org.jsmpp
Class DefaultPDUSender

java.lang.Object
  extended by org.jsmpp.DefaultPDUSender
All Implemented Interfaces:
PDUSender

public class DefaultPDUSender
extends java.lang.Object
implements PDUSender

The SMPP PDU reader class.

Since:
1.0
Version:
1.1
Author:
uudashr

Constructor Summary
DefaultPDUSender()
          Default constructor.
DefaultPDUSender(PDUComposer pduComposer)
          Construct with specified PDU composer.
 
Method Summary
 byte[] sendAlertNotification(java.io.OutputStream os, int sequenceNumber, byte sourceAddrTon, byte sourceAddrNpi, java.lang.String sourceAddr, byte esmeAddrTon, byte esmeAddrNpi, java.lang.String esmeAddr, OptionalParameter... optionalParameters)
           
 byte[] sendBind(java.io.OutputStream os, BindType bindType, int sequenceNumber, java.lang.String systemId, java.lang.String password, java.lang.String systemType, InterfaceVersion interfaceVersion, TypeOfNumber addrTon, NumberingPlanIndicator addrNpi, java.lang.String addressRange)
          Send bind command.
 byte[] sendBindResp(java.io.OutputStream os, int commandId, int sequenceNumber, java.lang.String systemId)
          Send bind response command.
 byte[] sendCancelSm(java.io.OutputStream os, int sequenceNumber, java.lang.String serviceType, java.lang.String messageId, TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi, java.lang.String sourceAddr, TypeOfNumber destAddrTon, NumberingPlanIndicator destAddrNpi, java.lang.String destinationAddr)
          Send cancel short message command.
 byte[] sendCancelSmResp(java.io.OutputStream os, int sequenceNumber)
          Send cancel short message response command.
 byte[] sendDataSm(java.io.OutputStream os, int sequenceNumber, java.lang.String serviceType, TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi, java.lang.String sourceAddr, TypeOfNumber destAddrTon, NumberingPlanIndicator destAddrNpi, java.lang.String destinationAddr, ESMClass esmClass, RegisteredDelivery registeredDelivery, DataCoding dataCoding, OptionalParameter... optionalParameters)
          Send the data short message command.
 byte[] sendDataSmResp(java.io.OutputStream os, int sequenceNumber, java.lang.String messageId, OptionalParameter... optionalParameters)
          Send data short message response command.
 byte[] sendDeliverSm(java.io.OutputStream os, int sequenceNumber, java.lang.String serviceType, TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi, java.lang.String sourceAddr, TypeOfNumber destAddrTon, NumberingPlanIndicator destAddrNpi, java.lang.String destinationAddr, ESMClass esmClass, byte protocoId, byte priorityFlag, RegisteredDelivery registeredDelivery, DataCoding dataCoding, byte[] shortMessage, OptionalParameter... optionalParameters)
          Send the deliver short message command.
 byte[] sendDeliverSmResp(java.io.OutputStream os, int sequenceNumber)
          Send the deliver short message response.
 byte[] sendEnquireLink(java.io.OutputStream os, int sequenceNumber)
          Send enquire link command.
 byte[] sendEnquireLinkResp(java.io.OutputStream os, int sequenceNumber)
          Send enquire link response command.
 byte[] sendGenericNack(java.io.OutputStream os, int commandStatus, int sequenceNumber)
          Send generic non-acknowledge command.
 byte[] sendHeader(java.io.OutputStream os, int commandId, int commandStatus, int sequenceNumber)
          Send only the PDU header.
 byte[] sendQuerySm(java.io.OutputStream os, int sequenceNumber, java.lang.String messageId, TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi, java.lang.String sourceAddr)
          Send query short message command.
 byte[] sendQuerySmResp(java.io.OutputStream os, int sequenceNumber, java.lang.String messageId, java.lang.String finalDate, MessageState messageState, byte errorCode)
          Send query short message response command.
 byte[] sendReplaceSm(java.io.OutputStream os, int sequenceNumber, java.lang.String messageId, TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi, java.lang.String sourceAddr, java.lang.String scheduleDeliveryTime, java.lang.String validityPeriod, RegisteredDelivery registeredDelivery, byte smDefaultMsgId, byte[] shortMessage)
           
 byte[] sendReplaceSmResp(java.io.OutputStream os, int sequenceNumber)
           
 byte[] sendSubmiMulti(java.io.OutputStream os, int sequenceNumber, java.lang.String serviceType, TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi, java.lang.String sourceAddr, DestinationAddress[] destinationAddresses, ESMClass esmClass, byte protocolId, byte priorityFlag, java.lang.String scheduleDeliveryTime, java.lang.String validityPeriod, RegisteredDelivery registeredDelivery, ReplaceIfPresentFlag replaceIfPresentFlag, DataCoding dataCoding, byte smDefaultMsgId, byte[] shortMessage, OptionalParameter... optionalParameters)
           
 byte[] sendSubmitMultiResp(java.io.OutputStream os, int sequenceNumber, java.lang.String messageId, UnsuccessDelivery... unsuccessDeliveries)
           
 byte[] sendSubmitSm(java.io.OutputStream os, int sequenceNumber, java.lang.String serviceType, TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi, java.lang.String sourceAddr, TypeOfNumber destAddrTon, NumberingPlanIndicator destAddrNpi, java.lang.String destinationAddr, ESMClass esmClass, byte protocoId, byte priorityFlag, java.lang.String scheduleDeliveryTime, java.lang.String validityPeriod, RegisteredDelivery registeredDelivery, byte replaceIfPresent, DataCoding dataCoding, byte smDefaultMsgId, byte[] shortMessage, OptionalParameter... optionalParameters)
          Send submit short message command.
 byte[] sendSubmitSmResp(java.io.OutputStream os, int sequenceNumber, java.lang.String messageId)
          Send submit short message response command.
 byte[] sendUnbind(java.io.OutputStream os, int sequenceNumber)
          Send unbind command.
 byte[] sendUnbindResp(java.io.OutputStream os, int commandStatus, int sequenceNumber)
          Send unbind response command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPDUSender

