Class SMSTPDUWithData
- java.lang.Object
-
- com.opencloud.util.AbstractDataObject
-
- com.opencloud.util.AbstractFieldsObject
-
- AbstractEncodedDataObject<T>
-
- AbstractLazyEncodedDataObject<byte[]>
-
- AbstractLazyEncodedByteArray
-
- com.opencloud.slee.resources.in.datatypes.sms.SMSTPDU
-
- com.opencloud.slee.resources.in.datatypes.sms.SMSTPDUWithData
-
- All Implemented Interfaces:
DataObject
,Serializable
- Direct Known Subclasses:
SMSDeliver
,SMSDeliverReport
,SMSStatusReport
,SMSSubmit
,SMSSubmitReport
public abstract class SMSTPDUWithData extends SMSTPDU
Superclass handling common methods for dealing with user data: ProtocolId (TP-PID), UserData (TP-UD), UserDataLength (TP-UDL), UserDataHeaderIndicator (TP-UDHI), and DataCodingScheme (TP-DCS).Field onlyHeader, when present, causes the userDataLength and userData fields to be omitted on encoding and to be required to be absent on decoding; it doesn't prevent values from being set for those fields, those fields still participate in the Map returned by getFieldsMap(), and hence equals(), hashCode() and toString() are still affected.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SMSTPDUWithData.UserDataHeaderIndicator
Enumeration of User Data Header Indicator constants.-
Nested classes/interfaces inherited from class com.opencloud.slee.resources.in.datatypes.sms.SMSTPDU
SMSTPDU.Type
-
-
Field Summary
Fields Modifier and Type Field Description protected SMSDataCodingScheme
DataCodingScheme_value
Value of field DataCodingScheme.protected boolean
OnlyHeader_present
Whether field OnlyHeader is present.protected ASN1Null
OnlyHeader_value
Value of field OnlyHeader.protected SMSProtocolId
ProtocolId_value
Value of field ProtocolId.protected byte[]
UserData_value
Value of field UserData.protected SMSTPDUWithData.UserDataHeaderIndicator
UserDataHeaderIndicator_value
Value of field UserDataHeaderIndicator.protected boolean
UserDataLength_present
Whether field UserDataLength is present.protected int
UserDataLength_value
Value of field UserDataLength.-
Fields inherited from class com.opencloud.slee.resources.cgin.AbstractLazyEncodedDataObject
isDecoded
-
Fields inherited from class com.opencloud.slee.resources.cgin.AbstractEncodedDataObject
encoded
-
Fields inherited from class com.opencloud.util.AbstractFieldsObject
FIELD_ABSENT, FIELD_UNINITIALISED
-
-
Constructor Summary
Constructors Constructor Description SMSTPDUWithData()
Constructs a new SMSTPDUWithData object with no fields set.SMSTPDUWithData(byte[] data)
Constructs a new SMSTPDUWithData object from network-encoded data.SMSTPDUWithData(byte[] data, int start, int len)
Constructs a new SMSTPDUWithData object from part of network-encoded data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkFieldsSet()
Checks that all mandatory fields are present.protected void
checkUserDataConstraints()
Checks that UserData (TP-UD), UserDataLength (TP-UDL), and DataCodingScheme (TP-DCS) are consistent with each other.SMSDataCodingScheme
getDataCodingScheme()
Gets the value of the coding scheme within the user data.SMSProtocolId
getProtocolId()
Gets the value of identifies the above layer protocol.byte[]
getUserData()
Gets the value of the user data.byte[]
getUserDataHeader()
Gets the UserDataHeader portion of the UserData (TP-UD), if present.SMSTPDUWithData.UserDataHeaderIndicator
getUserDataHeaderIndicator()
Gets the value of whether user data contains a header.int
getUserDataLength()
Gets the value of the length of the user data.String
getUserDataString()
Gets the text portion of UserData (TP-UD) in String form.boolean
hasDataCodingScheme()
Tests whether the field DataCodingScheme has a value.boolean
hasOnlyHeader()
Tests whether the field OnlyHeader has a value.boolean
hasProtocolId()
Tests whether the field ProtocolId has a value.boolean
hasUserData()
Tests whether the field UserData has a value.boolean
hasUserDataHeaderIndicator()
Tests whether the field UserDataHeaderIndicator has a value.boolean
hasUserDataLength()
Tests whether the field UserDataLength has a value.SMSTPDUWithData
setDataCodingScheme(SMSDataCodingScheme value)
Sets the value of the coding scheme within the user data.SMSTPDUWithData
setOnlyHeaderPresent(boolean flag)
Sets the presence or absence of the field OnlyHeader.SMSTPDUWithData
setProtocolId(SMSProtocolId value)
Sets the value of identifies the above layer protocol.void
setReadOnly()
Sets this and all its fields to be immutable.SMSTPDUWithData
setUserData(byte[] value)
Sets the value of the user data.SMSTPDUWithData
setUserDataHeaderIndicator(SMSTPDUWithData.UserDataHeaderIndicator value)
Sets the value of whether user data contains a header.SMSTPDUWithData
setUserDataLength(int value)
Sets the value of the length of the user data.SMSTPDUWithData
setUserDataLengthPresent(boolean flag)
Sets the presence or absence of the field UserDataLength.void
setUserDataString(SMSDataCodingScheme dcs, String value)
Sets UserData (TP-UD) to the given text value, using a provided DataCodingScheme (DCS) and no UserDataHeader (UDH).void
setUserDataString(SMSDataCodingScheme dcs, String value, byte[] header)
Sets UserData (TP-UD) to the given text value, using a provided DataCodingScheme (DCS) and an optional UserDataHeader (UDH).void
setUserDataString(String value)
Sets UserData (TP-UD) to the given text value, with no UserDataHeader (UDH).void
setUserDataString(String value, byte[] header)
Sets UserData (TP-UD) to the given text value, with an optional UserDataHeader (UDH).-
Methods inherited from class com.opencloud.slee.resources.in.datatypes.sms.SMSTPDU
decodeRPAck, decodeRPAck, decodeRPError, decodeRPError, decodeRPMOData, decodeRPMOData, decodeRPMTData, decodeRPMTData, encodeRPAck, encodeRPError, encodeRPMOData, encodeRPMTData, getEncodedForm, getType
-
Methods inherited from class com.opencloud.slee.resources.cgin.AbstractLazyEncodedDataObject
checkDecode, checkModifyAndDecode, decode, encode
-
Methods inherited from class com.opencloud.util.AbstractFieldsObject
equals, getFieldsMap, hashCode, toString
-
Methods inherited from class com.opencloud.util.AbstractDataObject
checkModify, clone, isReadOnly
-
-
-
-
Field Detail
-
OnlyHeader_value
protected ASN1Null OnlyHeader_value
Value of field OnlyHeader.
-
OnlyHeader_present
protected boolean OnlyHeader_present
Whether field OnlyHeader is present.
-
UserDataHeaderIndicator_value
protected SMSTPDUWithData.UserDataHeaderIndicator UserDataHeaderIndicator_value
Value of field UserDataHeaderIndicator.
-
ProtocolId_value
protected SMSProtocolId ProtocolId_value
Value of field ProtocolId.
-
DataCodingScheme_value
protected SMSDataCodingScheme DataCodingScheme_value
Value of field DataCodingScheme.
-
UserDataLength_value
protected int UserDataLength_value
Value of field UserDataLength.
-
UserDataLength_present
protected boolean UserDataLength_present
Whether field UserDataLength is present.
-
UserData_value
protected byte[] UserData_value
Value of field UserData.
-
-
Constructor Detail
-
SMSTPDUWithData
public SMSTPDUWithData()
Constructs a new SMSTPDUWithData object with no fields set.
-
SMSTPDUWithData
public SMSTPDUWithData(byte[] data)
Constructs a new SMSTPDUWithData 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
-
SMSTPDUWithData
public SMSTPDUWithData(byte[] data, int start, int len)
Constructs a new SMSTPDUWithData object from part of network-encoded data. The part starts at indexstart
and islen
bytes long. The data is not decoded and might not be decodable.- Parameters:
data
- network-encoded datastart
- starting offset of network-encoded data in byte arraylen
- default length if not predictable- Throws:
NullPointerException
- if data is nullIllegalArgumentException
- if len is negative
-
-
Method Detail
-
hasOnlyHeader
public boolean hasOnlyHeader() throws DecodeException
Tests whether the field OnlyHeader has a value.- Returns:
- whether the field has a value
- Throws:
DecodeException
- if encoded state cannot be decoded
-
setOnlyHeaderPresent
public SMSTPDUWithData setOnlyHeaderPresent(boolean flag) throws IllegalStateException
Sets the presence or absence of the field OnlyHeader.- Parameters:
flag
- whether the field should be marked as present- Returns:
- this
- Throws:
IllegalStateException
- if this instance has been marked as read-only
-
hasUserDataHeaderIndicator
public boolean hasUserDataHeaderIndicator() throws DecodeException
Tests whether the field UserDataHeaderIndicator has a value.- Returns:
- whether the field has a value
- Throws:
DecodeException
- if encoded state cannot be decoded
-
hasProtocolId
public boolean hasProtocolId() throws DecodeException
Tests whether the field ProtocolId has a value.- Returns:
- whether the field has a value
- Throws:
DecodeException
- if encoded state cannot be decoded
-
hasDataCodingScheme
public boolean hasDataCodingScheme() throws DecodeException
Tests whether the field DataCodingScheme has a value.- Returns:
- whether the field has a value
- Throws:
DecodeException
- if encoded state cannot be decoded
-
hasUserDataLength
public boolean hasUserDataLength() throws DecodeException
Tests whether the field UserDataLength has a value.- Returns:
- whether the field has a value
- Throws:
DecodeException
- if encoded state cannot be decoded
-
setUserDataLengthPresent
public SMSTPDUWithData setUserDataLengthPresent(boolean flag) throws IllegalStateException
Sets the presence or absence of the field UserDataLength.- Parameters:
flag
- whether the field should be marked as present- Returns:
- this
- Throws:
IllegalStateException
- if this instance has been marked as read-only
-
hasUserData
public boolean hasUserData() throws DecodeException
Tests whether the field UserData has a value.- Returns:
- whether the field has a value
- Throws:
DecodeException
- if encoded state cannot be decoded
-
checkFieldsSet
public void checkFieldsSet() throws EncodeException
Checks that all mandatory fields are present. Should be called immediately before all calls to encode().- Overrides:
checkFieldsSet
in classSMSTPDU
- Throws:
EncodeException
- if any mandatory field is not present
-
getUserDataHeaderIndicator
public SMSTPDUWithData.UserDataHeaderIndicator getUserDataHeaderIndicator() throws DecodeException
Gets the value of whether user data contains a header.- Returns:
- UserDataHeaderIndicator representation of whether user data contains a header
- Throws:
DecodeException
- if encoded state cannot be decoded
-
getProtocolId
public SMSProtocolId getProtocolId() throws DecodeException
Gets the value of identifies the above layer protocol.- Returns:
- SMSProtocolId representation of identifies the above layer protocol
- Throws:
DecodeException
- if encoded state cannot be decoded
-
getDataCodingScheme
public SMSDataCodingScheme getDataCodingScheme() throws DecodeException
Gets the value of the coding scheme within the user data.- Returns:
- SMSDataCodingScheme representation of the coding scheme within the user data
- Throws:
DecodeException
- if encoded state cannot be decoded
-
getUserDataLength
public int getUserDataLength() throws DecodeException
Gets the value of the length of the user data.- Returns:
- int representation of the length of the user data
- Throws:
DecodeException
- if encoded state cannot be decoded
-
getUserData
public byte[] getUserData() throws DecodeException
Gets the value of the user data.- Returns:
- byte[] representation of the user data
- Throws:
DecodeException
- if encoded state cannot be decoded
-
setUserDataHeaderIndicator
public SMSTPDUWithData setUserDataHeaderIndicator(SMSTPDUWithData.UserDataHeaderIndicator value) throws IllegalStateException
Sets the value of whether user data contains a header.- Parameters:
value
- UserDataHeaderIndicator representation of whether user data contains a header- Returns:
- this
- Throws:
IllegalStateException
-
setProtocolId
public SMSTPDUWithData setProtocolId(SMSProtocolId value) throws IllegalStateException
Sets the value of identifies the above layer protocol.- Parameters:
value
- SMSProtocolId representation of identifies the above layer protocol- Returns:
- this
- Throws:
IllegalStateException
-
setDataCodingScheme
public SMSTPDUWithData setDataCodingScheme(SMSDataCodingScheme value) throws IllegalStateException
Sets the value of the coding scheme within the user data.- Parameters:
value
- SMSDataCodingScheme representation of the coding scheme within the user data- Returns:
- this
- Throws:
IllegalStateException
-
setUserDataLength
public SMSTPDUWithData setUserDataLength(int value) throws IllegalStateException
Sets the value of the length of the user data.- Parameters:
value
- int representation of the length of the user data- Returns:
- this
- Throws:
IllegalStateException
-
setUserData
public SMSTPDUWithData setUserData(byte[] value) throws IllegalStateException
Sets the value of the user data.- Parameters:
value
- byte[] representation of the user data- Returns:
- this
- Throws:
IllegalStateException
-
setReadOnly
public void setReadOnly()
Sets this and all its fields to be immutable.- Specified by:
setReadOnly
in interfaceDataObject
- Overrides:
setReadOnly
in classAbstractDataObject
-
getUserDataHeader
public final byte[] getUserDataHeader()
Gets the UserDataHeader portion of the UserData (TP-UD), if present.- Returns:
- the header as a bytearray, or
null
if UserData (TP-UD) is not present or it does not contain a UserDataHeader (UDH)
-
getUserDataString
public final String getUserDataString()
Gets the text portion of UserData (TP-UD) in String form. This method only decodes data encoded using the 7-bit GSM and UCS-2 Data Coding Schemes. For other data coding schemes, the user must decode the data themselves.- Returns:
- a String representing the text portion of UserData (TP-UD), or
null
if UserData (TP-UD) is not present - Throws:
IllegalArgumentException
- if the PDU cannot be decoded or the Data Coding Scheme is not supportedArrayIndexOutOfBoundsException
- if the PDU is truncated
-
setUserDataString
public final void setUserDataString(String value)
Sets UserData (TP-UD) to the given text value, with no UserDataHeader (UDH). DataCodingScheme (TP-DCS) is set to the 7-bit GSM coding scheme if the string can be represented in the 7-bit alphabet; otherwise, the UCS-2 coding scheme is used. UserDataLength (TP-UDL) is set appropriately. UserDataHeaderIndicator (TP-UDHI) is cleared.- Parameters:
value
- the text value to use, ornull
to clear UserData (TP-UD)- Throws:
IllegalArgumentException
- if the PDU cannot be decoded, or the resulting UserData (TP-UD) exceeds 140 octets.ArrayIndexOutOfBoundsException
- if the PDU is truncated
-
setUserDataString
public final void setUserDataString(String value, byte[] header)
Sets UserData (TP-UD) to the given text value, with an optional UserDataHeader (UDH). DataCodingScheme (TP-DCS) is set to the 7-bit GSM coding scheme if the string can be represented in the 7-bit alphabet; otherwise, the UCS-2 coding scheme is used. UserDataLength (TP-UDL) is set appropriately. If a header is supplied, UserDataHeaderIndicator (TP-UDHI) is set and the provided header is added to UserData (TP-UD). If no header is supplied, UserDataHeaderIndicator (TP-UDHI) is cleared.- Parameters:
value
- the text value to use, ornull
to provide no text.header
- the UserDataHeader (UDH) contents to use, ornull
to provide no header.- Throws:
IllegalArgumentException
- if the PDU cannot be decoded, or the resulting UserData (TP-UD) exceeds 140 octets.ArrayIndexOutOfBoundsException
- if the PDU is truncated
-
setUserDataString
public final void setUserDataString(SMSDataCodingScheme dcs, String value)
Sets UserData (TP-UD) to the given text value, using a provided DataCodingScheme (DCS) and no UserDataHeader (UDH). Only 7-bit GSM and UCS-2 based coding schemes are supported. DataCodingScheme (TP-DCS) is set to the provided value. UserDataLength (TP-UDL) is set appropriately. If a header is supplied, UserDataHeaderIndicator (TP-UDHI) is set and the provided header is added to UserData (TP-UD). If no header is supplied, UserDataHeaderIndicator (TP-UDHI) is cleared.- Parameters:
dcs
- the DataCodingScheme (TP-DCS) value to usevalue
- the text value to use- Throws:
IllegalArgumentException
- if the PDU cannot be decoded, or DataCodingScheme (TP-DCS) is out of range, or the given DataCodingScheme (DCS) cannot encode the given value, or the resulting UserData (TP-UD) exceeds 140 octetsArrayIndexOutOfBoundsException
- if the PDU is truncated
-
setUserDataString
public final void setUserDataString(SMSDataCodingScheme dcs, String value, byte[] header)
Sets UserData (TP-UD) to the given text value, using a provided DataCodingScheme (DCS) and an optional UserDataHeader (UDH). Only 7-bit GSM and UCS-2 based coding schemes are supported. DataCodingScheme (TP-DCS) is set to the provided value. UserDataLength (TP-UDL) is set appropriately. UserDataHeaderIndicator (TP-UDHI) is cleared.- Parameters:
dcs
- the DataCodingScheme (TP-DCS) value to usevalue
- the text value to useheader
- the UserDataHeader (UDH) contents to use, ornull
to provide no header- Throws:
IllegalArgumentException
- if the PDU cannot be decoded, or DataCodingScheme (TP-DCS) is out of range, or the given DataCodingScheme (DCS) cannot encode the given value, or the resulting UserData (TP-UD) exceeds 140 octetsArrayIndexOutOfBoundsException
- if the PDU is truncated
-
checkUserDataConstraints
protected final void checkUserDataConstraints()
Checks that UserData (TP-UD), UserDataLength (TP-UDL), and DataCodingScheme (TP-DCS) are consistent with each other. Called by subclasses before encoding.- Throws:
IllegalStateException
- if something is inconsistent
-
-