com.akiban.sql.parser
Class QueryTreeNode

java.lang.Object
  extended by com.akiban.sql.parser.QueryTreeNode
All Implemented Interfaces:
Visitable
Direct Known Subclasses:
IndexColumn, IndexHintNode, JavaValueNode, OrderedColumn, PrivilegeNode, QueryTreeNodeList, ResultSetNode, StatementNode, TableElementNode, TableName, TablePrivilegesNode, ValueNode, WindowNode

public abstract class QueryTreeNode
extends Object
implements Visitable

QueryTreeNode is the root class for all query tree nodes. All query tree nodes inherit from QueryTreeNode.


Field Summary
static int AUTOINCREMENT_CREATE_MODIFY
           
static int AUTOINCREMENT_INC_INDEX
           
static int AUTOINCREMENT_IS_AUTOINCREMENT_INDEX
           
static int AUTOINCREMENT_START_INDEX
           
 
Constructor Summary
QueryTreeNode()
           
 
Method Summary
 Visitable accept(Visitor v)
          Accept a visitor, and call v.visit() on child nodes as necessary.
 Object convertDefaultNode(DataTypeDescriptor typeDescriptor)
          Translate a Default node into a default value, given a type descriptor.
 void copyFrom(QueryTreeNode other)
          Fill this node with a deep copy of the given node.
protected static void debugFlush()
          Flush the debug stream out
static void debugPrint(String outputString)
          Print a String for debugging
static String formatNodeString(String nodeString, int depth)
          Format a node that has been converted to a String for printing as part of a tree.
 int getBeginOffset()
          Gets the beginning offset of the SQL substring which this query node represents.
static Writer getDebugOutput()
           
 int getEndOffset()
          Gets the ending offset of the SQL substring which this query node represents.
 NodeFactory getNodeFactory()
          Gets the NodeFactory for this database.
 int getNodeType()
           
 ConstantNode getNullNode(DataTypeDescriptor type)
          Get a ConstantNode to represent a typed null value.
 SQLParserContext getParserContext()
          Get the current parser context.
protected  int getStatementType()
          Return the type of statement, something from StatementType.
 Object getUserData()
          Get the user data associated with this node.
 void init(Object arg1)
          Initialize a query tree node.
 void init(Object arg1, Object arg2)
          Initialize a query tree node.
 void init(Object arg1, Object arg2, Object arg3)
          Initialize a query tree node.
 void init(Object arg1, Object arg2, Object arg3, Object arg4)
          Initialize a query tree node.
 void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
          Initialize a query tree node.
 void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6)
          Initialize a query tree node.
 void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)
          Initialize a query tree node.
 void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8)
          Initialize a query tree node.
 void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9)
          Initialize a query tree node.
 void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10)
          Initialize a query tree node.
 void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11)
          Initialize a query tree node.
 void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12)
          Initialize a query tree node.
 void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13)
          Initialize a query tree node.
 void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)
          Initialize a query tree node.
protected  boolean isInstanceOf(int nodeType)
          For final nodes, return whether or not the node represents the specified nodeType.
static TableName makeTableName(NodeFactory nodeFactory, SQLParserContext parserContext, String schemaName, String flatName)
           
 TableName makeTableName(String schemaName, String flatName)
           
protected  String nodeHeader()
          Return header information for debug printing of this query tree node.
 void printLabel(int depth, String label)
          Print the given label at the given indentation depth.
 void printSubNodes(int depth)
          Print the sub-nodes of this node.
 void setBeginOffset(int beginOffset)
          Sets the beginning offset of the SQL substring which this query node represents.
static void setDebugOutput(Writer writer)
           
 void setEndOffset(int endOffset)
          Sets the ending offset of the SQL substring which this query node represents.
 void setNodeType(int nodeType)
          Set the node type for this node.
 void setParserContext(SQLParserContext pc)
          Set the parser context for this node.
 void setUserData(Object userData)
          Set the user data associated with this node.
 void stackPrint()
          Print call stack for debug purposes
 String toString()
          Format this node as a string Each sub-class of QueryTreeNode should implement its own toString() method.
 void treePrint()
          Print this tree for debugging purposes.
 void treePrint(int depth)
          Print this tree for debugging purposes.
 void treePrint(Writer writer)
          Print this tree to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AUTOINCREMENT_START_INDEX

public static final int AUTOINCREMENT_START_INDEX
See Also:
Constant Field Values

