mil.navy.nps.dis
Class VariableDatum

java.lang.Object
  extended bymil.navy.nps.dis.PduElement
      extended bymil.navy.nps.dis.VariableDatum
All Implemented Interfaces:
java.lang.Cloneable, SerializationInterface

public class VariableDatum
extends PduElement

Variable-length data.

Version:
1.0
Author:
Don McGregor (http://www.npsnet.org/~mcgredo)
Location:
Web: http://www.web3d.org/WorkingGroups/vrtp/mil/navy/nps/dis/VariableDatum.java
or locally: ~/mil/navy/nps/dis/VariableDatum.java
Hierarchy Diagram:
Summary:
These fields shall specify the types of variable datum, their length, and their value.
Explanation
VariableDatum contains (surprise! a variable amount of data). It consists of a 32-bit enumeration that describes the datum, a 32-bit field that descibes the lenght of the data (in bits) and a data region long enough to contain the data. The data region is allocated in chunks of 64 bits; for example, if the length field specifies a data length of 48 bits, a full 64 bits will be allocated to hold the data, and the remaining 16 bits would be unused padding. Per the specification, padding must be set to zero.

The VariableDatum is used in a variety of places, most notably the DataPdu.

This inherits from PduElement, which means that it must know how to serialize, deSerialize, clone, print its values, and determine its length when serialized.

History:
21Nov96 /Don McGregor /New
10Mar97 /Don McGregor /changes for javadoc
16Apr97 /Don McGregor /PrintStream passed to printValues
06May97 /Don McGregor /Bug fixes: block count not beeing computed correctly; moved computation to central place, made all computations of block size point there. Accessor method variableDatumValue() was always returning null. Bug reports submitted by Dmitry Azovtsev (azov@logos.cyber.mephi.ru).
8Dec97 /Ronan Fauglas /changes for documentation templates + complements in documentation
11Dec97 /Ronan Fauglas /changes access methods names from "variable()" to "getVariable()"
References:
DIS Data Dictionary: Variable Datum Record
DIS specification : IEEE 1278.1, Section 5.3.32
See Also:
PduElement, SerializationInterface, DataPdu

Field Summary
static int sizeOf
          Constant value--size of an empty object WHEN WRITTEN TO THE WIRE; here :sizeOf = 8 bytes.
(package private)  int variableDatumID
          The Variable Datum ID shall be represented by a 32-bit enumeration.
(package private)  int variableDatumLength
          This field shall specify the length of the variable datum in bits.
(package private)  long[] variableDatumValue
          These field(s) shall store the value of the variable datum defined by the Variable Datum ID and Variable Datum length.
 
Constructor Summary
VariableDatum()
          Default constructor--fills with zeros for all values.
 
Method Summary
 java.lang.Object clone()
          Makes deep copies of all the instance variables, so we don't have two objects pointing to the same data.
 void deSerialize(java.io.DataInputStream inputStream)
          Deserialize our data from the input stream.
 int getVariableDatumID()
           
 int getVariableDatumLength()
           
 long[] getVariableDatumValue()
           
 int length()
          Returns the length of the object when serialized in a stream.
 void printValues(int indentLevel, java.io.PrintStream printStream)
          Prints the generated serialized object for debugging.
 void serialize(java.io.DataOutputStream outputStream)
          Serialize our data out to the stream.
 void setVariableDatumID(int pVariableDatumID)
           
 void setVariableDatumLength(int pVariableDatumLength)
           
 void setVariableDatumValue(long[] pVariableDatumValue)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

variableDatumID

int variableDatumID
The Variable Datum ID shall be represented by a 32-bit enumeration.
Value:
Enumeration; see references below for values. *
References:
DIS Data Dictionary : Datum ID Field
See section 7 in the EBV-DOC


variableDatumLength

int variableDatumLength
This field shall specify the length of the variable datum in bits.
References:
DIS Data Dictionary : Variable Datum Length Field


variableDatumValue

long[] variableDatumValue
These field(s) shall store the value of the variable datum defined by the Variable Datum ID and Variable Datum length.
Explanation:
The Variable Datum Value is stored in an array of long integers so as to respect the convention to have a multiple of 64 length.
References:
DIS Data Dictionary: Variable Datum Value/Padding Field


sizeOf

public static final int sizeOf
Constant value--size of an empty object WHEN WRITTEN TO THE WIRE; here :sizeOf = 8 bytes.

See Also:
Constant Field Values
Constructor Detail

VariableDatum

public VariableDatum()
Default constructor--fills with zeros for all values.

Method Detail

clone

public java.lang.Object clone()
Description copied from class: PduElement
Makes deep copies of all the instance variables, so we don't have two objects pointing to the same data. The accessor methods make copies of the objects, rather than returning the objects themselves. The runtime provides the right object type with the call to super.clone(), and we cast it to our type. Subclasses should do the same thing, and all these ivars will be taken care of automatically.

Overrides:
clone in class PduElement
Returns:
a clone of this instance
See Also:
Object

serialize

public void serialize(java.io.DataOutputStream outputStream)
Description copied from class: PduElement
Serialize our data out to the stream. Subclasses of us should call super.Serialize() to make sure the superclasse's data is serialized out. The order in which instance variables are serialized is significant. They must be serialized in the same order they appear in the DIS spec. Prints out some information during execution if debugging flag is set.

Specified by:
serialize in interface SerializationInterface
Specified by:
serialize in class PduElement
Parameters:
outputStream - the stream to which this object is serialized
Throws:
java.lang.RuntimeException - when IO error occurs.

deSerialize

public void deSerialize(java.io.DataInputStream inputStream)
Description copied from class: PduElement
Deserialize our data from the input stream. Subclasses of us should call super.deSerialize to make sure the superclass's data are properly affected. The order in which instance variables are serialized is significant. They must be deSerialized in the same order as they have been serialized as specified by the DIS spec.

Specified by:
deSerialize in interface SerializationInterface
Specified by:
deSerialize in class PduElement
Parameters:
inputStream - the stream from which this object is initialized
Throws:
java.lang.RuntimeException - when IO error occurs.

length

public int length()
Description copied from class: PduElement
Returns the length of the object when serialized in a stream.

Specified by:
length in class PduElement
Returns:
the length of the object when serialized in a stream

printValues

public void printValues(int indentLevel,
                        java.io.PrintStream printStream)
Description copied from class: PduElement
Prints the generated serialized object for debugging.

Specified by:
printValues in class PduElement
Parameters:
indentLevel - number of spaces to indent for visibility

getVariableDatumID

public int getVariableDatumID()

setVariableDatumID

public void setVariableDatumID(int pVariableDatumID)

getVariableDatumLength

public int getVariableDatumLength()

setVariableDatumLength

public void setVariableDatumLength(int pVariableDatumLength)

getVariableDatumValue

public long[] getVariableDatumValue()
Throws:
java.lang.RuntimeException - if Index error occurs while copying array
java.lang.RuntimeException - if error occurs while copying array.

setVariableDatumValue

public void setVariableDatumValue(long[] pVariableDatumValue)