com.unipro.smlib
Class OutMessage

java.lang.Object
  |
  +--com.unipro.smlib.OutMessage
All Implemented Interfaces:
java.io.Serializable

public class OutMessage
extends java.lang.Object
implements java.io.Serializable

Class represents outgoing SMS message.
Outgoing message can be represented as OutMessage instance and sent by sendMessage() method of SmsManager class. You can set and get parameters of the message by calling set/get methods.

Parameters are:
Recipient number The recipient number in national format without '+' in provider specified number's number. For example: 79029070904 - national format, 001900 - provider specified format. String number must consist of numeral symbols, "00000000000" by default. For example: "79029070904"
SMSC Number The number of Short Message Service Center in national format without '+', null by default
Text The message text, "www.mobiles.unipro.ru" by default
Validity Time The validity period, 144 by default
ACK The request for status report, false by default.
Reply Path Reply path flag can be use to notify receiver if transmitter is capable to receive messages, true by default.
Flash Flag Flag indicates if this message is a flash message, false by default.
Reject Duplicates Instruct the SMSC to accept or reject an outgoung messages for an message still held in the SMSC which has the same message reference and the same recipient's address as a previously submitted message from the same mobile, false by default.

Reply path


The reply path is requested by the originating short message entity (an MS) by setting the reply path parameter in the outgoing message of the original SM. If the original SMSC supports reply path requesting for the originating short message entity (an MS), it will take notice of the reply path parameter in the outgoing message and set reply path parameter in the incoming message of the original MT SM towards the replying MS. Hence, reply path exists for the replying MS towards the originating short message entity (an MS).

Flash messages


A Flash SMS appears directly on the phone's screen, instead of the 'Inbox'. Its an useful alternative to normal SMS when you want to catch the recipients attention immediately. The recipient has the option of 'Saving' the Flash SMS to his 'Inbox'.

See Also:
Serialized Form

Constructor Summary
OutMessage()
          Creates new Outgoing Message with default values.
OutMessage(java.lang.String num, java.lang.String mes)
          Creates new OutMessage with the specified receiver and message string.
OutMessage(java.lang.String num, java.lang.String mes, boolean ack)
          Creates new OutMessage with the specified receiver, message string and ACK request.
OutMessage(java.lang.String num, java.lang.String SMSCnum, java.lang.String mes)
          Creates new OutMessage with the specified receiver, Short Message Service Center number and message string.
OutMessage(java.lang.String num, java.lang.String SMSCnum, java.lang.String mes, boolean ack, int valPer)
          Creates new OutMessage with the specified receiver, Short Message Service Center number, message string, request for status report, validity period.
 
Method Summary
 boolean getACKRequest()
          Gets message request for status report (ACK).
static java.lang.String getDefaultSMSCNumber()
          Gets default SMSC number.
 java.lang.String getRecipientNumber()
          Gets message recipient number.
 boolean getRejectDuplicates()
          Returns reject duplicates parameter of this message.
 boolean getReplyPath()
          Gets the reply path flag.
 java.lang.String getSMSCNumber()
          Gets message Short Message Service Center number.
 java.lang.String getText()
          Gets message text.
 int getValidityTime()
          Gets message validity period.
 boolean isFlash()
          Tests if this message is a flash message.
 void setACKRequest(boolean r)
          Sets request for status report (ACK) for the message.
static void setDefaultSMSCNumber(java.lang.String num)
          Sets default SMSC number.
 void setFlash(boolean f)
          Sets flag to indicate this message as flash message.
 void setRecipientNumber(java.lang.String num)
          Sets recipient number of the message.
 void setRejectDuplicates(boolean b)
          Instruct the SMSC to accept or reject an outgoung messages for an message still held in the SMSC which has the same message reference and the same recipient's address as a previously submitted message from the same mobile.
 void setReplyPath(boolean repPath)
          Sets reply path flag.
 void setSMSCNumber(java.lang.String num)
          Sets Short Message Service Center number of this message.
 void setText(java.lang.String mess)
          Sets the text of the message.
 void setValidityTime(int val)
          Sets validity period of the message.
 java.lang.String toString()
          Returns a String representation of the OutMessage object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OutMessage

public OutMessage(java.lang.String num,
                  java.lang.String SMSCnum,
                  java.lang.String mes,
                  boolean ack,
                  int valPer)
           throws ValidationException
