Class SMSTPDU

  • All Implemented Interfaces:
    DataObject, Serializable
    Direct Known Subclasses:
    SMSCommand, SMSReserved, SMSTPDUWithData

    public abstract class SMSTPDU
    extends AbstractLazyEncodedByteArray
    Representation of a SMS-TPDU as defined in 3GPP TS 23.040 V9.0.0 (2009-06).

    In general, accessors of all subclasses of SMSTPDU follow the following rules:

    • getXXX() and setXXX() call checkDecode() to decode data when required. checkDecode() may throw DecodeException or ArrayIndexOutOfBoundsException.
    • setXXX() throws IllegalStateException if the object is immutable or was set read-only
    • setXXX() throws IllegalArgumentException if the provided value is out of range

    For the sake of brevity, this common behaviour is not described individually on each accessor method.

    See Also:
    Serialized Form
    • Constructor Detail

      • SMSTPDU

        public SMSTPDU()
        Constructs a new SMSTPDU object with no fields set.
      • SMSTPDU

        public SMSTPDU​(byte[] data)
        Constructs a new SMSTPDU object from network-encoded data. The data is not decoded and might not be decodable.
        Parameters:
        data - network-encoded data
        Throws:
        NullPointerException - if data is null
      • SMSTPDU

        public SMSTPDU​(byte[] data,
                       int start,
                       int len)
        Constructs a new SMSTPDU object from part of network-encoded data. The part starts at index start and is len bytes long. The data is not decoded and might not be decodable.
        Parameters:
        data - network-encoded data
        start - starting offset of network-encoded data in byte array
        len - default length if not predictable
        Throws:
        NullPointerException - if data is null
        IllegalArgumentException - if len is negative
    • Method Detail

      • getType

        public abstract SMSTPDU.Type getType()
        Return the message type of this PDU
        Returns:
        the type
      • getEncodedForm

        public abstract byte[] getEncodedForm()
                                       throws EncodeException
        Encode this message to the network form. If the message is already encoded, the existing encoding is reused.
        Returns:
        a bytearray containing the encoded form
        Throws:
        EncodeException - if the PDU is missing mandatory fields, or provided field values are inconsistent
      • decodeRPMOData

        public static SMSTPDU decodeRPMOData​(byte[] message,
                                             int start,
                                             int len)
        Decode the SM-TL payload of a SM-RL RP-MO-DATA message (TPDU transferred from MS to SC) Only basic message-type decoding is performed immediately. Decoding of other fields is deferred until accessed, or until AbstractLazyEncodedDataObject.checkDecode() is called.
        Parameters:
        message - a bytearray containing the encoded PDU
        start - the offset within 'message' to begin decoding
        len - the number of valid bytes after 'offset' to decode (must be at least 1)
        Returns:
        the decoded message
        Throws:
        NullPointerException - if message is null
        ArrayIndexOutOfBoundsException - if start or len are out of range
      • decodeRPMOData

        public static SMSTPDU decodeRPMOData​(byte[] message)
        Decode the SM-TL payload of a SM-RL RP-MO-DATA message (TPDU transferred from MS to SC) Equivalent to decodeRPMOData(message, 0, message.length)
        Parameters:
        message - a bytearray containing the encoded PDU
        Returns:
        the decoded message
        Throws:
        NullPointerException - if message is null
      • encodeRPMOData

        public static byte[] encodeRPMOData​(SMSTPDU tpdu)
        Encode a TPDU for sending as the payload of a SM-RL RP-MO-DATA message.
        Parameters:
        tpdu - the pdu to encode
        Returns:
        the encoded form of the PDU
        Throws:
        EncodeException - if the TPDU could not be encoded for use in the RP-MO-DATA context
      • decodeRPMTData

        public static SMSTPDU decodeRPMTData​(byte[] message,
                                             int start,
                                             int len)
        Decode the SM-TL payload of a SM-RL RP-MT-DATA message (TPDU transferred from SC to MS) Only basic message-type decoding is performed immediately. Decoding of other fields is deferred until accessed, or until AbstractLazyEncodedDataObject.checkDecode() is called.
        Parameters:
        message - a bytearray containing the encoded PDU
        start - the offset within 'message' to begin decoding
        len - the number of valid bytes after 'offset' to decode (must be at least 1)
        Returns:
        the decoded message
        Throws:
        NullPointerException - if message is null
        ArrayIndexOutOfBoundsException - if start or len are out of range
      • decodeRPMTData

        public static SMSTPDU decodeRPMTData​(byte[] message)
        Decode the SM-TL payload of a SM-RL RP-MT-DATA message (TPDU transferred from SC to MS) Equivalent to decodeRPMTData(message, 0, message.length)
        Parameters:
        message - a bytearray containing the encoded PDU
        Returns:
        the decoded message
        Throws:
        NullPointerException - if message is null
        ArrayIndexOutOfBoundsException - if message is empty
      • encodeRPMTData

        public static byte[] encodeRPMTData​(SMSTPDU tpdu)
        Encode a TPDU for sending as the payload of a SM-RL RP-MT-DATA message.
        Parameters:
        tpdu - the pdu to encode
        Returns:
        the encoded form of the PDU
        Throws:
        EncodeException - if the TPDU could not be encoded for use in the RP-MT-DATA context
      • decodeRPAck

        public static SMSTPDU decodeRPAck​(byte[] message,
                                          int start,
                                          int len)
        Decode the SM-TL payload of a SM-RL RP-ACK message (positive ack of RP-MO-DATA or RP-MT-DATA) Only basic message-type decoding is performed immediately. Decoding of other fields is deferred until accessed, or until AbstractLazyEncodedDataObject.checkDecode() is called.
        Parameters:
        message - a bytearray containing the encoded PDU
        start - the offset within 'message' to begin decoding
        len - the number of valid bytes after 'offset' to decode (must be at least 1)
        Returns:
        the decoded message
        Throws:
        NullPointerException - if message is null
        ArrayIndexOutOfBoundsException - if start or len are out of range
      • decodeRPAck

        public static SMSTPDU decodeRPAck​(byte[] message)
        Decode the SM-TL payload of a SM-RL RP-ACK message (positive ack of RP-MO-DATA or RP-MT-DATA) Equivalent to decodeRPAck(message, 0, message.length)
        Parameters:
        message - a bytearray containing the encoded PDU
        Returns:
        the decoded message
        Throws:
        NullPointerException - if message is null
        ArrayIndexOutOfBoundsException - if message is empty
      • encodeRPAck

        public static byte[] encodeRPAck​(SMSTPDU tpdu)
        Encode a TPDU for sending as the payload of a SM-RL RP-ACK message.
        Parameters:
        tpdu - the pdu to encode
        Returns:
        the encoded form of the PDU
        Throws:
        EncodeException - if the TPDU could not be encoded for use in the RP-ACK context
      • decodeRPError

        public static SMSTPDU decodeRPError​(byte[] message,
                                            int start,
                                            int len)
        Decode the SM-TL payload of a SM-RL RP-ERROR message (negative ack of RP-MO-DATA or RP-MT-DATA) Only basic message-type decoding is performed immediately. Decoding of other fields is deferred until accessed, or until AbstractLazyEncodedDataObject.checkDecode() is called.
        Parameters:
        message - a bytearray containing the encoded PDU
        start - the offset within 'message' to begin decoding
        len - the number of valid bytes after 'offset' to decode (must be at least 1)
        Returns:
        the decoded message
        Throws:
        NullPointerException - if message is null
        ArrayIndexOutOfBoundsException - if start or len are out of range
      • decodeRPError

        public static SMSTPDU decodeRPError​(byte[] message)
        Decode the SM-TL payload of a SM-RL RP-ERROR message (negative ack of RP-MO-DATA or RP-MT-DATA). Equivalent to decodeRPError(message, 0, message.length)
        Parameters:
        message - a bytearray containing the encoded PDU
        Returns:
        the decoded message
        Throws:
        NullPointerException - if message is null
        ArrayIndexOutOfBoundsException - if message is empty
      • encodeRPError

        public static byte[] encodeRPError​(SMSTPDU tpdu)
        Encode this TPDU for sending as the payload of a SM-RL RP-ERROR message.
        Parameters:
        tpdu - the pdu to encode
        Returns:
        the encoded form of the PDU
        Throws:
        EncodeException - if the TPDU could not be encoded for use in the RP-ERROR context