edu.sdsc.inca.protocol
Class Statement

java.lang.Object
  extended byedu.sdsc.inca.protocol.Statement

public class Statement
extends java.lang.Object

Author:
Cathie Olschanowsky, Jim Hayes A statements is the most basic part of the Inca Protocol. Its format is CMD [SP DATA]

Description: Assists in sending/receiving and parsing the Inca protocol.


Constructor Summary
Statement()
          Creates a statement with no command or data.
Statement(char[] bytes)
          Creates a Statment from a byte array that contains both the command and optional data.
Statement(char[] cmd, char[] data)
          Create a new statement object from separate command and data arrays.
Statement(java.lang.String stmt)
          Creates a Statment from a string that contains both the command and optional data.
Statement(java.lang.String cmd, java.lang.String data)
          Create a new statement object from separate command and data strings.
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares two statements for equality.
 char[] getCmd()
          Retrieve the cmd.
 char[] getData()
          retrieve the data.
static Statement getErrorStatement(java.lang.String data)
          Creates a new ERROR message with the given error message.
static Statement getOkStatement(java.lang.String data)
          Creates a new OK message with the given payload.
static Statement getStartStatement()
          Creates a new Start message with the current Inca Protocol Version.
static java.lang.String getVersion()
          Returns the Inca protocol version.
 void setCmd(char[] cmd)
          set the cmd.
 void setData(char[] data)
          set the data.
 char[] toChars()
          Converts the statement to bytes that can be sent across the wire.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Statement

public Statement()
Creates a statement with no command or data.


Statement

public Statement(char[] bytes)
Creates a Statment from a byte array that contains both the command and optional data.

Parameters:
bytes - the raw bytes

Statement

public Statement(char[] cmd,
                 char[] data)
Create a new statement object from separate command and data arrays.

Parameters:
cmd - the characters that make up the command
data - the option characters that make up the data

Statement

public Statement(java.lang.String stmt)
Creates a Statment from a string that contains both the command and optional data.


Statement

public Statement(java.lang.String cmd,
                 java.lang.String data)
Create a new statement object from separate command and data strings.

Parameters:
cmd - the command string
data - the optional data string
Method Detail

getCmd

public char[] getCmd()
Retrieve the cmd.

Returns:
a char[] that is the cmd part of the statment

setCmd

public void setCmd(char[] cmd)
set the cmd.

Parameters:
cmd - the raw characters for the command

getData

public char[] getData()
retrieve the data.

Returns:
the data part of the statement

setData

public void setData(char[] data)
set the data.

Parameters:
data - raw characters for data

toChars

public char[] toChars()
Converts the statement to bytes that can be sent across the wire.

Returns:
the whole statement as characters

equals

public boolean equals(java.lang.Object o)
Compares two statements for equality.

Returns:
true if the two Statements are equivalent

getErrorStatement

public static Statement getErrorStatement(java.lang.String data)
Creates a new ERROR message with the given error message.

Returns:
A statement object contining the CMD ERROR and the message

getOkStatement

public static Statement getOkStatement(java.lang.String data)
Creates a new OK message with the given payload.


getStartStatement

public static Statement getStartStatement()
Creates a new Start message with the current Inca Protocol Version.

Returns:
The start message with current version.

getVersion

public static java.lang.String getVersion()
Returns the Inca protocol version.

Returns:
Inca protocol version

toString

public java.lang.String toString()