Package edu.nps.moves.dis7.pdus
Class Pdu
java.lang.Object
edu.nps.moves.dis7.pdus.Pdu
- All Implemented Interfaces:
Marshaller
,Serializable
- Direct Known Subclasses:
LiveEntityFamilyPdu
,PduBase
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
FieldsModifier and TypeFieldDescriptionprotected byte
Exercise IDprotected short
Length, in bytes, of the PDUprotected DisPduType
Type of pdu, unique for each PDU class uid 4protected DISProtocolFamily
value that refers to the protocol family, eg SimulationManagement, et uid 5protected DISProtocolVersion
The version of the protocol. 5=DIS-1995, 6=DIS-1998, 7=DIS-2012 uid 3protected int
Timestamp value -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
equalsImpl(Object obj)
Compare all fields that contribute to the state, ignoring transient and static fields, forthis
and the supplied objectbyte
Getter forexerciseID
short
Getter forlength
int
Returns size of this serialized (marshalled) object in bytesGetter forpduType
Getter forprotocolFamily
Getter forprotocolVersion
int
Getter fortimestamp
byte[]
marshal()
A convenience method for marshalling to a byte array.void
marshal(DataOutputStream dos)
Serializes an object to a DataOutputStream.void
marshal(ByteBuffer byteBuffer)
Packs an object into the ByteBuffer.setExerciseID(byte pExerciseID)
Setter forexerciseID
setExerciseID(int pExerciseID)
Utility setter forexerciseID
setLength(int pLength)
Utility setter forlength
setLength(short pLength)
Setter forlength
setPduType(DisPduType pPduType)
Setter forpduType
setProtocolFamily(DISProtocolFamily pProtocolFamily)
Setter forprotocolFamily
setProtocolVersion(DISProtocolVersion pProtocolVersion)
Setter forprotocolVersion
setTimestamp(int pTimestamp)
Setter fortimestamp
toString()
int
unmarshal(DataInputStream dis)
Deserializes an object from a DataInputStream.int
unmarshal(ByteBuffer byteBuffer)
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 creates and configures a new instance object
-
-
Method Details
-
getMarshalledSize
public int getMarshalledSize()Returns size of this serialized (marshalled) object in bytes- Specified by:
getMarshalledSize
in interfaceMarshaller
- Returns:
- serialized size in bytes
- See Also:
- https://en.wikipedia.org/wiki/Marshalling_(computer_science)
-
setProtocolVersion
Setter forprotocolVersion
- Parameters:
pProtocolVersion
- new value of interest- Returns:
- same object to permit progressive setters
-
getProtocolVersion
Getter forprotocolVersion
- Returns:
- value of interest
-
setExerciseID
Setter forexerciseID
- Parameters:
pExerciseID
- new value of interest- Returns:
- same object to permit progressive setters
-
setExerciseID
Utility setter forexerciseID
- Parameters:
pExerciseID
- new value of interest- Returns:
- same object to permit progressive setters
-
getExerciseID
public byte getExerciseID()Getter forexerciseID
- Returns:
- value of interest
-
setPduType
Setter forpduType
- Parameters:
pPduType
- new value of interest- Returns:
- same object to permit progressive setters
-
getPduType
Getter forpduType
- Returns:
- value of interest
-
setProtocolFamily
Setter forprotocolFamily
- Parameters:
pProtocolFamily
- new value of interest- Returns:
- same object to permit progressive setters
-
getProtocolFamily
Getter forprotocolFamily
- Returns:
- value of interest
-
setTimestamp
Setter fortimestamp
- Parameters:
pTimestamp
- new value of interest- Returns:
- same object to permit progressive setters
-
getTimestamp
public int getTimestamp()Getter fortimestamp
- Returns:
- value of interest
-
setLength
Setter forlength
- Parameters:
pLength
- new value of interest- Returns:
- same object to permit progressive setters
-
setLength
Utility setter forlength
- Parameters:
pLength
- new value of interest- Returns:
- same object to permit progressive setters
-
getLength
public short getLength()Getter forlength
- Returns:
- value of interest
-
marshal
Serializes an object to a DataOutputStream.- Specified by:
marshal
in interfaceMarshaller
- Parameters:
dos
- the OutputStream- Throws:
Exception
- if something goes wrong- See Also:
DataOutputStream
-
unmarshal
Deserializes an object from a DataInputStream.- Specified by:
unmarshal
in interfaceMarshaller
- Parameters:
dis
- the InputStream- Returns:
- marshalled serialized size in bytes
- Throws:
Exception
- if something goes wrong- See Also:
DataInputStream
, https://en.wikipedia.org/wiki/Marshalling_(computer_science)
-
marshal
Packs an object into the ByteBuffer.- Specified by:
marshal
in interfaceMarshaller
- Parameters:
byteBuffer
- The ByteBuffer at the position to begin writing- Throws:
BufferOverflowException
- if byteBuffer is too smallReadOnlyBufferException
- if byteBuffer is read onlyException
- ByteBuffer-generated exception- See Also:
ByteBuffer
-
unmarshal
Unpacks a Pdu from the underlying data.- Specified by:
unmarshal
in interfaceMarshaller
- Parameters:
byteBuffer
- The ByteBuffer at the position to begin reading- Returns:
- marshalled serialized size in bytes
- Throws:
BufferUnderflowException
- if byteBuffer is too smallException
- ByteBuffer-generated exception- See Also:
ByteBuffer
, https://en.wikipedia.org/wiki/Marshalling_(computer_science)
-
marshal
A convenience method for marshalling to a byte array. This is not as efficient as reusing a ByteBuffer, but it is easy. -
equals
-
equalsImpl
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
-