ie.omk.smpp.message
Class SMPPPacket

java.lang.Object
  extended by ie.omk.smpp.message.SMPPPacket
Direct Known Subclasses:
SMPPRequest, SMPPResponse

public abstract class SMPPPacket
extends Object

This is the abstract class that all SMPP messages are inherited from.

Version:
1.0
Author:
Oran Kelly

Field Summary
static int ALERT_NOTIFICATION
          Command Id: alert notification.
static int BIND_RECEIVER
          Command Id: Bind Receiver
static int BIND_RECEIVER_RESP
          Command Id: Bind Receiver Response
static int BIND_TRANSCEIVER
          Command Id: Bind transceiver
static int BIND_TRANSCEIVER_RESP
          Command Id: Bind transceiever response.
static int BIND_TRANSMITTER
          Command Id: Bind transmitter
static int BIND_TRANSMITTER_RESP
          Command Id: Bind transmitter response
static int CANCEL_SM
          Command Id: Cancel message
static int CANCEL_SM_RESP
          Command Id: Cancel message response
protected  int commandId
          Command ID.
protected  int commandStatus
          Command status.
static int DATA_SM
          Command Id: Data message.
static int DATA_SM_RESP
          Command Id: Data message response.
protected  int dataCoding
          GSM data coding (see GSM 03.38).
protected  int defaultMsg
          Default message number.
static int DELIVER_SM
          Command Id: Deliver Short message
static int DELIVER_SM_RESP
          Command Id: Deliver message response
protected  SMPPDate deliveryTime
          Scheduled delivery time
protected  Address destination
          Destination address
static int ENQUIRE_LINK
          Command Id: Enquire Link
static int ENQUIRE_LINK_RESP
          Command Id: Enquire link respinse
protected  int errorCode
          Error associated with message
protected  int esmClass
          ESM class.
static int ESME_ROK
          Esme error code: No error
protected  SMPPDate expiryTime
          Scheduled expiry time
protected  SMPPDate finalDate
          Date of reaching final state
static int GENERIC_NACK
          Command Id: Negative Acknowledgement
protected  byte[] message
          The short message data
protected  String messageId
          Smsc allocated message Id
protected  int messageStatus
          Status of message
static int OUTBIND
          Command Id: Outbind.
static int PARAM_RETRIEVE
          Command Id: Parameter retrieve
static int PARAM_RETRIEVE_RESP
          Command Id: Paramater retrieve response
protected  int priority
          Message priority.
protected  int protocolID
          GSM protocol ID.
static int QUERY_LAST_MSGS
          Command Id: Query last messages
static int QUERY_LAST_MSGS_RESP
          Command Id: Query last messages response
static int QUERY_MSG_DETAILS
          Command Id: Query message details
static int QUERY_MSG_DETAILS_RESP
          Command Id: Query message details response
static int QUERY_SM
          Command Id: Query message
static int QUERY_SM_RESP
          Command Id: Query message response
protected  int registered
          Registered delivery.
static int REPLACE_SM
          Command Id: Replace message
static int REPLACE_SM_RESP
          Command Id: replace message response
protected  int replaceIfPresent
          Replace if present.
protected  int sequenceNum
          Packet sequence number.
protected  String serviceType
          Service type for this msg
static int SM_STATE_ACCEPTED
          Message state at Smsc: Accepted
static int SM_STATE_DELETED
          Message state at Smsc: Deleted (final)
static int SM_STATE_DELIVERED
          Message state at Smsc: Delivered (final)
static int SM_STATE_EN_ROUTE
          Message state at Smsc: En route
static int SM_STATE_EXPIRED
          Message state at Smsc: Expired (final)
static int SM_STATE_INVALID
          Message state at Smsc: Invalid message (final)
static int SM_STATE_UNDELIVERABLE
          Message state at Smsc: Undeliverable (final)
static int SMC_CAS_DL
          Esm class: Distribution list and multiple recipient submission
static int SMC_DEFMSG
          Esm class: Predefined message
static int SMC_DLIST
          Esm class: Distribution submission
static int SMC_ESCALATED
          Esm class: Escalated message FFU
static int SMC_LOOPBACK_RECEIPT
          Esm class: Normal delivery , address swapping on
static int SMC_MCE
          Esm class: Memory capacity error
static int SMC_MO
          Esm class: Mobile originated
static int SMC_MOMT
          Esm class: Mobile Originated / Terminated
static int SMC_MT
          Esm class: Mobile Terminated; Normal delivery, no address swapping
static int SMC_MULTI
          Esm class: Multiple recipient submission
static int SMC_RECEIPT
          Esm class: Delivery receipt, no address swapping
