stella.net.tpl
Class TplCommand

java.lang.Object
  extended by stella.net.tpl.TplCommand
Direct Known Subclasses:
TplAbort, TplDisconnect, TplGet, TplSet

public abstract class TplCommand
extends Object

The base TPL-Command. Has a unique command-id, from which the hash-code is derived and supplies basic methods for checking the completeness state.


Field Summary
static String ABORTED
          The command has been aborted.
static String ABORTEDBY
          The command was aborted by an other command.
private  boolean acknowledged
          True if command was acknowledged with a 'COMMAND state' event.
static String BUSY
          The get/set value error signaling busy callback execution.
private  Date commenced
          The time-stamp the commands commence-method has been called.
static String COMPLETE
          The command has completed the callback execution.
private  boolean completed
          True if command was completed with a 'COMMAND state' event.
static String DENIED
          The get/set value error access not granted.
static String DIMENSION
          The get/set value error dimensional error on array.
static String ERROR
          General indicator for errors.
static String FAILED
          The error signaling failed callback execution.
private  int id
          The command id.
static String IDBUSY
          The error signaling id-collision.
private  Object info
          Unparsed additional info.
static String INVALID
          The get/set value error signaling invalid struct definition.
static String LOCKED
          The get/set value error signaling failed callback lock acquire.
static String NOTRUNNING
          The abort can not commence, requested command not running.
static String OK
          General indicator for okay.
static String OVERRUN
          The error signaling too complex commands.
static String RANGE
          The set value error for not-in-allowed-range.
private  boolean sending
          True, if command is sending.
private  Object state
          Any parsable status out of a TplEvent.
static String SYNTAX
          The error signaling syntax errors.
static String TIMEOUT
          The error signaling timeout-on-command.
static String TOOMANY
          The error signaling too many commands.
static String TYPE
          The set value error for non-compatible type.
static String UNKNOWN
          The get/set value error signaling unknown variable name.
 
Constructor Summary
protected TplCommand(int unique)
          Constructs a new TPL-Command with the specific id.
 
Method Summary
 String commenceCommand()
          Commences the command.
abstract  String getCommandLead()
          Returns the part of the command that is the command lead.
 Date getCommencedWhen()
          Returns the date this command was commenced.
 int getID()
          Returns the command id.
 Object getInfo()
          Returns unparsed additional info if available.Interpretation depends on the state the command was in.
 Object getState()
          Returns the status of this command.
 int hashCode()
          Returns the id as the hash-code.
 boolean isAcknowledged()
          Returns true if this command was acknowledged.
 boolean isCompleted()
          Returns true if this command was completed.
 boolean isSending()
          Returns rtue if this command is sending.
 boolean parseTplEvent(TplEvent reply)
          Takes a TPL-Event of command and parses errors and completeness state out of it.
protected  void setInfo(Object parsedinfo)
          Subclasses may change the content of the info field.
protected  void setState(Object parsedinfo)
          Subclasses may change the content of the state field due to a confusing protocol this was added rather late.
 String toString()
          Returns the string representation of the command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

OK

public static final String OK
General indicator for okay.

See Also:
Constant Field Values

ERROR

public static final String ERROR
General indicator for errors.

See Also:
Constant Field Values

COMPLETE

public static final String COMPLETE
The command has completed the callback execution.

See Also:
Constant Field Values

FAILED

public static final String FAILED
The error signaling failed callback execution.

See Also:
Constant Field Values

ABORTED

public static final String ABORTED
The command has been aborted.

See Also:
Constant Field Values

ABORTEDBY

public static final String ABORTEDBY
The command was aborted by an other command.

See Also:
Constant Field Values

UNKNOWN

public static final String UNKNOWN
The get/set value error signaling unknown variable name.

See Also:
Constant Field Values

INVALID

public static final String INVALID
The get/set value error signaling invalid struct definition.

See Also:
Constant Field Values

DENIED

public static final String DENIED
The get/set value error access not granted.

See Also:
Constant Field Values

TYPE

public static final String TYPE
The set value error for non-compatible type.

See Also:
Constant Field Values

RANGE

public static final String RANGE
The set value error for not-in-allowed-range.

See Also:
Constant Field Values

DIMENSION

public static final String DIMENSION
The get/set value error dimensional error on array.

See Also:
Constant Field Values

BUSY

public static final String BUSY
The get/set value error signaling busy callback execution.

See Also:
Constant Field Values

LOCKED

public static final String LOCKED
The get/set value error signaling failed callback lock acquire.

See Also:
Constant Field Values

IDBUSY

public static final String IDBUSY
The error signaling id-collision.

See Also:
Constant Field Values

SYNTAX

public static final String SYNTAX
The error signaling syntax errors.

See Also:
Constant Field Values

TIMEOUT

public static final String TIMEOUT
The error signaling timeout-on-command.

See Also:
Constant Field Values

OVERRUN

public static final String OVERRUN
The error signaling too complex commands.

See Also:
Constant Field Values

TOOMANY

public static final String TOOMANY
The error signaling too many commands.

See Also:
Constant Field Values

NOTRUNNING

public static final String NOTRUNNING
The abort can not commence, requested command not running.

See Also:
Constant Field Values

id

private int id
The command id. Must be unique for all active commands.


commenced

private Date commenced
The time-stamp the commands commence-method has been called.


sending

private boolean sending
True, if command is sending.


acknowledged

private boolean acknowledged
True if command was acknowledged with a 'COMMAND state' event.


completed

private boolean completed
True if command was completed with a 'COMMAND state' event.


state

private Object state
Any parsable status out of a TplEvent.


info

private Object info
Unparsed additional info. Subclasses may override and provide extra.

Constructor Detail

TplCommand

protected TplCommand(int unique)
Constructs a new TPL-Command with the specific id.

Method Detail

hashCode

public int hashCode()
Returns the id as the hash-code.

Overrides:
hashCode in class Object

getID

public int getID()
Returns the command id.


isSending

public boolean isSending()
Returns rtue if this command is sending.


isAcknowledged

public boolean isAcknowledged()
Returns true if this command was acknowledged.


isCompleted

public boolean isCompleted()
Returns true if this command was completed.


getCommencedWhen

public Date getCommencedWhen()
Returns the date this command was commenced. Can be used to trace time-outs on acknowledge or complete.


getState

public Object getState()
Returns the status of this command. Interpretation depends on the state it was in.


getInfo

public Object getInfo()
Returns unparsed additional info if available.Interpretation depends on the state the command was in.


setInfo

protected void setInfo(Object parsedinfo)
Subclasses may change the content of the info field.


setState

protected void setState(Object parsedinfo)
Subclasses may change the content of the state field due to a confusing protocol this was added rather late.


commenceCommand

public String commenceCommand()
Commences the command. The command is converted into a string and its status is set to active.


toString

public String toString()
Returns the string representation of the command. This is the ID, followed by a space and the command lead.

Overrides:
toString in class Object

getCommandLead

public abstract String getCommandLead()
Returns the part of the command that is the command lead. This is the part with the actual information like GET or SET plus variable name.


parseTplEvent

public boolean parseTplEvent(TplEvent reply)
                      throws ParseException
Takes a TPL-Event of command and parses errors and completeness state out of it.

Returns:
True, if the event belongs to this command.
Throws:
ParseException