org.web3d.vrtp.datatypes
Interface Primitive

All Known Implementing Classes:
DoublePrecision, OrderedMap, PrimitiveNumber, UnsignedShort

public interface Primitive

This is an interface that specifies the minimum requirements for "atomic" datatypes used in the dail-a-behavior project. Every element in a class needs to implement at least these functions.

The primitive types must be cloneable, so that we can make copies of them. They should also conform to the Comprable interface, so we can do things like sort them using the standard Java 1.2 collection classes. In addition, a primitive type must implement a no-args constructor, so we can create a new prototypical instance given only a class name.

In addition, there are several methods that are specific to dabp. These include getSize(), which tells us the size of the object when serialized, and toString, a standard java method used to convert data to strings for things like println.

Author Don McGregor (mcgredo@nps.navy.mil) Date: Yes, please. History


Method Summary
 java.lang.Object clone()
          Implementation of the Cloneable interface.
 int compareTo(java.lang.Object obj)
          Implementation of the Comparable interface.
 boolean equals(java.lang.Object obj)
          Returns true if the two objects are equal.
 int getSize()
          Number of bytes this takes up when serialized in binary format.
 int hashCode()
          Hashcode; compute a 32 bit hashcode for the object.
 void initializeWithBinary(byte[] pBinaryData, int offset)
          Initialize an already-existing object with binary data.
 void initializeWithString(java.lang.String pStringData)
          Initialize the object with the string data given.
 void serialize(java.io.DataOutputStream pOutputStream)
          Serialize data, using our own internal scheme, completely separate from that of the JDK serialization/externalizable scheme.
 java.lang.String toString()
          A standard java method.
 

Method Detail

getSize

public int getSize()
Number of bytes this takes up when serialized in binary format. this is computing using our own internal scheme for serialization; other schemes, such as the java or corba serialization, might be different.

serialize

public void serialize(java.io.DataOutputStream pOutputStream)
Serialize data, using our own internal scheme, completely separate from that of the JDK serialization/externalizable scheme.

toString

public java.lang.String toString()
A standard java method. It is used, for example, in println, or concatenating strings with '+'.
Overrides:
toString in class java.lang.Object

initializeWithBinary

public void initializeWithBinary(byte[] pBinaryData,
                                 int offset)
Initialize an already-existing object with binary data. the object must recoginize the binary data starting at the given offset.

initializeWithString

public void initializeWithString(java.lang.String pStringData)
Initialize the object with the string data given.

equals

public boolean equals(java.lang.Object obj)
Returns true if the two objects are equal. Sometimes you can do cross-class comparisions, for example if you're comparing an UnsignedShort to an Integer, but not always. And even then things like range might get in the way. Usually you have to check and make sure the ojbect passed in is of the same type.
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Hashcode; compute a 32 bit hashcode for the object.
Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(java.lang.Object obj)
Implementation of the Comparable interface. This is used by standard Java utilties classes to do things like sort arrays and the like. So as long as you implement this, you get sorting for "free".

clone

public java.lang.Object clone()
Implementation of the Cloneable interface. Returns a copy of the object, generally speaking a "deep copy" that in no way shares internal data with the original object.
Overrides:
clone in class java.lang.Object