AUTOINCREMENT_INC_INDEX

public static final int AUTOINCREMENT_INC_INDEX
See Also:
Constant Field Values

AUTOINCREMENT_IS_AUTOINCREMENT_INDEX

public static final int AUTOINCREMENT_IS_AUTOINCREMENT_INDEX
See Also:
Constant Field Values

AUTOINCREMENT_CREATE_MODIFY

public static final int AUTOINCREMENT_CREATE_MODIFY
See Also:
Constant Field Values
Constructor Detail

QueryTreeNode

public QueryTreeNode()
Method Detail

setParserContext

public void setParserContext(SQLParserContext pc)
Set the parser context for this node.

Parameters:
pc - The SQLParserContext

getParserContext

public SQLParserContext getParserContext()
Get the current parser context.

Returns:
The current SQLParserContext.

setUserData

public void setUserData(Object userData)
Set the user data associated with this node.


getUserData

public Object getUserData()
Get the user data associated with this node.


getNodeFactory

public NodeFactory getNodeFactory()
Gets the NodeFactory for this database.

Returns:
the node factory for this parser.

copyFrom

public void copyFrom(QueryTreeNode other)
              throws StandardException
Fill this node with a deep copy of the given node. Specific node classes must override to deep copy their data.

Throws:
StandardException

getBeginOffset

public int getBeginOffset()
Gets the beginning offset of the SQL substring which this query node represents.

Returns:
The beginning offset of the SQL substring. -1 means unknown.

setBeginOffset

public void setBeginOffset(int beginOffset)
Sets the beginning offset of the SQL substring which this query node represents.

Parameters:
beginOffset - The beginning offset of the SQL substring.

getEndOffset

public int getEndOffset()
Gets the ending offset of the SQL substring which this query node represents.

Returns:
The ending offset of the SQL substring. -1 means unknown.

setEndOffset

public void setEndOffset(int endOffset)
Sets the ending offset of the SQL substring which this query node represents.

Parameters:
endOffset - The ending offset of the SQL substring.

nodeHeader

protected String nodeHeader()
Return header information for debug printing of this query tree node.

Returns:
Header information for debug printing of this query tree node.

formatNodeString

public static String formatNodeString(String nodeString,
                                      int depth)
Format a node that has been converted to a String for printing as part of a tree. This method indents the String to the given depth by inserting tabs at the beginning of the string, and also after every newline.

Parameters:
nodeString - The node formatted as a String
depth - The depth to indent the given node
Returns:
The node String reformatted with tab indentation

treePrint

public void treePrint()
Print this tree for debugging purposes. This recurses through all the sub-nodes and prints them indented by their depth in the tree.


treePrint

public void treePrint(Writer writer)
Print this tree to the given stream.


stackPrint

public void stackPrint()
Print call stack for debug purposes


treePrint

public void treePrint(int depth)
Print this tree for debugging purposes. This recurses through all the sub-nodes and prints them indented by their depth in the tree, starting with the given indentation.

Parameters:
depth - The depth of this node in the tree, thus, the amount to indent it when printing it.

getDebugOutput

public static Writer getDebugOutput()

setDebugOutput

public static void setDebugOutput(Writer writer)

debugPrint

public static void debugPrint(String outputString)
Print a String for debugging

Parameters:
outputString - The String to print

debugFlush

protected static void debugFlush()
Flush the debug stream out


printSubNodes

public void printSubNodes(int depth)
Print the sub-nodes of this node. Each sub-class of QueryTreeNode is expected to provide its own printSubNodes() method. In each case, it calls super.printSubNodes(), passing along its depth, to get the sub-nodes of the super-class. Then it prints its own sub-nodes by calling treePrint() on each of its members that is a type of QueryTreeNode. In each case where it calls treePrint(), it should pass "depth + 1" to indicate that the sub-node should be indented one more level when printing. Also, it should call printLabel() to print the name of each sub-node before calling treePrint() on the sub-node, so that the reader of the printed tree can tell what the sub-node is.

Parameters:
depth - The depth to indent the sub-nodes

toString

public String toString()
Format this node as a string Each sub-class of QueryTreeNode should implement its own toString() method. In each case, toString() should format the class members that are not sub-types of QueryTreeNode (printSubNodes() takes care of following the references to sub-nodes, and toString() takes care of all members that are not sub-nodes). Newlines should be used liberally - one good way to do this is to have a newline at the end of each formatted member. It's also a good idea to put the name of each member in front of the formatted value. For example, the code might look like: "memberName: " + memberName + "\n" + ... List members containing subclasses of QueryTreeNode should subclass QueryTreeNodeList. Such subclasses form a special case: These classes should not implement printSubNodes, since there is generic handling in QueryTreeNodeList. They should only implement toString if they contain additional members.

