org.eodisp.wrapper.hla
Class LongValuedLogicalTime

java.lang.Object
  extended by org.eodisp.wrapper.hla.LongValuedLogicalTime
All Implemented Interfaces:
hla.rti1516.LogicalTime, java.io.Serializable, java.lang.Comparable

public class LongValuedLogicalTime
extends java.lang.Object
implements hla.rti1516.LogicalTime

An immutable long-valued logical time value.

Author:
Andrzej Kapolka
See Also:
Serialized Form

Constructor Summary
LongValuedLogicalTime(long pValue)
          Creates a new XRTILogicalTime.
 
Method Summary
 hla.rti1516.LogicalTime add(hla.rti1516.LogicalTimeInterval val)
          Adds the specified time interval to this logical time, returning the result as a new LogicalTime.
 int compareTo(java.lang.Object other)
          Compares this logical time to another.
 hla.rti1516.LogicalTimeInterval distance(hla.rti1516.LogicalTime val)
          Computes and returns the time interval between this logical time and another one.
 void encode(byte[] buffer, int offset)
          Encodes this logical time, placing the result into the specified buffer.
 int encodedLength()
          Returns the encoded length of this logical time.
 boolean equals(java.lang.Object other)
          Checks this logical time for equality with another.
 int hashCode()
          Computes and returns a hash code corresponding to this logical time.
 boolean isFinal()
          Checks whether this represents a final time.
 boolean isInitial()
          Checks whether this represents an initial time.
 hla.rti1516.LogicalTime subtract(hla.rti1516.LogicalTimeInterval val)
          Subtracts the specified time interval from this logical time, returning the result as a new LogicalTime.
 java.lang.String toString()
          Returns a string representation of this logical time.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LongValuedLogicalTime

public LongValuedLogicalTime(long pValue)
Creates a new XRTILogicalTime.

Parameters:
pValue - the value of the logical time
Method Detail

isInitial

public boolean isInitial()
Checks whether this represents an initial time.

Specified by:
isInitial in interface hla.rti1516.LogicalTime
Returns:
true if this represents an initial time, false otherwise

isFinal

public boolean isFinal()
Checks whether this represents a final time.

Specified by:
isFinal in interface hla.rti1516.LogicalTime
Returns:
true if this represents a final time, false otherwise

add

public hla.rti1516.LogicalTime add(hla.rti1516.LogicalTimeInterval val)
                            throws hla.rti1516.IllegalTimeArithmetic
Adds the specified time interval to this logical time, returning the result as a new LogicalTime.

Specified by:
add in interface hla.rti1516.LogicalTime
Parameters:
val - the time interval to add to this logical time
Returns:
a new LogicalTime that represents this logical time plus the specified time interval
Throws:
hla.rti1516.IllegalTimeArithmetic - if the operation cannot be performed

subtract

public hla.rti1516.LogicalTime subtract(hla.rti1516.LogicalTimeInterval val)
                                 throws hla.rti1516.IllegalTimeArithmetic
Subtracts the specified time interval from this logical time, returning the result as a new LogicalTime.

Specified by:
subtract in interface hla.rti1516.LogicalTime
Parameters:
val - the time interval to subtract from this logical time
Returns:
a new LogicalTime that represents this logical time minus the specified time interval
Throws:
hla.rti1516.IllegalTimeArithmetic - if the operation cannot be performed

distance

public hla.rti1516.LogicalTimeInterval distance(hla.rti1516.LogicalTime val)
Computes and returns the time interval between this logical time and another one.

Specified by:
distance in interface hla.rti1516.LogicalTime
Parameters:
val - the other logical time
Returns:
the logical time interval between this logical time and the other logical time

compareTo

public int compareTo(java.lang.Object other)
Compares this logical time to another.

Specified by:
compareTo in interface hla.rti1516.LogicalTime
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
other - the logical time to compare this to
Returns:
+1 if this logical time is greater than the other one, -1 if this logical time is less than the other one, 0 if the two logical times are equal

equals

public boolean equals(java.lang.Object other)
Checks this logical time for equality with another.

Specified by:
equals in interface hla.rti1516.LogicalTime
Overrides:
equals in class java.lang.Object
Parameters:
other - the other logical time to compare this to
Returns:
true if the other object represents the same logical time as this one, false otherwise

hashCode

public int hashCode()
Computes and returns a hash code corresponding to this logical time.

Specified by:
hashCode in interface hla.rti1516.LogicalTime
Overrides:
hashCode in class java.lang.Object
Returns:
a hash code corresponding to this logical time

toString

public java.lang.String toString()
Returns a string representation of this logical time.

Specified by:
toString in interface hla.rti1516.LogicalTime
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this logical time

encodedLength

public int encodedLength()
Returns the encoded length of this logical time.

Specified by:
encodedLength in interface hla.rti1516.LogicalTime
Returns:
the encoded length of this logical time (in bytes)

encode

public void encode(byte[] buffer,
                   int offset)
Encodes this logical time, placing the result into the specified buffer.

Specified by:
encode in interface hla.rti1516.LogicalTime
Parameters:
buffer - the buffer in which to place the result
offset - the offset within the buffer at which to store the encoded value