Creates new OutMessage with the specified receiver, Short Message Service Center number, message string, request for status report, validity period.
Parameters:
num - receiver address.
SMSCnum - Short Message Service Center number, MTS by default.
mes - message string up to 38760=255*152 characters.
ack - request for status report, if ack=true then status report will be requested at the SMS Center.
valPer - validity period.
Throws:
ValidationException - If any parameter of OutMessage is invalid:
  1. If any parameter is null
  2. If recipient's number or SMSC number isn't in national format without '+'
  3. If recipient's number or SMSC number does not consist of only numeral symbols
  4. If message text is more than 38760=255*152 characters
  5. If validity period parameter value is less than 0 or more than 255
  6. If message contains any character not from base alphabet, i.e. any Unicode character.
Additional information about SMLib exceptions: SMLib exceptions.

OutMessage

public OutMessage(java.lang.String num,
                  java.lang.String SMSCnum,
                  java.lang.String mes)
           throws ValidationException
Creates new OutMessage with the specified receiver, Short Message Service Center number and message string.
Parameters:
num - receiver address.
SMSCnum - Short Message Service Center number, MTS by default.
mes - message string up to 38760=255*152 characters.
Default values.
Throws:
ValidationException - If any parameter of OutMessage is invalid:
  1. If any parameter is null
  2. If recipient number or SMSC number isn't in national format without '+'
  3. If recipient number or SMSC number does not consist of only numeral symbols
  4. If message text is more than 38760=255*152 characters
  5. If message contains any character not from base alphabet, i.e. any Unicode character.
There is additional information about SMLib exceptions at all: SMLib exceptions.

OutMessage

public OutMessage(java.lang.String num,
                  java.lang.String mes,
                  boolean ack)
           throws ValidationException
Creates new OutMessage with the specified receiver, message string and ACK request.
Parameters:
num - receiver address.
mes - message string up to 38760=255*152 characters.
ack - request for status report, if ack=true then status report will be requested at the SMSC Center.
Default values.
Throws:
ValidationException - If any parameter of OutMessage is invalid:
  1. If any parameter is null
  2. If recipient number isn't in national format without '+'
  3. If recipient number does not consist of only numeral symbols
  4. If message text is more than 38760=255*152 characters
  5. If message contains any character not from base alphabet, i.e. any Unicode character.
Additional information about SMLib exceptions: SMLib exceptions.

OutMessage

public OutMessage(java.lang.String num,
                  java.lang.String mes)
           throws ValidationException
Creates new OutMessage with the specified receiver and message string.
Parameters:
num - receiver address
mes - message string up to 38760=255*152 characters
Default values.
Throws:
ValidationException - If parameter is invalid.
  1. If any parameter is null
  2. If recipient number isn't in national format without '+'
  3. If recipient number does not consist of only numeral symbols
  4. If message text is more than 38760=255*152 characters
  5. If message contains any character not from base alphabet, i.e. any Unicode character.
Additional information about SMLib exceptions: SMLib exceptions.

OutMessage

public OutMessage()
Creates new Outgoing Message with default values.
Default values.
Method Detail

setDefaultSMSCNumber

public static void setDefaultSMSCNumber(java.lang.String num)
                                 throws ValidationException
Sets default SMSC number. Default SMSC number is a static field of OutMessage class and it used by method sendMessage() of SmsManager if SMSC number of OutMessage object was not set (=null).
Parameters:
num - default SMSC number, 79029869990 by default.
Throws:
ValidationException - If parameter is invalid:
  1. If parameter is null
  2. If recipient's number isn't in national format without '+'
  3. If recipient's number does not consist of only numeral symbols

getDefaultSMSCNumber

public static java.lang.String getDefaultSMSCNumber()
Gets default SMSC number. Default SMSC number is a static field of OutMessage class and it used by method sendMessage() of SmsManager if SMSC number of OutMessage object was not set (=null).
Returns:
gets default SMSC number.

setValidityTime

public void setValidityTime(int val)
                     throws ValidationException
Sets validity period of the message. Validity period is a time period that will be recommended to SMS Center for message saving if message can't be delivered immediately.
Parameters:
val - validity period in validity period format:
val value Validity period value
0 to 143 (val + 1) * 5 minutes (i.e. 5 minutes intervals up to 12 hours)
144 to 167 12 hours + ((val - 143) * 30 minutes)
168 to 196 (val - 166) * 1 day
197 to 255 (val - 192) * 1 week