public DefaultPDUSender()
Default constructor.


DefaultPDUSender

public DefaultPDUSender(PDUComposer pduComposer)
Construct with specified PDU composer.

Parameters:
pduComposer - is the PDU composer.
Method Detail

sendHeader

public byte[] sendHeader(java.io.OutputStream os,
                         int commandId,
                         int commandStatus,
                         int sequenceNumber)
                  throws java.io.IOException
Description copied from interface: PDUSender
Send only the PDU header.

Specified by:
sendHeader in interface PDUSender
Parameters:
os - is the OutputStream
commandId - is the SMPP command_id.
commandStatus - is the SMPP command_status.
sequenceNumber - is the SMPP sequence_number.
Returns:
the composed bytes.
Throws:
java.io.IOException - if an I/O error occur.

sendBind

public byte[] sendBind(java.io.OutputStream os,
                       BindType bindType,
                       int sequenceNumber,
                       java.lang.String systemId,
                       java.lang.String password,
                       java.lang.String systemType,
                       InterfaceVersion interfaceVersion,
                       TypeOfNumber addrTon,
                       NumberingPlanIndicator addrNpi,
                       java.lang.String addressRange)
                throws PDUStringException,
                       java.io.IOException
Description copied from interface: PDUSender
Send bind command.

Specified by:
sendBind in interface PDUSender
Parameters:
os - is the OutputStream
bindType - is the bind type that determine the command_id.
sequenceNumber - is the sequence_number.
systemId - is the system_id.
password - is the password.
systemType - is the system_type.
interfaceVersion - is the interface_version.
addrTon - is the addr_ton.
addrNpi - is the addr_npi.
addressRange - is the address_range.
Returns:
the composed bytes.
Throws:
PDUStringException - if there is an invalid string constraint found.
java.io.IOException - if an I/O error occur.

