Class VariableDatum

java.lang.Object
edu.nps.moves.dis7.pdus.VariableDatum
All Implemented Interfaces:
Serializable

public class VariableDatum extends Object implements Serializable
The variable datum type, the datum length, and the value for that variable datum type. Section 6.2.93 IEEE Std 1278.1-2012, IEEE Standard for Distributed Interactive Simulation—Application Protocols
See Also:
  • Field Details

    • variableDatumID

      protected VariableRecordType variableDatumID
      Type of variable datum to be transmitted. 32 bit enumeration defined in EBV uid 66
    • variableDatumLength

      protected Integer variableDatumLength
      Length, IN BITS, of the variable datum.
    • variableDatumValue

      protected byte[] variableDatumValue
      This field shall specify the value for a particular Variable Datum ID. The field format shall depend on the type of datum as specified by the Variable Datum ID. Variable datums can be any number of bits long.
  • Constructor Details

    • VariableDatum

      public VariableDatum()
      Constructor
  • Method Details

    • getMarshalledSize

      public int getMarshalledSize()
      Returns size of this serialized (marshalled) object in bytes
      Returns:
      serialized size in bytes
      See Also:
    • setVariableDatumID

      public VariableDatum setVariableDatumID(VariableRecordType pVariableDatumID)
      Setter for variableDatumID
      Parameters:
      pVariableDatumID - of interest
      Returns:
      same object to permit progressive setters
    • getVariableDatumID

      public VariableRecordType getVariableDatumID()
      Getter for variableDatumID
      Returns:
      value of field
    • setVariableDatumLengthInBits

      public VariableDatum setVariableDatumLengthInBits(int bitLength)
      Setter for variableDatumLength

      This value is the size IN BITS of the variableDatumValue field. Since that field is a byte array, its size must be large enough to contain the specified number of bits. If variableDatumValue is NOT set and this pdu is issued (marshaled), the value used when marshaling this field will be the size of the byte array times 8.

      Parameters:
      bitLength - number of bits for this field
      Returns:
      same object to permit progressive setters
    • setVariableDatumLengthInBytes

      public VariableDatum setVariableDatumLengthInBytes(int byteLength)
      Setter for variableDatumLength

      This value is the size in bytes of the variableDatumValue field. Since that field is a byte array, its size must be large enough to contain the value specified here. If variableDatumValue is NOT set and this pdu is issued (marshaled), the value used when marshaling this field will be the size of the byte array times 8.

      Parameters:
      byteLength - number of bytes for this field
      Returns:
      same object to permit progressive setters
    • getVariableDatumLength

      public int getVariableDatumLength()
      Returns:
      length
    • setVariableDatumValue

      public VariableDatum setVariableDatumValue(byte[] pVariableDatumValue)
      Setter for variableDatumValue

      This is described in the specification as a stream of bits, but is implemented in Java as a byte array. The size of the byte array reflects the value of variableDatumLength rounded to the next highest byte boundary. If variableDatumLength is not set when the Pdu is sent, the receiver will read a bit length equal to the size of the byte array times 8.

      Parameters:
      pVariableDatumValue - of interest
      Returns:
      same object to permit progressive setters
    • getVariableDatumValue

      public byte[] getVariableDatumValue()
      Returns:
      value of interest
    • marshal

      public void marshal(DataOutputStream dos) throws Exception
      Serializes an object to a DataOutputStream.
      Parameters:
      dos - The DataOutputStream
      Throws:
      Exception - if something goes wrong
      See Also:
    • unmarshal

      public int unmarshal(DataInputStream dis) throws Exception
      Deserializes an object from a DataInputStream.
      Parameters:
      dis - DataInputStream
      Returns:
      marshalled serialized size in bytes
      Throws:
      Exception - if something goes wrong
      See Also:
    • marshal

      public void marshal(ByteBuffer byteBuffer) throws Exception
      Packs an object into the ByteBuffer.
      Parameters:
      byteBuffer - The ByteBuffer at the position to begin writing
      Throws:
      BufferOverflowException - if buff is too small
      ReadOnlyBufferException - if buff is read only
      Exception - ByteBuffer-generated exception
      See Also:
    • unmarshal

      public int unmarshal(ByteBuffer byteBuffer) throws Exception
      Unpacks a Pdu from the underlying data.
      Parameters:
      byteBuffer - The ByteBuffer at the position to begin reading
      Returns:
      marshalled serialized size in bytes
      Throws:
      BufferUnderflowException - if buff is too small
      Exception - ByteBuffer-generated exception
      See Also:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equalsImpl

      public boolean equalsImpl(Object obj)
      Compare all fields that contribute to the state, ignoring transient and static fields, for this and the supplied object
      Parameters:
      obj - the object to compare to
      Returns:
      true if the objects are equal, false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object