static int SMC_RECEIPT_SWAP
          Esm class: Delivery receipt, address swapping on
static int SMC_STORE
          Esm class: Store message, do not send to Kernel
static int SMC_STORE_FORWARD
          Esm class: Store message and send to kernel
static int SMC_SUBMIT_REPLACE
          Esm class: Submit with replace message
protected  Address source
          Source address
static int SUBMIT_MULTI
          Command Id: Submit multiple messages
static int SUBMIT_MULTI_RESP
          Command Id: Submit multi response
static int SUBMIT_SM
          Command Id: Submit message
static int SUBMIT_SM_RESP
          Command Id: Submit message response
protected  TLVTable tlvTable
          Optional parameter table.
static int UNBIND
          Command Id: Unbind
static int UNBIND_RESP
          Command Id: Unbind response
protected  SMPPVersion version
          Version of this packet.
 
Constructor Summary
protected SMPPPacket(int id)
          Create a new SMPPPacket with specified Id.
protected SMPPPacket(int id, int seqNum)
          Create a new SMPPPacket with specified Id and sequence number.
protected SMPPPacket(int id, int seqNum, SMPPVersion version)
           
protected SMPPPacket(int id, SMPPVersion version)
           
 
Method Summary
protected  void encodeBody(OutputStream out)
          Encode the body of the SMPP Packet to the output stream.
abstract  int getBodyLength()
          Get the number of bytes the body of this packet would encode as.
 int getCommandId()
          Get the Command Id of this SMPP packet.
 int getCommandLen()
          Deprecated.  
 int getCommandStatus()
          Get the status of this packet.
 int getDataCoding()
          Get the data coding.
 int getDefaultMsg()
          Get the default message to use.
 int getDefaultMsgId()
          Deprecated.  
 SMPPDate getDeliveryTime()
          Get the current value of the scheduled delivery time for the short message.
 Address getDestination()
          Get the destination address.
 int getErrorCode()
          Get the error code.
 int getEsmClass()
          Get the ESM class of the message.
 SMPPDate getExpiryTime()
          Get the current expiry time of the message.
 SMPPDate getFinalDate()
          Get the final date of the message.
 int getLength()
          Get the number of bytes this packet would be encoded as.
 byte[] getMessage()
          Get the message data.
 MessageEncoding getMessageEncoding()
          Get the current message encoding object.
 String getMessageId()
          Get the message id.
 int getMessageLen()
          Get the number of octets in the message payload.
 int getMessageStatus()
          Get the message status.
 String getMessageText()
          Get the text of the message.
 String getMessageText(AlphabetEncoding enc)
          Get the text of the message.
 Object getOptionalParameter(Tag tag)
          Get an optional parameter.
 int getPriority()
          Get the priority flag for the message.
 int getProtocolId()
          Deprecated. getProtocolID
 int getProtocolID()
          Get the GSM protocol ID of the message.
 int getRegistered()
          Get the 'registered' flag for the message.
 int getReplaceIfPresent()
          Get the replace if present flag for the message.
 int getSequenceNum()
          Get the sequence number of this packet.
 String getServiceType()
          Get the service type.
 Address getSource()
          Get the source address.
 TLVTable getTLVTable()
          Get the optional parameter (TLV) table.
 SMPPVersion getVersion()
          Get the version handler in use for this packet.
 boolean isPriority()
          Deprecated.  
 boolean isRegistered()
          Deprecated.  
 boolean isReplaceIfPresent()
          Deprecated.  
 boolean isRequest()
          Is this command a request packet.
 boolean isSet(Tag tag)
          Check if a particular optional parameter is set.