Overrides:
toString in class Object
Returns:
This node formatted as a String

printLabel

public void printLabel(int depth,
                       String label)
Print the given label at the given indentation depth.

Parameters:
depth - The depth of indentation to use when printing the label
label - The String to print

setNodeType

public void setNodeType(int nodeType)
Set the node type for this node.

Parameters:
nodeType - The node type.

getNodeType

public int getNodeType()

isInstanceOf

protected boolean isInstanceOf(int nodeType)
For final nodes, return whether or not the node represents the specified nodeType.

Parameters:
nodeType - The nodeType of interest.
Returns:
Whether or not the node represents the specified nodeType.

accept

public final Visitable accept(Visitor v)
                       throws StandardException
Accept a visitor, and call v.visit() on child nodes as necessary. Sub-classes should not override this method, but instead override the acceptChildren(Visitor) method.

Specified by:
accept in interface Visitable
Parameters:
v - the visitor
Throws:
StandardException - on error

getStatementType

protected int getStatementType()
Return the type of statement, something from StatementType.

Returns:
the type of statement

getNullNode

public ConstantNode getNullNode(DataTypeDescriptor type)
                         throws StandardException
Get a ConstantNode to represent a typed null value.

Parameters:
type - Type of the null node.
Returns:
A ConstantNode with the specified type, and a value of null
Throws:
StandardException - Thrown on error

convertDefaultNode

public Object convertDefaultNode(DataTypeDescriptor typeDescriptor)
                          throws StandardException
Translate a Default node into a default value, given a type descriptor.

Parameters:
typeDescriptor - A description of the required data type.
Throws:
StandardException - Thrown on error

init

public void init(Object arg1)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2,
                 Object arg3)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2,
                 Object arg3,
                 Object arg4)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2,
                 Object arg3,
                 Object arg4,
                 Object arg5)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2,
                 Object arg3,
                 Object arg4,
                 Object arg5,
                 Object arg6)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2,
                 Object arg3,
                 Object arg4,
                 Object arg5,
                 Object arg6,
                 Object arg7)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2,
                 Object arg3,
                 Object arg4,
                 Object arg5,
                 Object arg6,
                 Object arg7,
                 Object arg8)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2,
                 Object arg3,
                 Object arg4,
                 Object arg5,
                 Object arg6,
                 Object arg7,
                 Object arg8,
                 Object arg9)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2,
                 Object arg3,
                 Object arg4,
                 Object arg5,
                 Object arg6,
                 Object arg7,
                 Object arg8,
                 Object arg9,
                 Object arg10)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2,
                 Object arg3,
                 Object arg4,
                 Object arg5,
                 Object arg6,
                 Object arg7,
                 Object arg8,
                 Object arg9,
                 Object arg10,
                 Object arg11)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2,
                 Object arg3,
                 Object arg4,
                 Object arg5,
                 Object arg6,
                 Object arg7,
                 Object arg8,
                 Object arg9,
                 Object arg10,
                 Object arg11,
                 Object arg12)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2,
                 Object arg3,
                 Object arg4,
                 Object arg5,
                 Object arg6,
                 Object arg7,
                 Object arg8,
                 Object arg9,
                 Object arg10,
                 Object arg11,
                 Object arg12,
                 Object arg13)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

init

public void init(Object arg1,
                 Object arg2,
                 Object arg3,
                 Object arg4,
                 Object arg5,
                 Object arg6,
                 Object arg7,
                 Object arg8,
                 Object arg9,
                 Object arg10,
                 Object arg11,
                 Object arg12,
                 Object arg13,
                 Object arg14)
          throws StandardException
Initialize a query tree node.

Throws:
StandardException - Thrown on error

makeTableName

public TableName makeTableName(String schemaName,
                               String flatName)
                        throws StandardException
Throws:
StandardException

makeTableName

public static TableName makeTableName(NodeFactory nodeFactory,
                                      SQLParserContext parserContext,
                                      String schemaName,
                                      String flatName)
                               throws StandardException
Throws:
StandardException


Copyright © 2013 Akiban Technologies, Inc. All rights reserved.