Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class mil.navy.nps.dis.PduElement

java.lang.Object
  |
  +--mil.navy.nps.dis.PduElement
Subclasses:
AngularVelocity, ArticulationParameter, BurstDescriptor, ClockTime, DatumSpecification, EntityCoordinate, EntityID, EntityType, EulerAngle, EventID, FixedDatum, LinearAcceleration, LinearVelocity, ProtocolDataUnit, VariableDatum, WorldCoordinate

public abstract class PduElement
extends java.lang.Object
implements mil.navy.nps.util.SerializationInterface, java.lang.Cloneable
Version:
1.0
Author:
Don McGregor (http://www.stl.nps.navy.mil/~mcgredo)
Location:
http://www.stl.nps.navy.mil/dis-java-vrml/mil/navy/nps/dis/PduElement.java
Hierarchy Diagram:
Summary:
This abstract is inherited by all PDU classes; it can represent either a full PDU or simply a part of it.
Explanation:
The PduElement is an abstract class that other PDU classes inherit from. A pdu element can be a part of a pdu (such as the header portion of a full pdu) or a full pdu. It knows how to serialize and deserialize itself from or to a stream. Serialization must be to big endian format, and deserialization is assumed to be from big endian format.

Data is serialized or read from byte array input or output streams, which are closely related to the datagram buffers used to read or write datagrams to the wire.

This conforms to the SerializationInterface, a "protocol" (in obj-c terminology) that defines an abstract interface. See that interface for details. It also supports the Cloneable interface, with a public visibility rather than the default protected visibility.

All elements should implement a length() method, which specifies how many bytes the object will take up when serialized. Note that this might not be the same size as the current object; for example, the DIS standard specifies padding in a number of places to bring things up to word boundaries. The padding is not present in the object's ivars, but is when the object is written to the wire. Also, the length of a PDU might change over time, as (for example) more articulation parameters get added to the ESPDU.

As a debugging and analysis aid, printValues will dump to stdout the values of all the instance variables, plus any other information deemed appropriate. The printValues method takes an argument of the number of spaces to indent the values, to make things prettier. Typically you'll increment the indent value as you go farther down the object heirarchy.

History:
04Oct96 /DRM /New
09Oct96 /Don McGregor /changed name to PduElement, added to mil.navy.nps.dis package
28Oct96 /Don McGregor /added length() method
10Mar97 /Don McGregor /changes for javadoc
16Apr97 /Don McGregor /PrintStream passed to printValues
8Dec97 /Ronan Fauglas /Changes for documentation templates + complements in documentation
11Dec97 /Ronan Fauglas /changed access methods to class variables() to "getVariable()"
References:
DIS-Java-VRML Working Group: http://www.stl.nps.navy.mil/dis-java-vrml/
DIS Data Dictionary: http://stds.sc.ist.ucf.edu/dis/
DIS specification : IEEE 1278.1
See Also:
mil.navy.nps.util.SerializationInterface, java.lang.Cloneable, java.lang.Object

Constructor Summary
PduElement()
           
 
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 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.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Constructor Detail

PduElement

public PduElement()
Method Detail

serialize

public abstract void serialize(java.io.DataOutputStream outputStream)
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(java.io.DataOutputStream) in interface mil.navy.nps.util.SerializationInterface
Parameters:
outputStream - the stream to which this object is serialized

deSerialize

public abstract void deSerialize(java.io.DataInputStream inputStream)
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(java.io.DataInputStream) in interface mil.navy.nps.util.SerializationInterface
Parameters:
inputStream - the stream from which this object is initialized

length

public abstract int length()
Returns the length of the object when serialized in a stream.
Returns:
the length of the object when serialized in a stream

printValues

public abstract void printValues(int indentLevel,
                                 java.io.PrintStream printStream)
Prints the generated serialized object for debugging.
Parameters:
indentLevel - number of spaces to indent for visibility
printstream - defines the ouput stream

clone

public java.lang.Object clone()
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.
Returns:
a clone of this instance
Throws:
java.lang.RuntimeException - if the object doesn't support cloning.
Overrides:
clone in class java.lang.Object
See Also:
java.lang.Object

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD