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 classSMSTPDUWithData.UserDataHeaderIndicatorEnumeration 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 SMSDataCodingSchemeDataCodingScheme_valueValue of field DataCodingScheme.protected booleanOnlyHeader_presentWhether field OnlyHeader is present.protected ASN1NullOnlyHeader_valueValue of field OnlyHeader.protected SMSProtocolIdProtocolId_valueValue of field ProtocolId.protected byte[]UserData_valueValue of field UserData.protected SMSTPDUWithData.UserDataHeaderIndicatorUserDataHeaderIndicator_valueValue of field UserDataHeaderIndicator.protected booleanUserDataLength_presentWhether field UserDataLength is present.protected intUserDataLength_valueValue 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 voidcheckFieldsSet()Checks that all mandatory fields are present.protected voidcheckUserDataConstraints()Checks that UserData (TP-UD), UserDataLength (TP-UDL), and DataCodingScheme (TP-DCS) are consistent with each other.SMSDataCodingSchemegetDataCodingScheme()Gets the value of the coding scheme within the user data.SMSProtocolIdgetProtocolId()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.UserDataHeaderIndicatorgetUserDataHeaderIndicator()Gets the value of whether user data contains a header.intgetUserDataLength()Gets the value of the length of the user data.StringgetUserDataString()Gets the text portion of UserData (TP-UD) in String form.booleanhasDataCodingScheme()Tests whether the field DataCodingScheme has a value.booleanhasOnlyHeader()Tests whether the field OnlyHeader has a value.booleanhasProtocolId()Tests whether the field ProtocolId has a value.booleanhasUserData()Tests whether the field UserData has a value.booleanhasUserDataHeaderIndicator()Tests whether the field UserDataHeaderIndicator has a value.booleanhasUserDataLength()Tests whether the field UserDataLength has a value.SMSTPDUWithDatasetDataCodingScheme(SMSDataCodingScheme value)Sets the value of the coding scheme within the user data.SMSTPDUWithDatasetOnlyHeaderPresent(boolean flag)Sets the presence or absence of the field OnlyHeader.SMSTPDUWithDatasetProtocolId(SMSProtocolId value)Sets the value of identifies the above layer protocol.voidsetReadOnly()Sets this and all its fields to be immutable.SMSTPDUWithDatasetUserData(byte[] value)Sets the value of the user data.SMSTPDUWithDatasetUserDataHeaderIndicator(SMSTPDUWithData.UserDataHeaderIndicator value)Sets the value of whether user data contains a header.SMSTPDUWithDatasetUserDataLength(int value)Sets the value of the length of the user data.SMSTPDUWithDatasetUserDataLengthPresent(boolean flag)Sets the presence or absence of the field UserDataLength.voidsetUserDataString(SMSDataCodingScheme dcs, String value)Sets UserData (TP-UD) to the given text value, using a provided DataCodingScheme (DCS) and no UserDataHeader (UDH).voidsetUserDataString(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).voidsetUserDataString(String value)Sets UserData (TP-UD) to the given text value, with no UserDataHeader (UDH).voidsetUserDataString(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 indexstartand islenbytes 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 DecodeExceptionTests 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 DecodeExceptionTests 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 DecodeExceptionTests 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 DecodeExceptionTests 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 DecodeExceptionTests 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 DecodeExceptionTests 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 EncodeExceptionChecks that all mandatory fields are present. Should be called immediately before all calls to encode().- Overrides:
checkFieldsSetin 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 DecodeExceptionGets 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 DecodeExceptionGets 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:
setReadOnlyin interfaceDataObject- Overrides:
setReadOnlyin classAbstractDataObject
-
getUserDataHeader
public final byte[] getUserDataHeader()
Gets the UserDataHeader portion of the UserData (TP-UD), if present.- Returns:
- the header as a bytearray, or
nullif 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
nullif 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, ornullto 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, ornullto provide no text.header- the UserDataHeader (UDH) contents to use, ornullto 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, ornullto 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
-
-