Class PDU

    • Field Detail

      • commandID

        protected int commandID
      • commandStatus

        protected int commandStatus
      • sequenceNumber

        protected int sequenceNumber
    • Method Detail

      • getCommandLength

        public int getCommandLength()
      • getCommandID

        public int getCommandID()
      • getCommandStatus

        public int getCommandStatus()
      • getSequenceNumber

        public int getSequenceNumber()
      • setCommandID

        public void setCommandID​(int commandID)
      • setCommandStatus

        public void setCommandStatus​(int commandStatus)
      • setSequenceNumber

        public void setSequenceNumber​(int sequenceNumber)
      • toStream

        public void toStream​(DataOutput out)
                      throws IOException
        Specified by:
        toStream in interface com.opencloud.util.FastSerializable
        Throws:
        IOException
      • bodyToBuffer

        protected void bodyToBuffer​(ByteBuffer buf)
                             throws BufferOverflowException
        Write PDU body (not including header or TLVs) to a ByteBuffer. Subclasses MUST override this if they have any additional fields in their body. Fields must be written in big-endian byte order (the default with ByteBuffer anyway).
        Throws:
        BufferOverflowException
      • size

        public final int size()
        Description copied from class: ByteData
        Get the number of bytes that this object contains
        Specified by:
        size in class ByteData
      • headerSize

        protected final int headerSize()
      • bodySize

        protected int bodySize()
        Return size (in bytes) of PDU body (not including header or TLVs). Subclasses MUST override this if they have any additional fields in their body, so that PDU lengths will be calculated correctly.
      • tlvSize

        protected final int tlvSize()
        Get size (in bytes) of all optional TLVs that have been added to this PDU.
      • headerToString

        protected String headerToString()
      • bodyToString

        protected String bodyToString()
      • tlvToString

        protected String tlvToString()
      • addTLV

        public void addTLV​(TLV tlv)
                    throws TLVAlreadyExistsException
        Adds a TLV (optional field) to the end of this PDU. Note that for some types of TLV, the insertion order is significant, namely CALLBACK_NUM, CALLBACK_NUM_ATAG, CALLBACK_NUM_PRES_IND, and BROADCAST_AREA_IDENTIFIER, BROADCAST_ERROR_STATUS. For instance, there may be any number of callback TLVs and the order determines which CALLBACK_NUM_ATAG is associated with which CALLBACK_NUM etc. For all other TLV types, repetition is not permitted and attempting to add the same TLV twice will cause a TLVAlreadyExistsException.
        Parameters:
        tlv - the TLV to be added to this PDU.
        Throws:
        TLVAlreadyExistsException - if a TLV of the same type has already been added to the PDU.
      • getTLV

        public TLV getTLV​(short tag)
        Get the TLV object that has this tag.
        Parameters:
        tag - the TLV tag to search for.
        Returns:
        the TLV object containing tag, or null if it is not present in this PDU.
      • hasTLV

        public boolean hasTLV​(short tag)
      • getAllTLVs

        public List<TLV> getAllTLVs()
        Get the list of TLVs that this PDU contains. This should only be used by applications that need to support multiple occurrences of the same TLV (e.g. CALLBACK_NUM_xxx etc). For singular TLVs, use getTLV(short).
      • equals

        public boolean equals​(Object o)
        Compares given object with this PDU for equality, including header, body and optional TLVs.

        NOTE that the order/duplicates of TLVs are ONLY significant in terms of TLV pairs for TLV types, for which multiple occurrences are supported (e.g. CALLBACK_NUM_xxx etc). For all other TLV types the order/duplicates are insignificant in terms of the comparison result.

        Overrides:
        equals in class Object
      • headerEquals

        protected final boolean headerEquals​(PDU pdu)
      • bodyEquals

        protected boolean bodyEquals​(PDU pdu)
        Compares the body of given PDU with the body (not including header or TLVs) of this PDU for equality. Subclasses MUST override this if they have any additional fields in their body, so that PDUs comparison will be performed correctly.
      • tlvEquals

        protected final boolean tlvEquals​(PDU pdu)
        Compares the optional TLVs of given PDU with the optional TLVs of this PDU for equality.

        NOTE that the order/duplicates are ONLY significant in terms of TLV pairs for TLV types, for which multiple occurrences are supported (e.g. CALLBACK_NUM_xxx). For all other TLV types the order/duplicates are insignificant in terms of the comparison result.

      • hashCode

        public int hashCode()
        Get the hash code value of this PDU, including header, body and optional TLVs.

        NOTE that the hash code will be computed using the mutable PDU fields. Meaning that the resulting hash code value following a PDU field value change, may differ from the hash code computed before the change.

        Overrides:
        hashCode in class Object
      • headerHashCode

        protected final int headerHashCode()
      • bodyHashCode

        protected int bodyHashCode()
        Get the hash code value of PDU body (not including header or TLVs). Subclasses MUST override this if they have any additional fields in their body, so that PDU hash code will be calculated correctly.
      • tlvHashCode

        protected final int tlvHashCode()
        Get the hash code value of all optional TLVs that have been added to this PDU.