protected abstract  void readBodyFrom(byte[] b, int offset)
          Read this packet's mandatory parameters from a byte array.
 void readFrom(byte[] b, int offset)
          Decode an SMPP packet from a byte array.
 void setAlphabet(AlphabetEncoding enc)
          Set the alphabet encoding and dcs value for this message.
 void setAlphabet(AlphabetEncoding enc, int dcs)
          Set the alphabet encoding for this message with an alternate dcs.
 void setDataCoding(int dc)
          Set the GSM data coding of the message.
 void setDefaultMsg(int id)
          Set the default message id in the message flags.
 void setDeliveryTime(Date d)
          Set the scheduled delivery time for the short message.
 void setDeliveryTime(SMPPDate d)
          Set the scheduled delivery time for the short message.
 void setDestination(Address s)
          Set the destination address.
 void setErrorCode(int code)
          Set the error code.
 void setEsmClass(int c)
          Set the esm class of the message.
 void setExpiryTime(Date d)
          Set the expiry time of the message.
 void setExpiryTime(SMPPDate d)
          Set the expiry time of the message.
 void setFinalDate(Date d)
          Set the final date of the message.
 void setFinalDate(SMPPDate d)
          Set the final date of the message.
 void setMessage(byte[] message)
          Set the message data.
 void setMessage(byte[] message, int start, int len, MessageEncoding encoding)
          Set the message data.
 void setMessage(byte[] message, MessageEncoding encoding)
          Set the message data.
 void setMessageEncoding(MessageEncoding enc)
          Set the message encoding handler class for this packet.
 void setMessageId(String id)
          Set the message Id.
 void setMessageStatus(int st)
          Set the message status.
 void setMessageText(String text)
          Set the text of the message.
 void setMessageText(String text, AlphabetEncoding alphabet)
          Set the text of the message.
 Object setOptionalParameter(Tag tag, Object value)
          Set an optional parameter.
 void setPriority(int p)
          Set the 'priority' flag.
 void setProtocolId(int id)
          Deprecated. ie.omk.smpp.message.SMPPPacket#setProtocolID
 void setProtocolID(int id)
          Set the GSM protocol ID.
 void setRegistered(boolean b)
          Deprecated.  
 void setRegistered(int r)
          Set 'registered delivery' flag.
 void setReplaceIfPresent(boolean b)
          Deprecated.  
 void setReplaceIfPresent(int rip)
          Set 'replace if present' flag.
 void setSequenceNum(int sequenceNum)
          Set the sequence number of this packet.
 void setServiceType(String type)
          Set the service type.
 void setSource(Address s)
          Set the source address..
 TLVTable setTLVTable(TLVTable table)
          Set the optional parameter (TLV) table.
 void setVersion(SMPPVersion version)
          Set the version handler for this packet.
 String toString()
          Return a String representation of this packet.
 void writeTo(OutputStream out)
          Write the byte representation of this SMPP packet to an OutputStream
 void writeTo(OutputStream out, boolean withOptional)
          Write the byte representation of this SMPP packet to an OutputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GENERIC_NACK

public static final int GENERIC_NACK
Command Id: Negative Acknowledgement

See Also:
Constant Field Values

BIND_RECEIVER

public static final int BIND_RECEIVER
Command Id: Bind Receiver

See Also:
Constant Field Values

BIND_RECEIVER_RESP

public static final int BIND_RECEIVER_RESP
Command Id: Bind Receiver Response

See Also:
Constant Field Values

BIND_TRANSMITTER

public static final int BIND_TRANSMITTER
Command Id: Bind transmitter

See Also:
Constant Field Values

BIND_TRANSMITTER_RESP

public static final int BIND_TRANSMITTER_RESP
Command Id: Bind transmitter response

See Also:
Constant Field Values

QUERY_SM

public static final int QUERY_SM
Command Id: Query message

See Also:
Constant Field Values

QUERY_SM_RESP

public static final int QUERY_SM_RESP
Command Id: Query message response

See Also:
Constant Field Values

SUBMIT_SM

public static final int SUBMIT_SM
Command Id: Submit message

See Also:
Constant Field Values

SUBMIT_SM_RESP

public static final int SUBMIT_SM_RESP
Command Id: Submit message response

See Also:
Constant Field Values

DELIVER_SM

public static final int DELIVER_SM
Command Id: Deliver Short message

See Also:
Constant Field Values

DELIVER_SM_RESP

public static final int DELIVER_SM_RESP
Command Id: Deliver message response

See Also:
Constant Field Values

UNBIND

public static final int UNBIND
Command Id: Unbind

See Also:
Constant Field Values

UNBIND_RESP

public static final int UNBIND_RESP
Command Id: Unbind response

See Also:
Constant Field Values

REPLACE_SM

public static final int REPLACE_SM
Command Id: Replace message

See Also:
Constant Field Values

REPLACE_SM_RESP

public static final int REPLACE_SM_RESP
Command Id: replace message response

See Also:
Constant Field Values

CANCEL_SM

public static final int CANCEL_SM
Command Id: Cancel message

See Also:
Constant Field Values

CANCEL_SM_RESP

public static final int CANCEL_SM_RESP
Command Id: Cancel message response

See Also:
Constant Field Values

BIND_TRANSCEIVER

public static final int BIND_TRANSCEIVER
Command Id: Bind transceiver

See Also:
Constant Field Values

BIND_TRANSCEIVER_RESP

public static final int BIND_TRANSCEIVER_RESP
Command Id: Bind transceiever response.

See Also:
Constant Field Values

OUTBIND