sendBindResp

public byte[] sendBindResp(java.io.OutputStream os,
                           int commandId,
                           int sequenceNumber,
                           java.lang.String systemId)
                    throws PDUStringException,
                           java.io.IOException
Description copied from interface: PDUSender
Send bind response command.

Specified by:
sendBindResp in interface PDUSender
Parameters:
os - is the OutputStream.
commandId - is the command_id.
sequenceNumber - is the sequence_number.
systemId - is the system_id.
Returns:
the composed bytes.
Throws:
PDUStringException
java.io.IOException - if an IO error occur.

sendUnbind

public byte[] sendUnbind(java.io.OutputStream os,
                         int sequenceNumber)
                  throws java.io.IOException
Description copied from interface: PDUSender
Send unbind command.

Specified by:
sendUnbind in interface PDUSender
Parameters:
os - is the OutputStream .
sequenceNumber - is the sequence_number.
Returns:
the composed bytes.
Throws:
java.io.IOException - if an IO error occur.

sendGenericNack

public byte[] sendGenericNack(java.io.OutputStream os,
                              int commandStatus,
                              int sequenceNumber)
                       throws java.io.IOException
Description copied from interface: PDUSender
Send generic non-acknowledge command.

Specified by:
sendGenericNack in interface PDUSender
Parameters:
os - is the OutputStream
commandStatus - is the command_status.
sequenceNumber - is the sequence_number.
Returns:
the composed bytes.
Throws:
java.io.IOException - if an IO error occur.

sendUnbindResp

public byte[] sendUnbindResp(java.io.OutputStream os,
                             int commandStatus,
                             int sequenceNumber)
                      throws java.io.IOException
Description copied from interface: PDUSender
Send unbind response command.

Specified by:
sendUnbindResp in interface PDUSender
Parameters:
os - is the OutputStream.
commandStatus - is the command_status.
sequenceNumber - is the sequence_number.
Returns:
the composed bytes.
Throws:
java.io.IOException - if an IO error occur.

sendEnquireLink

public byte[] sendEnquireLink(java.io.OutputStream os,
                              int sequenceNumber)
                       throws java.io.IOException
Description copied from interface: PDUSender
Send enquire link command.

Specified by:
sendEnquireLink in interface PDUSender
Parameters:
os - is the OutputStream.
sequenceNumber - is the sequence_number.
Returns:
the composed bytes.
Throws:
java.io.IOException - if an IO error occur.

sendEnquireLinkResp

public byte[] sendEnquireLinkResp(java.io.OutputStream os,
                                  int sequenceNumber)
                           throws java.io.IOException
Description copied from interface: PDUSender
Send enquire link response command.

Specified by:
sendEnquireLinkResp in interface PDUSender
Parameters:
os - is the OutputStream.
sequenceNumber - is the sequenceNumber.
Returns:
the composed bytes.
Throws:
java.io.IOException - if an IO error occur.

sendSubmitSm

public byte[] sendSubmitSm(java.io.OutputStream os,
                           int sequenceNumber,
                           java.lang.String serviceType,
                           TypeOfNumber sourceAddrTon,
                           NumberingPlanIndicator sourceAddrNpi,
                           java.lang.String sourceAddr,
                           TypeOfNumber destAddrTon,
                           NumberingPlanIndicator destAddrNpi,
                           java.lang.String destinationAddr,
                           ESMClass esmClass,
                           byte protocoId,
                           byte priorityFlag,
                           java.lang.String scheduleDeliveryTime,
                           java.lang.String validityPeriod,
                           RegisteredDelivery registeredDelivery,
                           byte replaceIfPresent,
                           DataCoding dataCoding,
                           byte smDefaultMsgId,
                           byte[] shortMessage,
                           OptionalParameter... optionalParameters)
                    throws PDUStringException,
                           java.io.IOException
