com.java4less.sms
Class SmsMessage

java.lang.Object
  |
  +--com.java4less.sms.SmsMessage

public class SmsMessage
extends java.lang.Object

Generic class for SMS Messages. This class has several uses:

- store message fields before and after it is sent through a gateway.
- get its delivery status


As this a generic base class it does not perform validity checks.
Validity checks may be performed by subclasses of this one or by the SMS gateway class.


Field Summary
static int ACCEPTED
          SMS Gateway accepted message.
static int DOUBTFUL
          In TAP protocol : Initially accepted but not confirmed.
static int GATEWAY_ERROR
          Last try to connect to the SMS gateway to deliver this message failed.
static int PENDING
          Initial Message status before trying to deliver it
static int REJECTED
          SMS Gateway rejected message.
 
Constructor Summary
SmsMessage()
          Creates an empty message.
SmsMessage(java.lang.String recipient, java.lang.String text)
          Creates a message with the minimum fields set.
 
Method Summary
 java.lang.String getRecipient()
          see setRecipient(java.lang.String)
 java.lang.String getStatusText()
          see setStatus(int status, String text)
 java.lang.String getText()
          see setText
 boolean isAccepted()
          true if message status is ACCEPTED
 boolean isDoubtful()
          true if message status is DOUBTFUL
 boolean isGatewayError()
          true if message status is GATEWAY_ERROR
 boolean isPending()
          true if message status is PENDING
 boolean isRejected()
          true if message status is REJECTED
 void setRecipient(java.lang.String recipient)
          Phone number where the message will be or was sent.
 void setStatus(int status)
          Possible status are PENDING, ACCEPTED, REJECTED, GATEWAY_ERROR and DOUBTFUL.
 void setStatus(int status, java.lang.String text)
          Sets status and provides descriptive text (e.g. reason for rejection).
 void setText(java.lang.String text)
          The message's text (content).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PENDING

public static final int PENDING
Initial Message status before trying to deliver it

See Also:
Constant Field Values

ACCEPTED

public static final int ACCEPTED
SMS Gateway accepted message. Note that there is no guarantee the recipient effectively received it.

See Also:
Constant Field Values

REJECTED

public static final int REJECTED
SMS Gateway rejected message. This means this message has some problem such as unknown recipient or invalid content.

See Also:
Constant Field Values

GATEWAY_ERROR

public static final int GATEWAY_ERROR
Last try to connect to the SMS gateway to deliver this message failed. This may be due to a configuration error or just a temporary condition that may be corrected at a further connection.

See Also:
Constant Field Values

DOUBTFUL

public static final int DOUBTFUL
In TAP protocol : Initially accepted but not confirmed. Gateway initially accepted the message but a further condition when trying to finish the connection shows that in fact it may have been rejected.

See Also:
Constant Field Values
Constructor Detail

SmsMessage

public SmsMessage()
Creates an empty message.


SmsMessage

public SmsMessage(java.lang.String recipient,
                  java.lang.String text)
Creates a message with the minimum fields set.

Parameters:
recipient - see setRecipient
text - see setText
Method Detail

setRecipient

public void setRecipient(java.lang.String recipient)
Phone number where the message will be or was sent.
A common format is MSISDN (international mobile number format), but it can be specific format of the gateway used for delivery.

See Also:
getRecipient()

getRecipient

public java.lang.String getRecipient()
see setRecipient(java.lang.String)


setText

public void setText(java.lang.String text)
The message's text (content). Maximum length and valid character set will depent on the SMS gateway and other factors.

See Also:
getText()

getText

public java.lang.String getText()
see setText


isPending

public boolean isPending()
true if message status is PENDING

See Also:
setStatus

isAccepted

public boolean isAccepted()
true if message status is ACCEPTED

See Also:
setStatus

isRejected

public boolean isRejected()
true if message status is REJECTED

See Also:
setStatus

isGatewayError

public boolean isGatewayError()
true if message status is GATEWAY_ERROR

See Also:
setStatus

isDoubtful

public boolean isDoubtful()
true if message status is DOUBTFUL

See Also:
setStatus

getStatusText

public java.lang.String getStatusText()
see setStatus(int status, String text)


setStatus

public void setStatus(int status)
Possible status are PENDING, ACCEPTED, REJECTED, GATEWAY_ERROR and DOUBTFUL.

See Also:
isPending(), isAccepted(), isRejected(), isGatewayError(), isDoubtful()

setStatus

public void setStatus(int status,
                      java.lang.String text)
Sets status and provides descriptive text (e.g. reason for rejection).

See Also:
setStatus(int status), getStatusText()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object