public static final int OUTBIND
Command Id: Outbind.

See Also:
Constant Field Values

ENQUIRE_LINK

public static final int ENQUIRE_LINK
Command Id: Enquire Link

See Also:
Constant Field Values

ENQUIRE_LINK_RESP

public static final int ENQUIRE_LINK_RESP
Command Id: Enquire link respinse

See Also:
Constant Field Values

SUBMIT_MULTI

public static final int SUBMIT_MULTI
Command Id: Submit multiple messages

See Also:
Constant Field Values

SUBMIT_MULTI_RESP

public static final int SUBMIT_MULTI_RESP
Command Id: Submit multi response

See Also:
Constant Field Values

PARAM_RETRIEVE

public static final int PARAM_RETRIEVE
Command Id: Parameter retrieve

See Also:
Constant Field Values

PARAM_RETRIEVE_RESP

public static final int PARAM_RETRIEVE_RESP
Command Id: Paramater retrieve response

See Also:
Constant Field Values

QUERY_LAST_MSGS

public static final int QUERY_LAST_MSGS
Command Id: Query last messages

See Also:
Constant Field Values

QUERY_LAST_MSGS_RESP

public static final int QUERY_LAST_MSGS_RESP
Command Id: Query last messages response

See Also:
Constant Field Values

QUERY_MSG_DETAILS

public static final int QUERY_MSG_DETAILS
Command Id: Query message details

See Also:
Constant Field Values

QUERY_MSG_DETAILS_RESP

public static final int QUERY_MSG_DETAILS_RESP
Command Id: Query message details response

See Also:
Constant Field Values

ALERT_NOTIFICATION

public static final int ALERT_NOTIFICATION
Command Id: alert notification.

See Also:
Constant Field Values

DATA_SM

public static final int DATA_SM
Command Id: Data message.

See Also:
Constant Field Values

DATA_SM_RESP

public static final int DATA_SM_RESP
Command Id: Data message response.

See Also:
Constant Field Values

SM_STATE_EN_ROUTE

public static final int SM_STATE_EN_ROUTE
Message state at Smsc: En route

See Also:
Constant Field Values

SM_STATE_DELIVERED

public static final int SM_STATE_DELIVERED
Message state at Smsc: Delivered (final)

See Also:
Constant Field Values

SM_STATE_EXPIRED

public static final int SM_STATE_EXPIRED
Message state at Smsc: Expired (final)

See Also:
Constant Field Values

SM_STATE_DELETED

public static final int SM_STATE_DELETED
Message state at Smsc: Deleted (final)

See Also:
Constant Field Values

SM_STATE_UNDELIVERABLE

public static final int SM_STATE_UNDELIVERABLE
Message state at Smsc: Undeliverable (final)

See Also:
Constant Field Values

SM_STATE_ACCEPTED

public static final int SM_STATE_ACCEPTED
Message state at Smsc: Accepted

See Also:
Constant Field Values

SM_STATE_INVALID

public static final int SM_STATE_INVALID
Message state at Smsc: Invalid message (final)

See Also:
Constant Field Values

SMC_MT

public static final int SMC_MT
Esm class: Mobile Terminated; Normal delivery, no address swapping

See Also:
Constant Field Values

SMC_MO

public static final int SMC_MO
Esm class: Mobile originated

See Also:
Constant Field Values

SMC_MOMT

public static final int SMC_MOMT
Esm class: Mobile Originated / Terminated

See Also:
Constant Field Values

SMC_RECEIPT

public static final int SMC_RECEIPT
Esm class: Delivery receipt, no address swapping

See Also:
Constant Field Values

SMC_DEFMSG

public static final int SMC_DEFMSG
Esm class: Predefined message

See Also:
Constant Field Values

SMC_LOOPBACK_RECEIPT

public static final int SMC_LOOPBACK_RECEIPT
Esm class: Normal delivery , address swapping on

See Also:
Constant Field Values

SMC_RECEIPT_SWAP

public static final int SMC_RECEIPT_SWAP
Esm class: Delivery receipt, address swapping on

See Also:
Constant Field Values

SMC_STORE

public static final int SMC_STORE
Esm class: Store message, do not send to Kernel

See Also:
Constant Field Values

SMC_STORE_FORWARD

public static final int SMC_STORE_FORWARD
Esm class: Store message and send to kernel

See Also:
Constant Field Values

SMC_DLIST

public static final int SMC_DLIST
Esm class: Distribution submission

See Also:
Constant Field Values

SMC_MULTI

public static final int SMC_MULTI
Esm class: Multiple recipient submission

See Also:
Constant Field Values

SMC_CAS_DL

