org.ka2ddo.opentrac
Class OpenTracElement

java.lang.Object
  extended by org.ka2ddo.opentrac.OpenTracElement
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
OpenTracByte, OpenTracByteArray, OpenTracCountryCode, OpenTracCourseSpeed, OpenTracDouble, OpenTracEntity, OpenTracFloat, OpenTracNull, OpenTracPathTrace, OpenTracPosition, OpenTracRadioCapabilities, OpenTracShort, OpenTracString, OpenTracTimestamp, OpenTracWeatherObs

public abstract class OpenTracElement
extends java.lang.Object
implements java.io.Serializable

This class is the generic parent of the different data types of OpenTrac element data. Subclasses of this class should be implemented for each value data type (byte, short, float, string, etc.).

See Also:
Serialized Form

Field Summary
 int id
           
 
Constructor Summary
OpenTracElement()
           
 
Method Summary
abstract  int computeBody(byte[] buf, int offset)
          Append this element to a message buffer
abstract  boolean equals(OpenTracElement other)
          Test if this OpenTracElement has the same type and value as another OpenTracElement.
 int getId()
          Get the element ID for this element.
abstract  int length()
          Return the number of bytes needed to encode this element.
 java.lang.String toString()
          Returns a string representation of the object.
abstract  java.lang.String valueString()
          Get the string representation of the value of this element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

public int id
Constructor Detail

OpenTracElement

public OpenTracElement()
Method Detail

getId

public int getId()
Get the element ID for this element.

Returns:
element ID

valueString

public abstract java.lang.String valueString()
Get the string representation of the value of this element.

Returns:
value string

toString

public java.lang.String toString()
Returns a string representation of the object.

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

computeBody

public abstract int computeBody(byte[] buf,
                                int offset)
Append this element to a message buffer

Parameters:
buf - byte array to add the element to
offset - starting index to store the element
Returns:
index after the end of the stored element

length

public abstract int length()
Return the number of bytes needed to encode this element.

Returns:
byte count needed to hold this element

equals

public abstract boolean equals(OpenTracElement other)
Test if this OpenTracElement has the same type and value as another OpenTracElement.

Parameters:
other - OpenTracElement to compare against this element
Returns:
boolean true if elements are of the same type, class, and value