Description copied from interface: PDUSender
Send submit short message command.

Specified by:
sendSubmitSm in interface PDUSender
Parameters:
os - is the OutputStream.
sequenceNumber - is the sequence_number.
serviceType - is the service_type.
sourceAddrTon - is the source_addr_ton.
sourceAddrNpi - is the source_addr_npi.
sourceAddr - is the source_addr.
destAddrTon - is the dest_addr_ton.
destAddrNpi - is the dest_addr_npi.
destinationAddr - is the destination_addr.
esmClass - is the esm_class.
protocoId - is the protocol_id.
priorityFlag - is the priority_flag.
scheduleDeliveryTime - is the schedule_delivery_time
validityPeriod - is the validity_period.
registeredDelivery - is the registered_delivery.
replaceIfPresent - is the replace_if_present_flag.
dataCoding - is the data_coding.
smDefaultMsgId - is the sm_default_msg_id.
shortMessage - is the short_message.
optionalParameters - is the optional parameters.
Returns:
the composed bytes.
Throws:
PDUStringException - if there is an invalid string constraint found.
java.io.IOException - if there is an IO error occur.

sendSubmitSmResp

public byte[] sendSubmitSmResp(java.io.OutputStream os,
                               int sequenceNumber,
                               java.lang.String messageId)
                        throws PDUStringException,
                               java.io.IOException
Description copied from interface: PDUSender
Send submit short message response command.

Specified by:
sendSubmitSmResp in interface PDUSender
Parameters:
os - is the OutputStream.
sequenceNumber - is the sequence_number.
messageId - is the message_id.
Returns:
the composed bytes.
Throws:
PDUStringException - if there is an invalid string constraint found.
java.io.IOException - if there is an IO error occur.

sendQuerySm

public byte[] sendQuerySm(java.io.OutputStream os,
                          int sequenceNumber,
                          java.lang.String messageId,
                          TypeOfNumber sourceAddrTon,
                          NumberingPlanIndicator sourceAddrNpi,
                          java.lang.String sourceAddr)
                   throws PDUStringException,
                          java.io.IOException
Description copied from interface: PDUSender
Send query short message command.

Specified by:
sendQuerySm in interface PDUSender
Parameters:
os - is the OutputStream.
sequenceNumber - is the sequence_number.
messageId - is the message_id.
sourceAddrTon - is the source_addr_ton.
sourceAddrNpi - is the source_addr_npi.
sourceAddr - is the source_addr.
Returns:
the composed bytes.
Throws:
PDUStringException - if there is an invalid constraint found.
java.io.IOException - if there is an IO error occur.

sendQuerySmResp

public byte[] sendQuerySmResp(java.io.OutputStream os,
                              int sequenceNumber,
                              java.lang.String messageId,
                              java.lang.String finalDate,
                              MessageState messageState,
                              byte errorCode)
                       throws PDUStringException,
                              java.io.IOException
Description copied from interface: PDUSender
Send query short message response command.

Specified by:
sendQuerySmResp in interface PDUSender
Parameters:
os - is the OutputStream.
sequenceNumber - is the sequence_number.
messageId - is the message_id.
finalDate - is the final_date.
messageState - is the message_state.
errorCode - is the error_code.
Returns:
the composed bytes.
Throws:
PDUStringException - if there is an invalid constraint found.
java.io.IOException - if there is an IO error occur.

sendDeliverSm

public byte[] sendDeliverSm(java.io.OutputStream os,
                            int sequenceNumber,
                            java.lang.String serviceType,
                            TypeOfNumber sourceAddrTon,
                            NumberingPlanIndicator sourceAddrNpi,
                            java.lang.String sourceAddr,
                            TypeOfNumber destAddrTon,
                            NumberingPlanIndicator destAddrNpi,
                            java.lang.String destinationAddr,
                            ESMClass esmClass,
                            byte protocoId,
                            byte priorityFlag,
                            RegisteredDelivery registeredDelivery,
                            DataCoding dataCoding,
                            byte[] shortMessage,
                            OptionalParameter... optionalParameters)
                     throws PDUStringException,
                            java.io.IOException
