SMSLib 3.5.3

org.smslib
Class AGateway

java.lang.Object
  extended by org.smslib.AGateway
Direct Known Subclasses:
AbstractSMPPGateway, BulkSmsHTTPGateway, ClickatellHTTPGateway, EzTextingHTTPGateway, KannelHTTPGateway, ModemGateway, SkypeHTTPGateway

public abstract class AGateway
extends java.lang.Object

Abstract class representing a Gateway, i.e. an interface capable of sending and/or receiving SMS messages.


Nested Class Summary
static class AGateway.AsyncEvents
           
static class AGateway.GatewayAttributes
           
static class AGateway.GatewayStatuses
           
static class AGateway.Protocols
          Enumeration representing the operation protocols of a GSM modem.
 
Constructor Summary
AGateway(java.lang.String id)
           
 
Method Summary
 boolean deleteMessage(InboundMessage msg)
           
 int getAttributes()
           
 int getDeliveryErrorCode()
          Returns the gateway-specific error code from the last queryMessage() call.
 java.lang.String getFrom()
          Returns the string that will appear on recipient's phone as the originator.
 java.lang.String getGatewayId()
          Returns the gateway id assigned to this gateway during initialization.
 int getInboundMessageCount()
          Returns the total number of messages received by this gateway.
 AGateway getMyself()
           
 int getOutboundMessageCount()
          Returns the total number of messages sent via this gateway.
 AGateway.Protocols getProtocol()
          Returns the communication protocol current in use by the gateway.
abstract  int getQueueSchedulingInterval()
          Returns the Gateway Queue sending internal (in milliseconds).
 int getRestartCount()
           
 AGateway.GatewayStatuses getStatus()
          Returns the gateway status.
 void incInboundMessageCount()
           
 void incOutboundMessageCount()
           
 boolean isInbound()
          Returns true if the the gateway is set for inbound messaging.
 boolean isOutbound()
          Returns true if the the gateway is set for outbound messaging.
 float queryBalance()
          Queries the gateway for remaining credit.
 boolean queryCoverage(OutboundMessage msg)
          Queries the gateway to see if a specific message and its recipient are covered.
 StatusReportMessage.DeliveryStatuses queryMessage(OutboundMessage msg)
          Query the gateway for message delivery status.
 StatusReportMessage.DeliveryStatuses queryMessage(java.lang.String refNo)
          Query the gateway for message delivery status.
 InboundMessage readMessage(java.lang.String memLoc, int memIndex)
           
 void readMessages(java.util.Collection<InboundMessage> msgList, InboundMessage.MessageClasses msgClass)
           
 int readPhonebook(Phonebook phonebook)
           
 boolean sendMessage(OutboundMessage msg)
           
 int sendMessages(java.util.Collection<OutboundMessage> msgList)
           
 java.lang.String sendUSSDCommand(java.lang.String ussdCommand)
           
 java.lang.String sendUSSDCommand(java.lang.String ussdCommand, boolean interactive)
           
 boolean sendUSSDRequest(USSDRequest request)
           
 void setAttributes(int myAttributes)
           
 void setDeliveryErrorCode(int error)
           
 void setFrom(java.lang.String myFrom)
          Sets the string that will appear on recipient's phone as the originator.
 void setInbound(boolean value)
          Enables or disables the gateway for inbound messaging.
 void setOutbound(boolean value)
          Enables or disables the gateway for outbound messaging.
 void setProtocol(AGateway.Protocols myProtocoll)
          Sets the communication protocol of the gateway.
 void setStatus(AGateway.GatewayStatuses myStatus)
          Sets the gateway status to a new value.
 void startGateway()
           
 void stopGateway()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AGateway

public AGateway(java.lang.String id)
Method Detail

setAttributes

public void setAttributes(int myAttributes)

getAttributes

public int getAttributes()

getMyself

public AGateway getMyself()

isInbound

public boolean isInbound()
Returns true if the the gateway is set for inbound messaging.

Returns:
True if this gateway is set for inbound messaging.

setInbound

public void setInbound(boolean value)
Enables or disables the gateway for inbound messaging. The command is accepted only if the gateway supports inbound messaging.