public static final int SMC_CAS_DL
Esm class: Distribution list and multiple recipient submission

See Also:
Constant Field Values

SMC_ESCALATED

public static final int SMC_ESCALATED
Esm class: Escalated message FFU

See Also:
Constant Field Values

SMC_SUBMIT_REPLACE

public static final int SMC_SUBMIT_REPLACE
Esm class: Submit with replace message

See Also:
Constant Field Values

SMC_MCE

public static final int SMC_MCE
Esm class: Memory capacity error

See Also:
Constant Field Values

ESME_ROK

public static final int ESME_ROK
Esme error code: No error

See Also:
Constant Field Values

version

protected SMPPVersion version
Version of this packet. This object controls valid settings for field values.


commandId

protected int commandId
Command ID.


commandStatus

protected int commandStatus
Command status.


sequenceNum

protected int sequenceNum
Packet sequence number.


source

protected Address source
Source address


destination

protected Address destination
Destination address


message

protected byte[] message
The short message data


serviceType

protected String serviceType
Service type for this msg


deliveryTime

protected SMPPDate deliveryTime
Scheduled delivery time


expiryTime

protected SMPPDate expiryTime
Scheduled expiry time


finalDate

protected SMPPDate finalDate
Date of reaching final state


messageId

protected String messageId
Smsc allocated message Id


messageStatus

protected int messageStatus
Status of message


errorCode

protected int errorCode
Error associated with message


priority

protected int priority
Message priority.


registered

protected int registered
Registered delivery.


replaceIfPresent

protected int replaceIfPresent
Replace if present.


esmClass

protected int esmClass
ESM class.


protocolID

protected int protocolID
GSM protocol ID.


dataCoding

protected int dataCoding
GSM data coding (see GSM 03.38).


defaultMsg

protected int defaultMsg
Default message number.


tlvTable

protected TLVTable tlvTable
Optional parameter table.

Constructor Detail

SMPPPacket

protected SMPPPacket(int id)
Create a new SMPPPacket with specified Id.

Parameters:
id - Command Id value

SMPPPacket

protected SMPPPacket(int id,
                     int seqNum)
Create a new SMPPPacket with specified Id and sequence number.

Parameters:
id - Command Id value
seqNum - Command Sequence number

SMPPPacket

protected SMPPPacket(int id,
                     SMPPVersion version)

SMPPPacket

protected SMPPPacket(int id,
                     int seqNum,
                     SMPPVersion version)
Method Detail

getVersion

public SMPPVersion getVersion()
Get the version handler in use for this packet.

See Also:
SMPPVersion

isRequest

public boolean isRequest()
Is this command a request packet.

Returns:
true if this packet is an SMPP request, false if it is a response.

setVersion

public void setVersion(SMPPVersion version)
Set the version handler for this packet. If null is passed in as the version, the default version will be used.

Parameters:
version - the version handler to use.
See Also:
SMPPVersion.getDefaultVersion()

getCommandLen

public final int getCommandLen()
Deprecated. 

Return the number of bytes this packet would be encoded as to an OutputStream.

Returns:
The size in bytes of the packet

getLength

public final int getLength()
Get the number of bytes this packet would be encoded as. This returns the sum of the size of the header (always 16), the packet's body and all optional parameters.

Returns:
the number of bytes this packet would encode as.

getBodyLength

public abstract int getBodyLength()
Get the number of bytes the body of this packet would encode as. This method should only return the number of bytes the fields in the mandatory parameters section of the packet would encode as. The total size of the packet then is 16 (header length) + getBodyLength() + SUM(foreach optionalParameter: getLength()).


getCommandId

public int getCommandId()
Get the Command Id of this SMPP packet.

Returns:
The Command Id of this packet

getCommandStatus

public int getCommandStatus()
Get the status of this packet.

Returns:
The error status of this packet (only relevent to Response packets)

getSequenceNum

public int getSequenceNum()
Get the sequence number of this packet.

Returns:
The sequence number of this SMPP packet

setSequenceNum

public void setSequenceNum(int sequenceNum)
Set the sequence number of this packet.


setSource

public void setSource(Address s)
               throws InvalidParameterValueException
Set the source address..

Throws:
InvalidParameterValueException

getSource

public Address getSource()
Get the source address.

Returns:
The source address or null if it is not set.

setDestination

public void setDestination(Address s)
Set the destination address.


getDestination

public Address getDestination()
Get the destination address.

Returns:
The destination address or null if it is not set.

setPriority

public void setPriority(int p)
                 throws InvalidParameterValueException
Set the 'priority' flag.

Throws:
InvalidParameterValueException - If p is not a valid value for the priority flag.