Description copied from interface: PDUSender
Send the deliver short message command.

Specified by:
sendDeliverSm in interface PDUSender
Parameters:
os - is the OutputStream.
sequenceNumber - the sequence_number.
serviceType - the service_type.
sourceAddrTon - is the source_addr_ton.
sourceAddrNpi - is the source_addr_npi.
sourceAddr - is the source_addr.
destAddrTon - is the dest_addr_ton.
destAddrNpi - is the dest_addr_npi.
destinationAddr - is the destination_addr.
esmClass - is the esm_class.
protocoId - is the protocol_id.
priorityFlag - is the priority_flag.
registeredDelivery - is the registered_delivery.
dataCoding - is the data_coding.
shortMessage - is the short_message.
optionalParameters - is the optional parameters.
Returns:
the composed bytes.
Throws:
PDUStringException - if there is an invalid string constraint found.
java.io.IOException - if there is an IO error occur.

sendDeliverSmResp

public byte[] sendDeliverSmResp(java.io.OutputStream os,
                                int sequenceNumber)
                         throws java.io.IOException
Description copied from interface: PDUSender
Send the deliver short message response.

Specified by:
sendDeliverSmResp in interface PDUSender
Parameters:
os - is the OutputStream.
sequenceNumber - is the sequence_number.
Returns:
the composed bytes.
Throws:
java.io.IOException - if there is an IO error occur.

sendDataSm

public byte[] sendDataSm(java.io.OutputStream os,
                         int sequenceNumber,
                         java.lang.String serviceType,
                         TypeOfNumber sourceAddrTon,
                         NumberingPlanIndicator sourceAddrNpi,
                         java.lang.String sourceAddr,
                         TypeOfNumber destAddrTon,
                         NumberingPlanIndicator destAddrNpi,
                         java.lang.String destinationAddr,
                         ESMClass esmClass,
                         RegisteredDelivery registeredDelivery,
                         DataCoding dataCoding,
                         OptionalParameter... optionalParameters)
                  throws PDUStringException,
                         java.io.IOException
Description copied from interface: PDUSender
Send the data short message command.

Specified by:
sendDataSm in interface PDUSender
Parameters:
os - is the OutputStream.
sequenceNumber - the sequence_number.
serviceType - the service_type.
sourceAddrTon - is the source_addr_ton.
sourceAddrNpi - is the source_addr_npi.
sourceAddr - is the source_addr.
destAddrTon - is the dest_addr_ton.
destAddrNpi - is the dest_addr_npi.
destinationAddr - is the destination_addr.
esmClass - is the esm_class.
registeredDelivery - is the registered_delivery.
dataCoding - is the data_coding.
optionalParameters - is the optional parameters.
Returns:
the composed bytes.
Throws:
PDUStringException - if there is an invalid string constraint found.
java.io.IOException - if there is an IO error occur.

sendDataSmResp

public byte[] sendDataSmResp(java.io.OutputStream os,
                             int sequenceNumber,
                             java.lang.String messageId,
                             OptionalParameter... optionalParameters)
                      throws PDUStringException,
                             java.io.IOException
Description copied from interface: PDUSender
Send data short message response command.

Specified by:
sendDataSmResp in interface PDUSender
Parameters:
os - is the OutputStream.
sequenceNumber - is the sequence_number.
messageId - is the message_id.
optionalParameters - is the optional parameters.
Returns:
the composed bytes.
Throws:
PDUStringException - if there is an invalid string constraint found.
java.io.IOException - if there is an IO error occur.

sendCancelSm

