com.softwareag.tamino.db.api.command
Class TCommandStatement

java.lang.Object
  extended by com.softwareag.tamino.db.api.command.TCommandStatement
All Implemented Interfaces:
java.lang.Cloneable

public class TCommandStatement
extends java.lang.Object
implements java.lang.Cloneable

Class representing Tamino specific command statements. Each command statement consists of a sequence of TCommandItemPair objects. The first among these is a TCommand/TCommandValue instance pair whereas the others represent TCommandParameter/TCommandParameterValue pair instances. As a consequence Tamino specific commands do not have to be written as encoded string but rather as TCommandStatement instances. The following example depicts a scenario for a XQL statement:

   // Instantiate the command statement for xql
   TCommandStatement commandStatement = new TCommandStatement( TCommand.XQL , new TCommandValue( "Telephone[Lastname=\"Mustermann\"]" ) );
   commandStatement.addCommandParameter( TCommandParameter.SESSION_ID  , new TCommandParameterValue("6") );
   commandStatement.addCommandParameter( TCommandParameter.SESSION_KEY , new TCommandParameterValue("65132" );
   System.out.println( "Statement:" commandStatement.toString() );
   ...
   The output for this code snippet is:
   Statement: _xql(1,5)=Telephone[Lastname="Mustermann"]&_sessionid=6&_sessionkey=65132
 

Version:
$Revision: 1.17 $
Author:
Marcus Schreyer

Constructor Summary
TCommandStatement()
          Initializes an empty command statement.
TCommandStatement(TCommand mainCommand, TCommandValue mainCommandValue)
          Initializes the command statement with the given main command and its corresponding value.
 
Method Summary
 void addCommand(TCommand command, TCommandValue commandValue)
          Adds another command/value pair.
 void addCommandParameter(TCommandParameter commandParameter, TCommandParameterValue commandParameterValue)
          Adds a command parameter and its corresponding value to the statement.
 void clear()
          Clears the command statements internal command/value and commandparameter/value representation.
 java.lang.Object clone()
          Makes a clone of the command statement.
 TCommand getCommand()
          Returns the main command which just is the first command that has been added.
 TCommandValue getCommandValue()
          Returns the main command value which just is the first command value that has been added.
 java.util.Iterator<TCommandItemPair> getIterator()
          Gets the iterator for the navigation over the TCommandItemPair instances stored within the TCommandStatement.
 boolean hasSessionState()
           
protected  boolean isGiven()
          Indicates if the command statement is currently given.
 void removeCommandParameter(TCommandItemPair key)
          Removes a command parameter and its corresponding value to the statement.
 java.lang.String toString()
          Gets the string representation of the command statement.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TCommandStatement

public TCommandStatement()
Initializes an empty command statement.


TCommandStatement

public TCommandStatement(TCommand mainCommand,
                         TCommandValue mainCommandValue)
Initializes the command statement with the given main command and its corresponding value.

Parameters:
command - is the Tamino specific command verb abstraction.
commandValue - directly relates to the value for the command. Should be set according to the Tamino documentation.
Method Detail

addCommand

public void addCommand(TCommand command,
                       TCommandValue commandValue)
Adds another command/value pair. Please note that a command statement can contain more than a single command/value pair.Anyway the first command added to the statement is considered as the main command.

Parameters:
command - is the Tamino specific command verb abstraction.
commandValue - directly relates to the value for the command. Should be set according to the Tamino documentation.

addCommandParameter

public void addCommandParameter(TCommandParameter commandParameter,
                                TCommandParameterValue commandParameterValue)
Adds a command parameter and its corresponding value to the statement. An already existing command parameter will NOT be overriden.

Parameters:
commandParameter - is the Tamino specific command parameter abstraction.
commandParameterValue - directly relates to the value for the command parameter. Should be set according to the Tamino documentation.

removeCommandParameter

public void removeCommandParameter(TCommandItemPair key)
Removes a command parameter and its corresponding value to the statement.

Parameters:
key - is the Tamino specific command parameter and its value.

getIterator

public java.util.Iterator<TCommandItemPair> getIterator()
Gets the iterator for the navigation over the TCommandItemPair instances stored within the TCommandStatement.

Returns:
iterator for navigation over TCommandItemPair instances.

getCommand

public TCommand getCommand()
Returns the main command which just is the first command that has been added. If none is given yet null is returned.

Returns:
the TCommand instance that has been added as the first command, null if none has been added yet.

getCommandValue

public TCommandValue getCommandValue()
Returns the main command value which just is the first command value that has been added. If none is given yet null is returned.

Returns:
the TCommandValue instance that has been added as the first command, null if none has been added yet.

toString

public java.lang.String toString()
Gets the string representation of the command statement.

Overrides:
toString in class java.lang.Object
Returns:
the String representation of the entire command statement.

clear

public void clear()
Clears the command statements internal command/value and commandparameter/value representation.


clone

public java.lang.Object clone()
Makes a clone of the command statement.

Overrides:
clone in class java.lang.Object
Returns:
the shallow copy of this object

isGiven

protected boolean isGiven()
Indicates if the command statement is currently given. This is the case when at least one command has been set.


hasSessionState

public boolean hasSessionState()


Copyright (c) 2013 Software AG. All Rights Reserved.