setRegistered

public void setRegistered(boolean b)
Deprecated. 

Set 'registered delivery' flag.


setRegistered

public void setRegistered(int r)
                   throws InvalidParameterValueException
Set 'registered delivery' flag.

Throws:
InvalidParameterValueException - If r is not a valid value for the registered delivery flag.

setReplaceIfPresent

public void setReplaceIfPresent(boolean b)
Deprecated. 

Set 'replace if present'.


setReplaceIfPresent

public void setReplaceIfPresent(int rip)
                         throws InvalidParameterValueException
Set 'replace if present' flag.

Throws:
InvalidParameterValueException - If rip is not a valid value for the replace if present flag.

setEsmClass

public void setEsmClass(int c)
                 throws InvalidParameterValueException
Set the esm class of the message.

Throws:
InvalidParameterValueException - If the value passed is not a valid ESM class.
See Also:
GSMConstants

setProtocolId

public void setProtocolId(int id)
Deprecated. ie.omk.smpp.message.SMPPPacket#setProtocolID

Set the protocol Id in the message flags.

See Also:
GSMConstants

setProtocolID

public void setProtocolID(int id)
                   throws InvalidParameterValueException
Set the GSM protocol ID.

Throws:
InvalidParameterValueException - If the protocol ID supplied is invalid.
See Also:
GSMConstants

setDataCoding

public void setDataCoding(int dc)
                   throws InvalidParameterValueException
Set the GSM data coding of the message. This will also set the internal encoding type of the message to match the DCS value. It will not set the encoding type if the DCS is 0 as this code is reserved to represent the default SMSC encoding type, which is dependent on the SMSC implementation.

Throws:
InvalidParameterValueException - If the data coding supplied is invalid.
See Also:
GSMConstants

setDefaultMsg

public void setDefaultMsg(int id)
                   throws InvalidParameterValueException
Set the default message id in the message flags.

Throws:
InvalidParameterValueException

isRegistered

public boolean isRegistered()
Deprecated. 

Check is the message registered.


getRegistered

public int getRegistered()
Get the 'registered' flag for the message.


isPriority

public boolean isPriority()
Deprecated. 

Check is the message submitted as priority.


getPriority

public int getPriority()
Get the priority flag for the message.


isReplaceIfPresent

public boolean isReplaceIfPresent()
Deprecated. 

Check if the message should be replaced if it is already present.


getReplaceIfPresent

public int getReplaceIfPresent()
Get the replace if present flag for the message.


getEsmClass

public int getEsmClass()
Get the ESM class of the message.


getProtocolId

public int getProtocolId()
Deprecated. getProtocolID

Get the GSM protocol Id of the message.


getProtocolID

public int getProtocolID()
Get the GSM protocol ID of the message.


getDataCoding

public int getDataCoding()
Get the data coding.


getDefaultMsgId

public int getDefaultMsgId()
Deprecated. 

Get the default message to use.


getDefaultMsg

public int getDefaultMsg()
Get the default message to use.


setMessageText

public void setMessageText(String text)
                    throws InvalidParameterValueException
Set the text of the message. This method sets the message text encoded using the current alphabet for this message. The default alphabet to use is obtained using EncodingFactory.getDefaultAlphabet(). If, at some point, the encoding for the message has been altered to be one other than a sub-class of AlphabetEncoding then calls to this method will reset the encoding back to the default. The maximum length of the message is determined by the SMPP version in use. Calling this method affects the data_coding value.

Parameters:
text - The short message text.
Throws:
InvalidParameterValueException - If the message text is too long.
See Also:
EncodingFactory, DefaultAlphabetEncoding

setMessageText

public void setMessageText(String text,
                           AlphabetEncoding alphabet)
                    throws InvalidParameterValueException
Set the text of the message. This method sets the message text encoded using the SMS alphabet alphabet. The AlphabetEncoding.getDataCoding value will be used to set the data_coding field.

Parameters:
text - The short message text.
alphabet - The SMS alphabet to use.
Throws:
InvalidParameterValueException - If the message text is too long.
See Also:
AlphabetEncoding, MessageEncoding.getDataCoding(), DefaultAlphabetEncoding

setMessage

public void setMessage(byte[] message)
                throws InvalidParameterValueException
Set the message data. The data will be copied from the supplied byte array into an internal one.

Parameters:
message - The byte array to take message data from.
Throws:
InvalidParameterValueException - If the message data is too long.

setMessage

public void setMessage(byte[] message,
                       MessageEncoding encoding)
                throws InvalidParameterValueException
Set the message data. The data will be copied from the supplied byte array into an internal one.