public byte[] sendCancelSm(java.io.OutputStream os,
                           int sequenceNumber,
                           java.lang.String serviceType,
                           java.lang.String messageId,
                           TypeOfNumber sourceAddrTon,
                           NumberingPlanIndicator sourceAddrNpi,
                           java.lang.String sourceAddr,
                           TypeOfNumber destAddrTon,
                           NumberingPlanIndicator destAddrNpi,
                           java.lang.String destinationAddr)
                    throws PDUStringException,
                           java.io.IOException
Description copied from interface: PDUSender
Send cancel short message command.

Specified by:
sendCancelSm in interface PDUSender
Returns:
Throws:
PDUStringException
java.io.IOException

sendCancelSmResp

public byte[] sendCancelSmResp(java.io.OutputStream os,
                               int sequenceNumber)
                        throws java.io.IOException
Description copied from interface: PDUSender
Send cancel short message response command.

Specified by:
sendCancelSmResp in interface PDUSender
Returns:
Throws:
java.io.IOException

sendReplaceSm

public byte[] sendReplaceSm(java.io.OutputStream os,
                            int sequenceNumber,
                            java.lang.String messageId,
                            TypeOfNumber sourceAddrTon,
                            NumberingPlanIndicator sourceAddrNpi,
                            java.lang.String sourceAddr,
                            java.lang.String scheduleDeliveryTime,
                            java.lang.String validityPeriod,
                            RegisteredDelivery registeredDelivery,
                            byte smDefaultMsgId,
                            byte[] shortMessage)
                     throws PDUStringException,
                            java.io.IOException
Specified by:
sendReplaceSm in interface PDUSender
Throws:
PDUStringException
java.io.IOException

sendReplaceSmResp

public byte[] sendReplaceSmResp(java.io.OutputStream os,
                                int sequenceNumber)
                         throws java.io.IOException
Specified by:
sendReplaceSmResp in interface PDUSender
Throws:
java.io.IOException

sendSubmiMulti

public byte[] sendSubmiMulti(java.io.OutputStream os,
                             int sequenceNumber,
                             java.lang.String serviceType,
                             TypeOfNumber sourceAddrTon,
                             NumberingPlanIndicator sourceAddrNpi,
                             java.lang.String sourceAddr,
                             DestinationAddress[] destinationAddresses,
                             ESMClass esmClass,
                             byte protocolId,
                             byte priorityFlag,
                             java.lang.String scheduleDeliveryTime,
                             java.lang.String validityPeriod,
                             RegisteredDelivery registeredDelivery,
                             ReplaceIfPresentFlag replaceIfPresentFlag,
                             DataCoding dataCoding,
                             byte smDefaultMsgId,
                             byte[] shortMessage,
                             OptionalParameter... optionalParameters)
                      throws PDUStringException,
                             InvalidNumberOfDestinationsException,
                             java.io.IOException
Specified by:
sendSubmiMulti in interface PDUSender
Throws:
PDUStringException
InvalidNumberOfDestinationsException
java.io.IOException

sendSubmitMultiResp

public byte[] sendSubmitMultiResp(java.io.OutputStream os,
                                  int sequenceNumber,
                                  java.lang.String messageId,
                                  UnsuccessDelivery... unsuccessDeliveries)
                           throws PDUStringException,
                                  java.io.IOException
Specified by:
sendSubmitMultiResp in interface PDUSender
Throws:
PDUStringException
java.io.IOException

sendAlertNotification

public byte[] sendAlertNotification(java.io.OutputStream os,
                                    int sequenceNumber,
                                    byte sourceAddrTon,
                                    byte sourceAddrNpi,
                                    java.lang.String sourceAddr,
                                    byte esmeAddrTon,
                                    byte esmeAddrNpi,
                                    java.lang.String esmeAddr,
                                    OptionalParameter... optionalParameters)
                             throws PDUStringException,
                                    java.io.IOException
Specified by:
sendAlertNotification in interface PDUSender
Throws:
PDUStringException
java.io.IOException