org.opengts.db
Class CommandPacketHandler

java.lang.Object
  extended by org.opengts.util.AbstractClientPacketHandler
      extended by org.opengts.db.CommandPacketHandler
All Implemented Interfaces:
ClientPacketHandler
Direct Known Subclasses:
CommandHandler, CommandHandler, TemplateCommandHandler

public abstract class CommandPacketHandler
extends AbstractClientPacketHandler


Field Summary
static java.lang.String ARG_ACCOUNT
           
static java.lang.String[] ARG_ARG0
           
static java.lang.String ARG_ARG1
           
static java.lang.String ARG_ARG2
           
static java.lang.String ARG_ARG3
           
static java.lang.String ARG_ARG4
           
static java.lang.String ARG_ARG5
           
static java.lang.String ARG_ARG6
           
static java.lang.String ARG_ARG7
           
static java.lang.String ARG_ARG8
           
static java.lang.String ARG_ARG9
           
static java.lang.String ARG_CMDNAME
           
static java.lang.String ARG_CMDTYPE
           
static java.lang.String ARG_DEVICE
           
static java.lang.String ARG_IP
           
static java.lang.String ARG_LASTCONNECT
           
static java.lang.String ARG_MESSAGE
           
static java.lang.String ARG_PHONE
           
static java.lang.String ARG_RESULT
           
static java.lang.String ARG_SERVER
           
static java.lang.String ARG_USER
           
static java.lang.String[] CMD_ARGS
           
static java.lang.String INTERNCMD_COMMANDS
           
static java.lang.String INTERNCMD_SESSIONS
           
static java.lang.String INTERNCMD_STACKTRACE
           
 
Fields inherited from class org.opengts.util.AbstractClientPacketHandler
GMT_Timezone, PACKET_LEN_END_OF_STREAM, PACKET_LEN_LINE_TERMINATOR
 
Constructor Summary
CommandPacketHandler()
           
 
Method Summary
static RTProperties EncodeCommand(java.lang.String cmdType, java.lang.String cmdName, java.lang.String[] cmdArgs)
          Encode the specified command into an RTProperties instance
 int getActualPacketLength(byte[] packet, int packetLen)
          Callback to obtain the length of the next packet, based on the provided partial packet data.
static java.lang.String getFromEmailCommand(Account account)
           
static java.lang.String getFromEmailCommand(BasicPrivateLabel bpl)
           
 byte[] getHandlePacket(byte[] pktBytes)
          Parse the provided packet information, and return any response that should be sent back to the remote device
 int getResponsePort()
          Returns the client response port#
abstract  java.lang.String getServerName()
           
 boolean getTerminateSession()
          Callback to determine if the current session should be terminated
abstract  DCServerFactory.ResultCode handleCommand(Device device, java.lang.String cmdType, java.lang.String cmdName, java.lang.String[] args)
           
static void main(java.lang.String[] argv)
           
protected static byte[] RESULT(RTProperties rtp, DCServerFactory.ResultCode result)
           
 void sessionStarted(java.net.InetAddress inetAddr, boolean isTCP, boolean isText)
          Called when the session has started
 void sessionTerminated(java.lang.Throwable err, long readCount, long writeCount)
          Callback just before the session is terminated
static RTProperties setResult(RTProperties rtp, DCServerFactory.ResultCode result)
           
 void setTerminateSession()
          Sets the terminate-session state to true
 boolean terminateSession()
          Callback to determine if the current session should be terminated
static boolean validateAddress(java.lang.String addr)
           
static boolean validateAddresses(java.lang.String addrs)
           
 
Methods inherited from class org.opengts.util.AbstractClientPacketHandler
clearSavedEventCount, clearTerminateSession, equals, equalsSessionID, forceCloseTCPSession, GetDebugMode, getFinalPacket, getHostAddress, getInetAddress, getInitialPacket, getIPAddress, getLocalPort, getMaximumPacketLength, getMinimumPacketLength, getName, getPromptEnabled, getRemotePort, getSavedEventCount, getSequenceID, getSessionID, getSessionInfo, getSessionStartTime, getSessionStartTimeMS, getSessionType, getThreadName, hasHostAddress, hasIPAddress, hasSavedEvents, idleTimeoutInterrupt, incrementSavedEventCount, IsDebugMode, isDuplex, isInputStream, isTCP, isTextPackets, isUDP, printSessionStart, printSessionTerminated, SetDebugMode, setPromptEnabled, setSavedEventCount, setSessionInfo, setTerminateSession, tcpWrite
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARG_ACCOUNT

public static final java.lang.String ARG_ACCOUNT
See Also:
Constant Field Values

ARG_DEVICE

public static final java.lang.String ARG_DEVICE
See Also:
Constant Field Values

ARG_USER

public static final java.lang.String ARG_USER
See Also:
Constant Field Values

ARG_CMDTYPE

public static final java.lang.String ARG_CMDTYPE
See Also:
Constant Field Values

ARG_CMDNAME

public static final java.lang.String ARG_CMDNAME
See Also:
Constant Field Values

ARG_ARG0

public static final java.lang.String[] ARG_ARG0

ARG_ARG1

public static final java.lang.String ARG_ARG1
See Also:
Constant Field Values

ARG_ARG2

public static final java.lang.String ARG_ARG2
See Also:
Constant Field Values

ARG_ARG3

public static final java.lang.String ARG_ARG3
See Also:
Constant Field Values

ARG_ARG4

public static final java.lang.String ARG_ARG4
See Also:
Constant Field Values

ARG_ARG5