Parameters:
value - True to enable the gateway for inbound messaging.

isOutbound

public boolean isOutbound()
Returns true if the the gateway is set for outbound messaging.

Returns:
True if this gateway is set for outbound messaging.

setOutbound

public void setOutbound(boolean value)
Enables or disables the gateway for outbound messaging. The command is accepted only if the gateway supports outbound messaging.

Parameters:
value - True to enable the gateway for outbound messaging.

setProtocol

public void setProtocol(AGateway.Protocols myProtocoll)
Sets the communication protocol of the gateway. The call is applicable only for modem gateways, in other cases it is ignored.

Parameters:
myProtocoll - The protocol to be used.
See Also:
AGateway.Protocols, getProtocol()

getProtocol

public AGateway.Protocols getProtocol()
Returns the communication protocol current in use by the gateway.

Returns:
The communication protocol.
See Also:
AGateway.Protocols, setProtocol(Protocols)

getGatewayId

public java.lang.String getGatewayId()
Returns the gateway id assigned to this gateway during initialization.

Returns:
The gateway id.

getStatus

public AGateway.GatewayStatuses getStatus()
Returns the gateway status.

Returns:
The gateway status
See Also:
AGateway.GatewayStatuses

setStatus

public void setStatus(AGateway.GatewayStatuses myStatus)
Sets the gateway status to a new value.

Parameters:
myStatus - The new gateway status.
See Also:
AGateway.GatewayStatuses

getInboundMessageCount

public int getInboundMessageCount()
Returns the total number of messages received by this gateway.

Returns:
The number of received messages.

incInboundMessageCount

public void incInboundMessageCount()

getOutboundMessageCount

public int getOutboundMessageCount()
Returns the total number of messages sent via this gateway.

Returns:
The number of sent messages.

incOutboundMessageCount

public void incOutboundMessageCount()

getFrom

public java.lang.String getFrom()
Returns the string that will appear on recipient's phone as the originator. Not all gateways support this.

Returns:
The originator string.
See Also:
setFrom(String)

setFrom

public void setFrom(java.lang.String myFrom)
Sets the string that will appear on recipient's phone as the originator. Not all gateways support this.

Parameters:
myFrom - The originator string.
See Also:
getFrom()

startGateway

public void startGateway()
                  throws TimeoutException,
                         GatewayException,
                         java.io.IOException,
                         java.lang.InterruptedException
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

stopGateway

public void stopGateway()
                 throws TimeoutException,
                        GatewayException,
                        java.io.IOException,
                        java.lang.InterruptedException
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

readMessages

public void readMessages(java.util.Collection<InboundMessage> msgList,
                         InboundMessage.MessageClasses msgClass)
                  throws TimeoutException,
                         GatewayException,
                         java.io.IOException,
                         java.lang.InterruptedException
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

readMessage

public InboundMessage readMessage(java.lang.String memLoc,
                                  int memIndex)
                           throws TimeoutException,
                                  GatewayException,
                                  java.io.IOException,
                                  java.lang.InterruptedException
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

sendMessage

public boolean sendMessage(OutboundMessage msg)
                    throws TimeoutException,
                           GatewayException,
                           java.io.IOException,
                           java.lang.InterruptedException
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

sendMessages

public int sendMessages(java.util.Collection<OutboundMessage> msgList)
                 throws TimeoutException,
                        GatewayException,
                        java.io.IOException,
                        java.lang.InterruptedException
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

deleteMessage

public boolean deleteMessage(InboundMessage msg)
                      throws TimeoutException,
                             GatewayException,
                             java.io.IOException,
                             java.lang.InterruptedException
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

queryBalance

public float queryBalance()
                   throws TimeoutException,
                          GatewayException,
                          java.io.IOException,
                          java.lang.InterruptedException
Queries the gateway for remaining credit.

Returns:
Remaining credit.
Throws:
TimeoutException - The gateway did not respond in a timely manner.
GatewayException - A Gateway error occurred.
java.io.IOException - An IO error occurred.
java.lang.InterruptedException - The call was interrupted.

