org.web3d.vrtp.datatypes
Class LongInteger

java.lang.Object
  |
  +--org.web3d.vrtp.datatypes.PrimitiveNumber
        |
        +--org.web3d.vrtp.datatypes.LongInteger
All Implemented Interfaces:
ArithmeticIF, java.lang.Cloneable, java.lang.Comparable, Primitive, java.io.Serializable

public class LongInteger
extends PrimitiveNumber
implements ArithmeticIF

LongInteger, not to be confused with java.lang.Long. This contains some extra methods.

This is a 64-bit integer, eight bytes long.

Author:
Don McGregor mcgredo@nps.navy.mil
See Also:
Serialized Form

Field Summary
static int LONG_SIZE
           
 
Constructor Summary
LongInteger()
          Contructs a new LongInteger object and intializes its value to 0.
LongInteger(byte pData)
          Constructs an LongInteger object from a signed byte,
LongInteger(int pData)
          Constructs a new LongInteger from a primitive integer
LongInteger(long pData)
          Constructs a new LongInteger from a primitive long
LongInteger(short pData)
          Constructs an LongInteger object from a short,
LongInteger(java.lang.String pData)
          Constructor, takes string represenation of the long integer as input.
 
Method Summary
 void add(int pValue)
          Add the given amount to the data
 java.lang.Object clone()
          return a deep-copy new instance of this object.
 int compareTo(java.lang.Object obj)
          Implementation of the Comparable interface.
 void decrement()
          subtract one from the value
 double doubleValue()
          Returns the current value of this object as a java primitive double, after conversion.
 boolean equals(java.lang.Object obj)
          Compare for equality.
 float floatValue()
          Returns a the current value of this object as a float, after conversion.
 int getSize()
          Returns the size, in bytes, of this piece of data, when serialized in binary format
 int hashCode()
          Returns a hashcode for the object.
 void increment()
          add one to the value
 void initializeWithBinary(byte[] pBinaryData, int pOffset)
          Initialize an already-existing object with binary data.
 void initializeWithString(java.lang.String pStringData)
          Initialize the object with the string data given.
 int intValue()
          Returns the current value of this object as an int, after conversion.
 long longValue()
          Returns the current value of this object as a long, after conversion.
 void serialize(java.io.DataOutputStream pOutputStream)
          Yeech.
 void subtract(int pValue)
          subtract the given amount from the value
 java.lang.String toString()
          Returns a String object representing this UnsignedShort value.
 
Methods inherited from class org.web3d.vrtp.datatypes.PrimitiveNumber
byteValue, shortValue
 
Methods inherited from class java.lang.Object
, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LONG_SIZE

public static final int LONG_SIZE
Constructor Detail

LongInteger

public LongInteger(java.lang.String pData)
Constructor, takes string represenation of the long integer as input.
Parameters:
pData - string representation of long integer

LongInteger

public LongInteger()
Contructs a new LongInteger object and intializes its value to 0.

LongInteger

public LongInteger(byte pData)
Constructs an LongInteger object from a signed byte,
Parameters:
pData - java byte primitive type

LongInteger

public LongInteger(short pData)
Constructs an LongInteger object from a short,

LongInteger

public LongInteger(int pData)
Constructs a new LongInteger from a primitive integer

LongInteger

public LongInteger(long pData)
Constructs a new LongInteger from a primitive long
Method Detail

getSize

public int getSize()
Returns the size, in bytes, of this piece of data, when serialized in binary format

initializeWithBinary

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

Parameters:
pBinaryData - array containing binary value of this object
pOffset - point in the data that this object's value starts

initializeWithString

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

Parameters:
pStringData - string representation of the long integer

doubleValue

public double doubleValue()
Returns the current value of this object as a java primitive double, after conversion.
Overrides:
doubleValue in class PrimitiveNumber
Returns:
the current value of this object as a double float

floatValue

public float floatValue()
Returns a the current value of this object as a float, after conversion.
Overrides:
floatValue in class PrimitiveNumber
Returns:
the current value of this object as a float

intValue

public int intValue()
Returns the current value of this object as an int, after conversion.
Overrides:
intValue in class PrimitiveNumber
Returns:
the current value of this object as an int

longValue

public long longValue()
Returns the current value of this object as a long, after conversion.
Overrides:
longValue in class PrimitiveNumber
Returns:
the current value of this object as a long

toString

public java.lang.String toString()
Returns a String object representing this UnsignedShort value. This has massive problems with truncation.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the value of this object in base 10.

serialize

public void serialize(java.io.DataOutputStream pOutputStream)
Yeech. THis needs to be brought into line with javasoft's serialization schemes.

clone

public java.lang.Object clone()
return a deep-copy new instance of this object.
Overrides:
clone in class PrimitiveNumber

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".

equals

public boolean equals(java.lang.Object obj)
Compare for equality. Object being compared must be of type LongInteger for the equality to be true, so comparing an LongInteger value of 7 to an UnsignedShort value of 7 will return false.
Overrides:
equals in class PrimitiveNumber

hashCode

public int hashCode()
Returns a hashcode for the object. Since a long is 64 bits, and the hashcode must be 32 bits, we take the lower 32 bits of the long. This maximizes the probability we'll get something unique for a given value. Most of the time.
Overrides:
hashCode in class java.lang.Object

increment

public void increment()
add one to the value
Specified by:
increment in interface ArithmeticIF
Overrides:
increment in class PrimitiveNumber

decrement

public void decrement()
subtract one from the value
Specified by:
decrement in interface ArithmeticIF
Overrides:
decrement in class PrimitiveNumber

add

public void add(int pValue)
Add the given amount to the data
Specified by:
add in interface ArithmeticIF
Overrides:
add in class PrimitiveNumber

subtract

public void subtract(int pValue)
subtract the given amount from the value
Specified by:
subtract in interface ArithmeticIF
Overrides:
subtract in class PrimitiveNumber