Default values.
Throws:
ValidationException - If parameter is invalid: if validity period parameter value is less than 0 or more than 255.
Additional information about SMLib exceptions: SMLib exceptions.

setRecipientNumber

public void setRecipientNumber(java.lang.String num)
                        throws ValidationException
Sets recipient number of the message.
Parameters:
num - recipient number in national format without '+'.
Default values.
Throws:
ValidationException - If parameter is invalid:
  1. If parameter is null
  2. If recipient's number's length more than 12 symbols
  3. If recipient's number does not consist of only numeral symbols
Additional information about SMLib exceptions: SMLib exceptions.
Default values.

setACKRequest

public void setACKRequest(boolean r)
Sets request for status report (ACK) for the message.
Parameters:
r - request for status report: If r is true then report will be requested at the SMSC Center.
Default values.

getACKRequest

public boolean getACKRequest()
Gets message request for status report (ACK).
Returns:
the request for status report (ACK). If returned value is true then report will be requested at the SMS Center.

getSMSCNumber

public java.lang.String getSMSCNumber()
Gets message Short Message Service Center number.
Returns:
the Short Message Service Center number in national format without '+'.

setSMSCNumber

public void setSMSCNumber(java.lang.String num)
                   throws ValidationException
Sets Short Message Service Center number of this message.
Parameters:
num - Short Message Service Center number in national format without '+'.
Default values.
Throws:
ValidationException - If parameter is invalid:
  1. If parameter is null
  2. If SMSC number isn't in national format without '+'
  3. If SMSC number does not consist of only numeral symbols
Additional information about SMLib exceptions: SMLib exceptions.

setText

public void setText(java.lang.String mess)
             throws ValidationException
Sets the text of the message. Maximum message's length is 38760=255*152 characters. If the length of message is more than 160 characters then massage is sent as concatinated.
Parameters:
mess - - text of message up to 38760=255*152 characters.
Throws:
ValidationException - If parameter is invalid:
  1. If parameter is null
  2. If message text is more than 38760=255*152 characters
  3. If message contains any character not from base alphabet, i.e. any Unicode character.

Default values.

getRecipientNumber

public java.lang.String getRecipientNumber()
Gets message recipient number.
Returns:
the recipient number in national format without '+'.

getValidityTime

public int getValidityTime()
Gets message validity period. Validity period it is time what will be recommended to SMS center for saving message if message can't be delivered immediately.
Returns:
the validity period of this message in validity period format:
val value Validity period value
0 to 143 (val + 1) * 5 minutes (i.e. 5 minutes intervals up to 12 hours)
144 to 167 12 hours + ((val - 143) * 30 minutes)
168 to 196 (val - 166) * 1 day
197 to 255 (val - 192) * 1 week

getText

public java.lang.String getText()
Gets message text.
Returns:
the text of the message.

setReplyPath

public void setReplyPath(boolean repPath)
Sets reply path flag. more about reply path.
Parameters:
repPath - reply path flag, if this parameter is true - reply path is specified, false - not
Default values.

getReplyPath

public boolean getReplyPath()
Gets the reply path flag. more about reply path.
Returns:
reply path flag.

setFlash

public void setFlash(boolean f)
Sets flag to indicate this message as flash message. more about flash messages.
Parameters:
f - flash flag, if f is true, then this message is indicated as flash, false - otherwise. The default value is false.

isFlash

public boolean isFlash()
Tests if this message is a flash message. more about flash messages.
Returns:
flash flag.

setRejectDuplicates

public void setRejectDuplicates(boolean b)
Instruct the SMSC to accept or reject an outgoung messages for an message still held in the SMSC which has the same message reference and the same recipient's address as a previously submitted message from the same mobile.
Parameters:
b - true means reject duplicates, false otherwise. The default value is false.

getRejectDuplicates

public boolean getRejectDuplicates()
Returns reject duplicates parameter of this message.
Returns:
reject duplicates parameter,true means reject duplicates, false otherwise.

toString

public java.lang.String toString()
Returns a String representation of the OutMessage object. Format: "OutMessage [To: {receiver number}, Text: {text}, SMSC Number: {smsc number}, ACK: {true/false}, Valid Time: {validity period}, Reply Path: {reply path}], Flash: {true/false}]"
Overrides:
toString in class java.lang.Object
Returns:
a string representation of the message