public static final java.lang.String ARG_ARG5
See Also:
Constant Field Values

ARG_ARG6

public static final java.lang.String ARG_ARG6
See Also:
Constant Field Values

ARG_ARG7

public static final java.lang.String ARG_ARG7
See Also:
Constant Field Values

ARG_ARG8

public static final java.lang.String ARG_ARG8
See Also:
Constant Field Values

ARG_ARG9

public static final java.lang.String ARG_ARG9
See Also:
Constant Field Values

CMD_ARGS

public static final java.lang.String[] CMD_ARGS

ARG_SERVER

public static final java.lang.String ARG_SERVER
See Also:
Constant Field Values

ARG_IP

public static final java.lang.String ARG_IP
See Also:
Constant Field Values

ARG_PHONE

public static final java.lang.String ARG_PHONE
See Also:
Constant Field Values

ARG_LASTCONNECT

public static final java.lang.String ARG_LASTCONNECT
See Also:
Constant Field Values

ARG_RESULT

public static final java.lang.String ARG_RESULT
See Also:
Constant Field Values

ARG_MESSAGE

public static final java.lang.String ARG_MESSAGE
See Also:
Constant Field Values

INTERNCMD_COMMANDS

public static final java.lang.String INTERNCMD_COMMANDS
See Also:
Constant Field Values

INTERNCMD_STACKTRACE

public static final java.lang.String INTERNCMD_STACKTRACE
See Also:
Constant Field Values

INTERNCMD_SESSIONS

public static final java.lang.String INTERNCMD_SESSIONS
See Also:
Constant Field Values
Constructor Detail

CommandPacketHandler

public CommandPacketHandler()
Method Detail

setResult

public static RTProperties setResult(RTProperties rtp,
                                     DCServerFactory.ResultCode result)

RESULT

protected static byte[] RESULT(RTProperties rtp,
                               DCServerFactory.ResultCode result)

getServerName

public abstract java.lang.String getServerName()

handleCommand

public abstract DCServerFactory.ResultCode handleCommand(Device device,
                                                         java.lang.String cmdType,
                                                         java.lang.String cmdName,
                                                         java.lang.String[] args)

getResponsePort

public int getResponsePort()
Description copied from class: AbstractClientPacketHandler
Returns the client response port#

Specified by:
getResponsePort in interface ClientPacketHandler
Overrides:
getResponsePort in class AbstractClientPacketHandler
Returns:
The port for UDP Datafram responses

sessionStarted

public void sessionStarted(java.net.InetAddress inetAddr,
                           boolean isTCP,
                           boolean isText)
Description copied from class: AbstractClientPacketHandler
Called when the session has started

Specified by:
sessionStarted in interface ClientPacketHandler
Overrides:
sessionStarted in class AbstractClientPacketHandler
Parameters:
inetAddr - The host IP address
isTCP - True if the connection is TCP
isText - True if the connection is text

sessionTerminated

public void sessionTerminated(java.lang.Throwable err,
                              long readCount,
                              long writeCount)
Description copied from class: AbstractClientPacketHandler
Callback just before the session is terminated

Specified by:
sessionTerminated in interface ClientPacketHandler
Overrides:
sessionTerminated in class AbstractClientPacketHandler

getActualPacketLength

public int getActualPacketLength(byte[] packet,
                                 int packetLen)
Description copied from class: AbstractClientPacketHandler
Callback to obtain the length of the next packet, based on the provided partial packet data.

Specified by:
getActualPacketLength in interface ClientPacketHandler
Overrides:
getActualPacketLength in class AbstractClientPacketHandler

setTerminateSession

public void setTerminateSession()
Description copied from class: AbstractClientPacketHandler
Sets the terminate-session state to true

Specified by:
setTerminateSession in interface ClientPacketHandler
Overrides:
setTerminateSession in class AbstractClientPacketHandler

getTerminateSession

public boolean getTerminateSession()
Description copied from class: AbstractClientPacketHandler
Callback to determine if the current session should be terminated

Specified by:
getTerminateSession in interface ClientPacketHandler
Overrides:
getTerminateSession in class AbstractClientPacketHandler
Returns:
True if the session should terminate

terminateSession

public boolean terminateSession()
Description copied from class: AbstractClientPacketHandler
Callback to determine if the current session should be terminated

Specified by:
terminateSession in interface ClientPacketHandler
Overrides:
terminateSession in class AbstractClientPacketHandler

getHandlePacket

public byte[] getHandlePacket(byte[] pktBytes)
Description copied from class: AbstractClientPacketHandler
Parse the provided packet information, and return any response that should be sent back to the remote device

Specified by:
getHandlePacket in interface ClientPacketHandler
Specified by:
getHandlePacket in class AbstractClientPacketHandler
Parameters:
pktBytes - The packet
Returns:
The response

EncodeCommand

public static RTProperties EncodeCommand(java.lang.String cmdType,
                                         java.lang.String cmdName,
                                         java.lang.String[] cmdArgs)
Encode the specified command into an RTProperties instance

Parameters:
cmdType - The command type
cmdName - The command name
cmdArgs - The array of command arguments
Returns:
The encoded RTProperties instance

validateAddress

public static boolean validateAddress(java.lang.String addr)

validateAddresses

public static boolean validateAddresses(java.lang.String addrs)

getFromEmailCommand

public static java.lang.String getFromEmailCommand(Account account)

getFromEmailCommand

public static java.lang.String getFromEmailCommand(BasicPrivateLabel bpl)

main

public static void main(java.lang.String[] argv)