queryCoverage

public boolean queryCoverage(OutboundMessage msg)
                      throws TimeoutException,
                             GatewayException,
                             java.io.IOException,
                             java.lang.InterruptedException
Queries the gateway to see if a specific message and its recipient are covered. The given message is not sent out - it is just tested.

Parameters:
msg - The message to test.
Returns:
True is the recipient is covered by the network.
Throws:
TimeoutException - The gateway did not respond in a timely manner.
GatewayException - A Gateway error occurred.
java.io.IOException - An IO error occurred.
java.lang.InterruptedException - The call was interrupted.

queryMessage

public StatusReportMessage.DeliveryStatuses queryMessage(OutboundMessage msg)
                                                  throws TimeoutException,
                                                         GatewayException,
                                                         java.io.IOException,
                                                         java.lang.InterruptedException
Query the gateway for message delivery status.

Parameters:
msg - The OutboundMessage object to be checked.
Returns:
The delivery status. This is interpreted and mapped to the standard SMSLib status codes. For detailed information, check method getDeliveryErrorCode().
Throws:
TimeoutException - The gateway did not respond in a timely manner.
GatewayException - A Gateway error occurred.
java.io.IOException - An IO error occurred.
java.lang.InterruptedException - The call was interrupted.
See Also:
StatusReportMessage.DeliveryStatuses, getDeliveryErrorCode()

queryMessage

public StatusReportMessage.DeliveryStatuses queryMessage(java.lang.String refNo)
                                                  throws TimeoutException,
                                                         GatewayException,
                                                         java.io.IOException,
                                                         java.lang.InterruptedException
Query the gateway for message delivery status.

Parameters:
refNo - The reference number of a previously sent message to be checked.
Returns:
The delivery status. This is interpreted and mapped to the standard SMSLib status codes. For detailed information, check method getDeliveryErrorCode().
Throws:
TimeoutException - The gateway did not respond in a timely manner.
GatewayException - A Gateway error occurred.
java.io.IOException - An IO error occurred.
java.lang.InterruptedException - The call was interrupted.
See Also:
StatusReportMessage.DeliveryStatuses, getDeliveryErrorCode()

readPhonebook

public int readPhonebook(Phonebook phonebook)
                  throws TimeoutException,
                         GatewayException,
                         java.io.IOException,
                         java.lang.InterruptedException
Throws:
TimeoutException
GatewayException
java.io.IOException
java.lang.InterruptedException

getDeliveryErrorCode

public int getDeliveryErrorCode()
Returns the gateway-specific error code from the last queryMessage() call. Note that each call to queryMessage() resets this error.

Returns:
The error code - actual values depend on gateway used.
See Also:
queryMessage(OutboundMessage)

setDeliveryErrorCode

public void setDeliveryErrorCode(int error)

getRestartCount

public int getRestartCount()

getQueueSchedulingInterval

public abstract int getQueueSchedulingInterval()
Returns the Gateway Queue sending internal (in milliseconds). Should be defined in every actual Gateway implementation.

Returns:
The scheduling interval (in milliseconds).

sendUSSDCommand

public java.lang.String sendUSSDCommand(java.lang.String ussdCommand)
                                 throws GatewayException,
                                        TimeoutException,
                                        java.io.IOException,
                                        java.lang.InterruptedException
Throws:
GatewayException
TimeoutException
java.io.IOException
java.lang.InterruptedException

sendUSSDCommand

public java.lang.String sendUSSDCommand(java.lang.String ussdCommand,
                                        boolean interactive)
                                 throws GatewayException,
                                        TimeoutException,
                                        java.io.IOException,
                                        java.lang.InterruptedException
Throws:
GatewayException
TimeoutException
java.io.IOException
java.lang.InterruptedException

sendUSSDRequest

public boolean sendUSSDRequest(USSDRequest request)
                        throws GatewayException,
                               TimeoutException,
                               java.io.IOException,
                               java.lang.InterruptedException
Throws:
GatewayException
TimeoutException
java.io.IOException
java.lang.InterruptedException

SMSLib 3.5.3

(c) 2002-2011, http://smslib.org