Parameters:
message - The byte array to take message data from.
Throws:
InvalidParameterValueException - If the message data is too long.

setMessage

public void setMessage(byte[] message,
                       int start,
                       int len,
                       MessageEncoding encoding)
                throws InvalidParameterValueException
Set the message data. The data will be copied from the supplied byte array into an internal one. If encoding is not null, the data_coding field will be set using the value returned by MessageEncoding.getDataCoding.

Parameters:
message - The byte array to take message data from.
start - The index the message data begins at.
len - The length of the message data.
encoding - The encoding object representing the type of data in the message. If null, uses ie.omk.smpp.util.BinaryEncoding.
Throws:
InvalidParameterValueException - If the message data is too long.
ArrayIndexOutOfBoundsException - if start or len is less than zero or if the byte array length is less than start + len.

getMessage

public byte[] getMessage()
Get the message data. This method returns a copy of the binary message data.

Returns:
A byte array copy of the message data. May be null.

getMessageText

public String getMessageText()
Get the text of the message. The message will be decoded according to the current encoding of the message (that is, according to it's DCS value). If the current encoding is not some form of text encoding (that is, the DCS indicates a binary encoding), null will be returned.

Returns:
The text of the message, or null if the message is not text.
See Also:
getMessageText(ie.omk.smpp.util.AlphabetEncoding), setMessageText(java.lang.String, ie.omk.smpp.util.AlphabetEncoding)

getMessageText

public String getMessageText(AlphabetEncoding enc)
Get the text of the message. Never returns null.

Parameters:
enc - The alphabet to use to decode the message bytes.
Returns:
The text of the message. Never returns null.
See Also:
AlphabetEncoding

getMessageLen

public int getMessageLen()
Get the number of octets in the message payload.

Returns:
The number of octets (bytes) in the message payload.

setServiceType

public void setServiceType(String type)
                    throws InvalidParameterValueException
Set the service type.

Parameters:
type - The service type.
Throws:
InvalidParameterValueException - if the service type is too long.

getServiceType

public String getServiceType()
Get the service type.


setDeliveryTime

public void setDeliveryTime(SMPPDate d)
Set the scheduled delivery time for the short message.

Parameters:
d - The date and time the message should be delivered.

setDeliveryTime

public void setDeliveryTime(Date d)
Set the scheduled delivery time for the short message.

Parameters:
d - The date and time the message should be delivered.

getDeliveryTime

public SMPPDate getDeliveryTime()
Get the current value of the scheduled delivery time for the short message.


setExpiryTime

public void setExpiryTime(SMPPDate d)
Set the expiry time of the message. If the message is not delivered by time 'd', it will be cancelled and never delivered to it's destination.

Parameters:
d - the date and time the message should expire.

setExpiryTime

public void setExpiryTime(Date d)
Set the expiry time of the message. If the message is not delivered by time 'd', it will be cancelled and never delivered to it's destination.


getExpiryTime

public SMPPDate getExpiryTime()
Get the current expiry time of the message.


setFinalDate

public void setFinalDate(SMPPDate d)
Set the final date of the message. The final date is the date and time that the message reached it's final destination.

Parameters:
d - the date the message was delivered.

setFinalDate

public void setFinalDate(Date d)
Set the final date of the message. The final date is the date and time that the message reached it's final destination.

Parameters:
d - the date the message was delivered.

getFinalDate

public SMPPDate getFinalDate()
Get the final date of the message.


setMessageId

public void setMessageId(String id)
                  throws InvalidParameterValueException
Set the message Id. Each submitted short message is assigned an Id by the SMSC which is used to uniquely identify it. SMPP v3.3 message Ids are hexadecimal numbers up to 9 characters long. This gives them a range of 0x0 - 0xffffffff.

SMPP v3.4 Ids, on the other hand, are opaque objects represented as C-Strings assigned by the SMSC and can be up to 64 characters (plus 1 nul-terminator).

Parameters:
id - The message's id.
Throws:
InvalidParameterValueException - If the message ID is invalid.

getMessageId

public String getMessageId()
Get the message id.


setMessageStatus

public void setMessageStatus(int st)
                      throws InvalidParameterValueException
Set the message status. The message status (or message state) describes the current state of the message at the SMSC. There are a number of states defined in the SMPP specification.

Parameters:
st - The message status.
Throws:
InvalidParameterValueException
See Also:
PacketStatus

getMessageStatus

public int getMessageStatus()
Get the message status.


setErrorCode

public void setErrorCode(int code)
                  throws InvalidParameterValueException
Set the error code.

Parameters:
code - The error code.
Throws:
InvalidParameterValueException

getErrorCode

public int getErrorCode()
Get the error code.


getTLVTable

public TLVTable getTLVTable()
Get the optional parameter (TLV) table.

See Also:
TLVTable

setTLVTable

public TLVTable setTLVTable(TLVTable table)
Set the optional parameter (TLV) table. This method discards the entire optional paramter table and replaces it with table. The discarded table is returned. If null is passed in, a new, empty TLVTable object will be created.

Returns:
the old tlvTable.
See Also:
TLVTable

setOptionalParameter

public Object setOptionalParameter(Tag tag,
                                   Object value)
Set an optional parameter. This is a convenience method and merely calls TLVTable.set(ie.omk.smpp.message.tlv.Tag, java.lang.Object)on this message's optional parameter table.

Parameters:
tag - the tag of the parameter to set.
value - the value object to set.
Returns:
the previous value of the parameter, or null if it was unset.
Throws:
BadValueTypeException - if the type of value is incorrect for the tag.

getOptionalParameter

public Object getOptionalParameter(Tag tag)
Get an optional parameter. This is a convenience method and merely calls TLVTable.get(ie.omk.smpp.message.tlv.Tag)on this message's optional parameter table.

Parameters:
tag - the tag of the parameter value to get.

isSet

public boolean isSet(Tag tag)
Check if a particular optional parameter is set. This is a convenience method and merely calls TLVTable.isSet(ie.omk.smpp.message.tlv.Tag)on this message's optional parameter table.

Parameters:
tag - the tag of the parameter to check.
Returns:
true if the parameter is set, false if it is not.

setAlphabet

public void setAlphabet(AlphabetEncoding enc)
Set the alphabet encoding and dcs value for this message. The data_coding (dcs) value of this message will be set to the return value of MessageEncoding.getDataCoding().

Parameters:
enc - The alphabet to use. If null, use DefaultAlphabetEncoding.
See Also:
AlphabetEncoding, DefaultAlphabetEncoding

setAlphabet

public void setAlphabet(AlphabetEncoding enc,
                        int dcs)
Set the alphabet encoding for this message with an alternate dcs. enc will be used to encode the message but dcs will be used as the data coding value. This method is useful when the SMSC uses an alternate value to those built-in to the smppapi.

Parameters:
enc - The alphabet encoding to use to encode messages. If null, the encoding returned by EncodingFactory.getDefaultAlphabet() will be used.
dcs - The data coding value to use.

setMessageEncoding

public void setMessageEncoding(MessageEncoding enc)
Set the message encoding handler class for this packet.


getMessageEncoding

public MessageEncoding getMessageEncoding()
Get the current message encoding object.


toString

public String toString()
Return a String representation of this packet. This method does not return any value which is useful programatically...it returns a description of the packet's header as follows:
"SMPP(l:[len], c:[commandId], s:[status], n:[sequence])"

Overrides:
toString in class Object

encodeBody

protected void encodeBody(OutputStream out)
                   throws IOException
Encode the body of the SMPP Packet to the output stream. Sub classes should override this method to output their packet-specific fields. This method is called from SMPPPacket.writeTo(java.io.OutputStream) to encode the message.

Parameters:
out - The output stream to write to.
Throws:
IOException - if there's an error writing to the output stream.

writeTo

public final void writeTo(OutputStream out)
                   throws IOException
Write the byte representation of this SMPP packet to an OutputStream

Parameters:
out - The OutputStream to use
Throws:
IOException - if there's an error writing to the output stream.

writeTo

public final void writeTo(OutputStream out,
                          boolean withOptional)
                   throws IOException
Write the byte representation of this SMPP packet to an OutputStream

Parameters:
out - The OutputStream to use
withOptional - true to send optional parameters over the link, false to only write the mandatory parameters.
Throws:
IOException - if there's an error writing to the output stream.

readFrom

public void readFrom(byte[] b,
                     int offset)
              throws SMPPProtocolException
Decode an SMPP packet from a byte array.

Parameters:
b - the byte array to read the SMPP packet's fields from.
offset - the offset into b to begin reading the packet fields from.
Throws:
SMPPProtocolException - if there is an error parsing the packet fields.

readBodyFrom

protected abstract void readBodyFrom(byte[] b,
                                     int offset)
                              throws SMPPProtocolException
Read this packet's mandatory parameters from a byte array.

Parameters:
b - the byte array to read the mandatory parameters from.
offset - the offset into b that the mandatory parameter's begin at.
Throws:
SMPPProtocolException - if there is an error parsing the packet fields.


Copyright © 2011 smppapi at Sourceforge. All Rights Reserved.