Package edu.nps.moves.dis7
Class Pdu
java.lang.Object
edu.nps.moves.dis7.Pdu
- All Implemented Interfaces:
edu.nps.moves.dis7.Marshaller
,java.io.Serializable
- Direct Known Subclasses:
LiveEntityPdu
,PduBase
public abstract class Pdu
extends java.lang.Object
implements java.io.Serializable, edu.nps.moves.dis7.Marshaller
Base class of PduBase and LiveEntityPdu
IEEE Std 1278.1-2012, IEEE Standard for Distributed Interactive Simulation—Application Protocols
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected byte
exerciseID
Exercise IDprotected short
length
Length, in bytes, of the PDUprotected DISPDUType
pduType
Type of pdu, unique for each PDU class uid 4protected DISProtocolFamily
protocolFamily
value that refers to the protocol family, eg SimulationManagement, et uid 5protected DISProtocolVersion
protocolVersion
The version of the protocol.protected int
timestamp
Timestamp value -
Constructor Summary
Constructors Constructor Description Pdu()
Constructor -
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object obj)
boolean
equalsImpl(java.lang.Object obj)
Compare all fields that contribute to the state, ignoring transient and static fields, forthis
and the supplied objectbyte
getExerciseID()
Getter forexerciseID
short
getLength()
Getter forlength
int
getMarshalledSize()
Returns the size of this serialized object in bytesDISPDUType
getPduType()
Getter forpduType
DISProtocolFamily
getProtocolFamily()
Getter forprotocolFamily
DISProtocolVersion
getProtocolVersion()
Getter forprotocolVersion
int
getTimestamp()
Getter fortimestamp
byte[]
marshal()
A convenience method for marshalling to a byte array.void
marshal(java.io.DataOutputStream dos)
Serializes an object to a DataOutputStream.void
marshal(java.nio.ByteBuffer buff)
Packs an object into the ByteBuffer.Pdu
setExerciseID(byte pExerciseID)
Setter forexerciseID
Pdu
setLength(short pLength)
Setter forlength
Pdu
setPduType(DISPDUType pPduType)
Setter forpduType
Pdu
setProtocolFamily(DISProtocolFamily pProtocolFamily)
Setter forprotocolFamily
Pdu
setProtocolVersion(DISProtocolVersion pProtocolVersion)
Setter forprotocolVersion
Pdu
setTimestamp(int pTimestamp)
Setter fortimestamp
java.lang.String
toString()
int
unmarshal(java.io.DataInputStream dis)
Unserializes an object from a DataInputStream.int
unmarshal(java.nio.ByteBuffer buff)
Unpacks a Pdu from the underlying data.
-
Field Details
-
protocolVersion
The version of the protocol. 5=DIS-1995, 6=DIS-1998, 7=DIS-2012 uid 3 -
exerciseID
protected byte exerciseIDExercise ID -
pduType
Type of pdu, unique for each PDU class uid 4 -
protocolFamily
value that refers to the protocol family, eg SimulationManagement, et uid 5 -
timestamp
protected int timestampTimestamp value -
length
protected short lengthLength, in bytes, of the PDU
-
-
Constructor Details
-
Pdu
public Pdu()Constructor
-
-
Method Details
-
getMarshalledSize
public int getMarshalledSize()Returns the size of this serialized object in bytes- Specified by:
getMarshalledSize
in interfaceedu.nps.moves.dis7.Marshaller
-
setProtocolVersion
Setter forprotocolVersion
-
getProtocolVersion
Getter forprotocolVersion
-
setExerciseID
Setter forexerciseID
-
getExerciseID
public byte getExerciseID()Getter forexerciseID
-
setPduType
Setter forpduType
-
getPduType
Getter forpduType
-
setProtocolFamily
Setter forprotocolFamily
-
getProtocolFamily
Getter forprotocolFamily
-
setTimestamp
Setter fortimestamp
-
getTimestamp
public int getTimestamp()Getter fortimestamp
-
setLength
Setter forlength
-
getLength
public short getLength()Getter forlength
-
marshal
public void marshal(java.io.DataOutputStream dos) throws java.lang.ExceptionSerializes an object to a DataOutputStream.- Specified by:
marshal
in interfaceedu.nps.moves.dis7.Marshaller
- Parameters:
dos
- the OutputStream- Throws:
java.lang.Exception
- if something goes wrong- See Also:
DataOutputStream
-
unmarshal
public int unmarshal(java.io.DataInputStream dis) throws java.lang.ExceptionUnserializes an object from a DataInputStream.- Specified by:
unmarshal
in interfaceedu.nps.moves.dis7.Marshaller
- Parameters:
dis
- the InputStream- Returns:
- unmarshalled size
- Throws:
java.lang.Exception
- if something goes wrong- See Also:
DataInputStream
-
marshal
public void marshal(java.nio.ByteBuffer buff) throws java.lang.ExceptionPacks an object into the ByteBuffer.- Specified by:
marshal
in interfaceedu.nps.moves.dis7.Marshaller
- Parameters:
buff
- The ByteBuffer at the position to begin writing- Throws:
java.nio.BufferOverflowException
- if buff is too smalljava.nio.ReadOnlyBufferException
- if buff is read onlyjava.lang.Exception
- ByteBuffer-generated exception- See Also:
ByteBuffer
-
unmarshal
public int unmarshal(java.nio.ByteBuffer buff) throws java.lang.ExceptionUnpacks a Pdu from the underlying data.- Specified by:
unmarshal
in interfaceedu.nps.moves.dis7.Marshaller
- Parameters:
buff
- The ByteBuffer at the position to begin reading- Returns:
- marshalled size
- Throws:
java.nio.BufferUnderflowException
- if buff is too smalljava.lang.Exception
- ByteBuffer-generated exception- See Also:
ByteBuffer
-
marshal
public byte[] marshal() throws java.lang.ExceptionA convenience method for marshalling to a byte array. This is not as efficient as reusing a ByteBuffer, but it is easy.- Returns:
- a byte array with the marshalled
Pdu
- Throws:
java.lang.Exception
- ByteBuffer-generated exception
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
equalsImpl
public boolean equalsImpl(java.lang.Object obj)Compare all fields that contribute to the state, ignoring transient and static fields, forthis
and the supplied object- Parameters:
obj
- the object to compare to- Returns:
- true if the objects are equal, false otherwise.
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-