Package com.mckoi.database
Class StatementTree
- java.lang.Object
-
- 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.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashMap
map
A map that maps from the name of the tree element to the object that contains information about.(package private) static long
serialVersionUID
private java.lang.String
statement_class
The class of statement this is.
-
Constructor Summary
Constructors Constructor Description StatementTree(java.lang.String statement_class)
Constructs the StatementTree.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.private void
prepareExpressionsInObject(java.lang.Object v, ExpressionPreparer preparer)
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.
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
-
statement_class
private java.lang.String statement_class
The class of statement this is. This is set to one of the query objects from the com.mckoi.database.interpret package. For example, if this is a select statement then it points to 'com.mckoi.database.interpret.Select'.
-
map
private java.util.HashMap map
A map that maps from the name of the tree element to the object that contains information about. For example, if this is an SQL SELECT statement then entries in this map may be;"columns" -> sql.SelectColumn[] "distinct" -> new Boolean(true)
-
-
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
-
prepareExpressionsInObject
private void prepareExpressionsInObject(java.lang.Object v, ExpressionPreparer preparer) throws DatabaseException
- 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 classjava.lang.Object
- Throws:
java.lang.CloneNotSupportedException
-
toString
public java.lang.String toString()
For diagnostic.- Overrides:
toString
in classjava.lang.Object
-
-