smsexpert
Class SMSExpertSender

java.lang.Object
  extended by smsexpert.SMSExpertSender

public class SMSExpertSender
extends java.lang.Object

Send SMS via SMS-Gateway of SMS-Expert.

Copyright 2009 Bastian Treger (SMS-Expert)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Version:
1.0
Author:
Bastian Treger, http://www.sms-expert.de

Field Summary
private static java.lang.Boolean debug
           
private static java.lang.String gateway_host
           
private static java.lang.Integer gateway_port
           
private static java.lang.String gateway_protocol
           
private static java.lang.String gateway_urlpath
           
private static java.lang.String gatewaypassword
           
private  java.lang.String message
           
private  java.lang.String receiver
           
private  java.lang.Double responseCost
           
private  java.lang.String responseMessageId
           
private  java.lang.Integer responseStatusCode
           
private  java.lang.String responseStatusText
           
private  java.lang.String sender
           
private static java.lang.String sendMode
           
private  long timestamp
           
private  java.lang.String type
           
private static java.lang.String user
           
private static java.lang.String version
           
 
Constructor Summary
SMSExpertSender()
           
 
Method Summary
private  java.lang.String getHash()
          Returns the MD5 hash.
 java.lang.String getMessage()
          Returns the SMS message.
 java.lang.String getReceiver()
          Returns the SMS receiver.
private  java.lang.String getRequestData()
          Returns the request data.
 java.lang.Double getResponseCost()
          Returns the cost of the XML response
 java.lang.String getResponseMessageId()
          Returns the message id of the XML response
 java.lang.Integer getResponseStatusCode()
          Returns the status code of the XML response
 java.lang.String getResponseStatusText()
          Returns the status text of the XML response
 java.lang.String getSender()
          Returns the SMS sender.
 java.lang.String getSMSType()
          Returns the SMS-type.
private  void readResponse(java.lang.String response)
          Reads the XML response of the SMS-Gateway.
 void send()
          Sends the message.
private  void sendGET()
          Sends the message via GET.
private  void sendPOST()
          Sends the message via POST.
 void setMessage(java.lang.String message)
          Sets the SMS message.
 void setReceiver(java.lang.String receiver)
          Set the SMS receiver.
 void setSendDateTime(int year, int month, int day, int hour, int minute)
          Sets the date and time for a time shift SMS.
 void setSender(java.lang.String sender)
          Set the SMS sender.
 void setSMSType(java.lang.String type)
          Sets the SMS-type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

user

private static java.lang.String user

gatewaypassword

private static java.lang.String gatewaypassword

sendMode

private static java.lang.String sendMode

debug

private static java.lang.Boolean debug

gateway_protocol

private static java.lang.String gateway_protocol

gateway_host

private static java.lang.String gateway_host

gateway_port

private static java.lang.Integer gateway_port

gateway_urlpath

private static java.lang.String gateway_urlpath

version

private static java.lang.String version

type

private java.lang.String type

sender

private java.lang.String sender

receiver

private java.lang.String receiver

message

private java.lang.String message

timestamp

private long timestamp

responseStatusCode

private java.lang.Integer responseStatusCode

responseStatusText

private java.lang.String responseStatusText

responseMessageId

private java.lang.String responseMessageId

responseCost

private java.lang.Double responseCost
Constructor Detail

SMSExpertSender

public SMSExpertSender()
Method Detail

setSMSType

public void setSMSType(java.lang.String type)
                throws SMSExpertSenderException
Sets the SMS-type.

Parameters:
type - The SMS-type. Possible values are "standard" or "expert"
Throws:
SMSExpertSenderException

getSMSType

public java.lang.String getSMSType()
Returns the SMS-type.

Returns:
SMS-type

setSender

public void setSender(java.lang.String sender)
               throws SMSExpertSenderException
Set the SMS sender.

Parameters:
sender - phone number in international format WITHOUT leading + or 00 (up to 16 digits) or a text (up to 11 characters)
Throws:
SMSExpertSenderException

getSender

public java.lang.String getSender()
Returns the SMS sender.

Returns:
sender

setReceiver

public void setReceiver(java.lang.String receiver)
                 throws SMSExpertSenderException
Set the SMS receiver.

Parameters:
receiver - phone number in international format WITHOUT leading + or 00 (up to 16 digits)
Throws:
SMSExpertSenderException

getReceiver

public java.lang.String getReceiver()
Returns the SMS receiver.

Returns:
receiver

setMessage

public void setMessage(java.lang.String message)
                throws SMSExpertSenderException
Sets the SMS message.

Parameters:
message - up to 1530 signs
Throws:
SMSExpertSenderException

getMessage

public java.lang.String getMessage()
Returns the SMS message.

Returns:
message

setSendDateTime

public void setSendDateTime(int year,
                            int month,
                            int day,
                            int hour,
                            int minute)
                     throws SMSExpertSenderException
Sets the date and time for a time shift SMS. If you want send the SMS immediately don't call these method.

Parameters:
year - int yyyy (4 digits)
month - int MM (2 digits)
day - int dd (2 digits)
hour - int HH (2 digits)
minute - int mm (2 digits)
Throws:
SMSExpertSenderException

send

public void send()
          throws SMSExpertSenderException
Sends the message. Checks if all necessary values are set. Calls sendGET() or sendPOST()

Throws:
SMSExpertSenderException

sendGET

private void sendGET()
Sends the message via GET. Calls readResponse(String) to handle the XML response.


sendPOST

private void sendPOST()
Sends the message via POST. Calls readResponse(String) to handle the XML response.


getRequestData

private java.lang.String getRequestData()
Returns the request data.

Returns:
String request data urlencoded

getHash

private java.lang.String getHash()
Returns the MD5 hash.

Returns:
String MD5 hash

readResponse

private void readResponse(java.lang.String response)
Reads the XML response of the SMS-Gateway. Requires JDOM.


getResponseStatusCode

public java.lang.Integer getResponseStatusCode()
Returns the status code of the XML response

Returns:
Integer status code (200 = ok, 4xx = error)

getResponseStatusText

public java.lang.String getResponseStatusText()
Returns the status text of the XML response

Returns:
String status text

getResponseMessageId

public java.lang.String getResponseMessageId()
Returns the message id of the XML response

Returns:
String message id

getResponseCost

public java.lang.Double getResponseCost()
Returns the cost of the XML response

Returns:
Double cost