public abstract class SMSTPDUWithData extends SMSTPDU
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.
Modifier and Type | Class and Description |
---|---|
static class |
SMSTPDUWithData.UserDataHeaderIndicator
Enumeration of User Data Header Indicator constants.
|
SMSTPDU.Type
Modifier and Type | Field and 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.
|
isDecoded
encoded
FIELD_ABSENT, FIELD_UNINITIALISED
Constructor and 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.
|
Modifier and Type | Method and 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).
|
decodeRPAck, decodeRPAck, decodeRPError, decodeRPError, decodeRPMOData, decodeRPMOData, decodeRPMTData, decodeRPMTData, encodeRPAck, encodeRPError, encodeRPMOData, encodeRPMTData, getEncodedForm, getType
checkDecode, checkModifyAndDecode, decode, encode
equals, getFieldsMap, hashCode, toString
checkModify, clone, isReadOnly
protected ASN1Null OnlyHeader_value
protected boolean OnlyHeader_present
protected SMSTPDUWithData.UserDataHeaderIndicator UserDataHeaderIndicator_value
protected SMSProtocolId ProtocolId_value
protected SMSDataCodingScheme DataCodingScheme_value
protected int UserDataLength_value
protected boolean UserDataLength_present
protected byte[] UserData_value
public SMSTPDUWithData()
public SMSTPDUWithData(byte[] data)
data
- network-encoded dataNullPointerException
- if data is nullpublic SMSTPDUWithData(byte[] data, int start, int len)
start
and is len
bytes long.
The data is not decoded and might not be decodable.data
- network-encoded datastart
- starting offset of network-encoded data in byte arraylen
- default length if not predictableNullPointerException
- if data is nullIllegalArgumentException
- if len is negativepublic boolean hasOnlyHeader() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic SMSTPDUWithData setOnlyHeaderPresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic boolean hasUserDataHeaderIndicator() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean hasProtocolId() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean hasDataCodingScheme() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic boolean hasUserDataLength() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic SMSTPDUWithData setUserDataLengthPresent(boolean flag) throws IllegalStateException
flag
- whether the field should be marked as presentIllegalStateException
- if this instance has been marked as read-onlypublic boolean hasUserData() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic void checkFieldsSet() throws EncodeException
checkFieldsSet
in class SMSTPDU
EncodeException
- if any mandatory field is not presentpublic SMSTPDUWithData.UserDataHeaderIndicator getUserDataHeaderIndicator() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic SMSProtocolId getProtocolId() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic SMSDataCodingScheme getDataCodingScheme() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic int getUserDataLength() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic byte[] getUserData() throws DecodeException
DecodeException
- if encoded state cannot be decodedpublic SMSTPDUWithData setUserDataHeaderIndicator(SMSTPDUWithData.UserDataHeaderIndicator value) throws IllegalStateException
value
- UserDataHeaderIndicator representation of whether user data contains a headerIllegalStateException
public SMSTPDUWithData setProtocolId(SMSProtocolId value) throws IllegalStateException
value
- SMSProtocolId representation of identifies the above layer protocolIllegalStateException
public SMSTPDUWithData setDataCodingScheme(SMSDataCodingScheme value) throws IllegalStateException
value
- SMSDataCodingScheme representation of the coding scheme within the user dataIllegalStateException
public SMSTPDUWithData setUserDataLength(int value) throws IllegalStateException
value
- int representation of the length of the user dataIllegalStateException
public SMSTPDUWithData setUserData(byte[] value) throws IllegalStateException
value
- byte[] representation of the user dataIllegalStateException
public void setReadOnly()
setReadOnly
in interface DataObject
setReadOnly
in class AbstractDataObject
public final byte[] getUserDataHeader()
null
if UserData (TP-UD) is not present or it does not contain a UserDataHeader (UDH)public final String getUserDataString()
null
if UserData (TP-UD) is not presentIllegalArgumentException
- if the PDU cannot be decoded or the Data Coding Scheme is not supportedArrayIndexOutOfBoundsException
- if the PDU is truncatedpublic final void setUserDataString(String value)
value
- the text value to use, or null
to clear UserData (TP-UD)IllegalArgumentException
- if the PDU cannot be decoded, or the resulting UserData (TP-UD) exceeds 140 octets.ArrayIndexOutOfBoundsException
- if the PDU is truncatedpublic final void setUserDataString(String value, byte[] header)
value
- the text value to use, or null
to provide no text.header
- the UserDataHeader (UDH) contents to use, or null
to provide no header.IllegalArgumentException
- if the PDU cannot be decoded, or the resulting UserData (TP-UD) exceeds 140 octets.ArrayIndexOutOfBoundsException
- if the PDU is truncatedpublic final void setUserDataString(SMSDataCodingScheme dcs, String value)
dcs
- the DataCodingScheme (TP-DCS) value to usevalue
- the text value to useIllegalArgumentException
- 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 truncatedpublic final void setUserDataString(SMSDataCodingScheme dcs, String value, byte[] header)
dcs
- the DataCodingScheme (TP-DCS) value to usevalue
- the text value to useheader
- the UserDataHeader (UDH) contents to use, or null
to provide no headerIllegalArgumentException
- 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 truncatedprotected final void checkUserDataConstraints()
IllegalStateException
- if something is inconsistent