com.mckoi.database
Class StatementTree

java.lang.Object
  extended by com.mckoi.database.StatementTree
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public final class StatementTree
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

A serializable container class for a parsed query language statement. The structure of the tree is entirely dependant on the grammar that was used to create the tree. This object is a convenient form that can be cached and serialized to be stored.

Think of this as the model of a query after the grammar has been parsed and before it is evaluated.

Author:
Tobias Downer
See Also:
Serialized Form

Constructor Summary
StatementTree(java.lang.String statement_class)
          Constructs the StatementTree.
 
Method Summary
 java.lang.Object clone()
          Performs a deep clone of this object, calling 'clone' on any elements that are mutable or shallow copying immutable members.
static java.lang.Object cloneSingleObject(java.lang.Object entry)
          Clones a single object.
 boolean getBoolean(java.lang.String entry_name)
          Gets a boolean entry from the statement tree.
 java.lang.String getClassName()
          Gets the interpreter class that services this tree.
 int getInt(java.lang.String entry_name)
          Gets an integer entry from the statement tree.
 java.lang.Object getObject(java.lang.String entry_name)
          Gets an object entry from the statement tree.
 void prepareAllExpressions(ExpressionPreparer preparer)
          For each expression in this StatementTree this method will call the 'prepare' method in each expression.
 void putBoolean(java.lang.String entry_name, boolean b)
          Puts a boolean into the statement tree map.
 void putInt(java.lang.String entry_name, int v)
          Puts an integer into the statement tree map.
 void putObject(java.lang.String entry_name, java.lang.Object ob)
          Puts a new entry into the statement tree map.
 java.lang.String toString()
          For diagnostic.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StatementTree

public StatementTree(java.lang.String statement_class)
Constructs the StatementTree.

Parameters:
statement_class - the name of the class that interpretes this statement (eg. com.mckoi.database.interpret.Select).
Method Detail

putObject

public void putObject(java.lang.String entry_name,
                      java.lang.Object ob)
Puts a new entry into the statement tree map.


putBoolean

public void putBoolean(java.lang.String entry_name,
                       boolean b)
Puts a boolean into the statement tree map.


putInt

public void putInt(java.lang.String entry_name,
                   int v)
Puts an integer into the statement tree map.


getObject

public java.lang.Object getObject(java.lang.String entry_name)
Gets an object entry from the statement tree.


getBoolean

public boolean getBoolean(java.lang.String entry_name)
Gets a boolean entry from the statement tree.


getInt

public int getInt(java.lang.String entry_name)
Gets an integer entry from the statement tree.


getClassName

public java.lang.String getClassName()
Gets the interpreter class that services this tree.


prepareAllExpressions

public void prepareAllExpressions(ExpressionPreparer preparer)
                           throws DatabaseException
For each expression in this StatementTree this method will call the 'prepare' method in each expression. The prepare method is intended to mutate each expression so that references can be qualified, sub-queries can be resolved, and variable substitutions can be substituted.

Throws:
DatabaseException

cloneSingleObject

public static java.lang.Object cloneSingleObject(java.lang.Object entry)
                                          throws java.lang.CloneNotSupportedException
Clones a single object.

Throws:
java.lang.CloneNotSupportedException

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Performs a deep clone of this object, calling 'clone' on any elements that are mutable or shallow copying immutable members.

Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

toString

public java.lang.String toString()
For diagnostic.

Overrides:
toString in class java.lang.Object