|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectantlr.BaseAST
antlr.CommonAST
org.apache.jdo.impl.jdoql.jdoqlc.JDOQLAST
org.apache.jdo.impl.jdoql.tree.NodeImpl
org.apache.jdo.impl.jdoql.tree.Tree
This node represents the root of a query tree. You can use it to factorize this node's children, as there are candidate class, declarations, filter expression and ordering expressions.
| Nested Class Summary | |
(package private) static class |
Tree.JavaKeyWords
|
| Field Summary | |
(package private) CandidateClass |
candidateClass
|
(package private) Expression |
filter
|
(package private) static Tree.JavaKeyWords |
javaKeyWords
|
(package private) java.util.List |
orderings
|
(package private) java.util.List |
parameterList
|
(package private) java.util.Map |
parameterMap
|
(package private) java.lang.String |
serializedCandidateClassName
|
(package private) java.util.Map |
variableMap
|
| Fields inherited from class org.apache.jdo.impl.jdoql.tree.NodeImpl |
children, clazz, msg, object, parent |
| Fields inherited from class org.apache.jdo.impl.jdoql.jdoqlc.JDOQLAST |
column, line, typeInfo |
| Fields inherited from class antlr.CommonAST |
|
| Fields inherited from class antlr.BaseAST |
down, right |
| Constructor Summary | |
Tree()
The noarg constructor is called by persistence manager internal. |
|
Tree(CandidateClass candidateClass,
ParameterDecl parameterDeclarations,
VariableDecl variableDeclarations,
OrderingExpr orderingExpressions,
Expr filter)
This constructor is called by semantic analysis only. |
|
| Method Summary | |
void |
addAscendingOrdering(Expression expression)
Adds an ascending ordering expression to this query tree. |
void |
addDescendingOrdering(Expression expression)
Adds an descending ordering expression to this query tree. |
void |
arrive(NodeVisitor visitor)
Delegates to the argument visitor. |
protected java.lang.Object |
clone()
Creates and returns a copy of this object. |
void |
declareParameter(java.lang.Class clazz,
java.lang.String parameter)
Declares a parameter for this query tree. |
void |
declareVariable(java.lang.Class clazz,
java.lang.String variable)
Declares a variable for this query tree. |
java.lang.Class |
getCandidateClass()
Returns the candidate class. |
Node[] |
getChildren()
Returns the children of this node. |
java.util.Map |
getDeclaredParameters()
Returns a map containing all declared parameters. |
java.util.List |
getDeclaredParametersAsList()
Returns a list of all declared parameters. |
java.util.Map |
getDeclaredVariables()
Returns a map containing all declared variables. |
Expression |
getFilter()
Returns the filter expression of this query tree. |
java.util.List |
getOrderingExpressions()
Returns a list of all added ordering expressions. |
java.lang.String |
getSerializedCandidateClassName()
Returns the candidate class name calculated during serialization of this query tree instance. |
private void |
init()
|
void |
initANTLRAST()
Ensures that this node has a corresponding ANTLR tree structure. |
java.lang.Object |
leave(NodeVisitor visitor,
java.lang.Object[] results)
Delegates to the argument visitor. |
AndExpression |
newAnd(Expression left,
Expression right)
Returns an and expression for the arguments left and right. |
CastExpression |
newCast(java.lang.Class clazz,
Expression expression)
Returns an instance of CastExpression. |
ComplementExpression |
newComplement(Expression expr)
Returns a complement expression for the argument expr. |
ConditionalAndExpression |
newConditionalAnd(Expression left,
Expression right)
Returns a conditional and expression for the arguments left and right. |
ConditionalOrExpression |
newConditionalOr(Expression left,
Expression right)
Returns a conditional or expression for the arguments left and right. |
ConstantExpression |
newConstant(boolean b)
Returns an instance of BooleanLiteralExpression. |
ConstantExpression |
newConstant(byte b)
Returns an instance of ByteLiteralExpression. |
ConstantExpression |
newConstant(char c)
Returns an instance of CharLiteralExpression. |
ConstantExpression |
newConstant(double d)
Returns an instance of DoubleLiteralExpression. |
ConstantExpression |
newConstant(float f)
Returns an instance of FloatLiteralExpression. |
ConstantExpression |
newConstant(int i)
Returns an instance of IntLiteralExpression. |
ConstantExpression |
newConstant(long l)
Returns an instance of LongLiteralExpression. |
ConstantExpression |
newConstant(java.lang.Object value)
Returns an instance of ConstantExpression. |
ConstantExpression |
newConstant(short s)
Returns an instance of ShortLiteralExpression. |
DivideExpression |
newDivide(Expression left,
Expression right)
Returns a divide expression for the arguments left and right. |
EqualsExpression |
newEquals(Expression left,
Expression right)
Returns an equals expression for the arguments left and right. |
StaticFieldAccessExpression |
newFieldAccess(java.lang.Class clazz,
java.lang.String fieldName)
Returns an instance of StaticFieldAccessExpression. |
FieldAccessExpression |
newFieldAccess(Expression target,
java.lang.String fieldName)
Returns an instance of FieldAccessExpression. |
GreaterThanExpression |
newGreaterThan(Expression left,
Expression right)
Returns a greater than expression for the arguments left and right. |
GreaterThanEqualsExpression |
newGreaterThanEquals(Expression left,
Expression right)
Returns a greater than equals expression for the arguments left and right. |
IdentifierExpression |
newIdentifier(java.lang.String identifier)
Returns an instance of either ThisExpression or
VariableAccessExpression or
ParameterAccessExpression or FieldAccessExpression
depending on the fact which of the classes the argument
identifier maps to. |
LessThanExpression |
newLessThan(Expression left,
Expression right)
Returns a less than expression for the arguments left and right. |
LessThanEqualsExpression |
newLessThanEquals(Expression left,
Expression right)
Returns a less than equals expression for the arguments left and right. |
MethodCallExpression |
newMethodCall(Expression target,
java.lang.String methodName,
Expression[] arguments)
Returns an instance of MethodCallExpression. |
UnaryMinusExpression |
newMinus(Expression expr)
Returns a unary minus expression for the argument expr. |
MinusExpression |
newMinus(Expression left,
Expression right)
Returns a minus expression for the arguments left and right. |
NotExpression |
newNot(Expression expr)
Returns a not expression for the argument expr. |
NotEqualsExpression |
newNotEquals(Expression left,
Expression right)
Returns a not equals expression for the arguments left and right. |
OrExpression |
newOr(Expression left,
Expression right)
Returns an or expression for the arguments left and right. |
UnaryPlusExpression |
newPlus(Expression expr)
Returns a plus expression for the argument expr. |
PlusExpression |
newPlus(Expression left,
Expression right)
Returns a plus expression for the arguments left and right. |
TimesExpression |
newTimes(Expression left,
Expression right)
Returns a times expression for the arguments left and right. |
private void |
reset()
Nullifies the declared fields in this node as well as the underlying ANTLR tree structure. |
void |
setCandidateClass(java.lang.Class clazz)
Sets the candidate class for this query tree. |
void |
setFilter(Expression filter)
Sets the filter expression for this query tree. |
(package private) static java.lang.Class |
toWrapperClass(java.lang.Class clazz)
|
boolean |
walkNextChild(NodeVisitor visitor,
java.lang.Object resultOfPreviousChild,
int indexOfNextChild)
Delegates to the argument visitor. |
private void |
writeObject(java.io.ObjectOutputStream out)
Deserialization support. |
| Methods inherited from class org.apache.jdo.impl.jdoql.tree.NodeImpl |
ASTToChildren, getJavaClass, getObject, getParent, getTokenType, setChildren, setObject, setParent, toString |
| Methods inherited from class org.apache.jdo.impl.jdoql.jdoqlc.JDOQLAST |
getColumn, getLine, getTypeInfo, initialize, initialize, initialize, setColumn, setLine, setTypeInfo, treeToString |
| Methods inherited from class antlr.CommonAST |
getText, getType, initialize, setText, setType |
| Methods inherited from class antlr.BaseAST |
addChild, decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getFirstChild, getNextSibling, getNumberOfChildren, getTokenNames, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.jdo.jdoql.tree.Node |
getJavaClass, getObject, getParent, getTokenType, setObject, setParent |
| Field Detail |
static final Tree.JavaKeyWords javaKeyWords
CandidateClass candidateClass
java.util.Map parameterMap
java.util.List parameterList
java.util.Map variableMap
java.util.List orderings
Expression filter
java.lang.String serializedCandidateClassName
| Constructor Detail |
public Tree()
public Tree(CandidateClass candidateClass,
ParameterDecl parameterDeclarations,
VariableDecl variableDeclarations,
OrderingExpr orderingExpressions,
Expr filter)
candidateClass - the candidate classparameterDeclarations - the antlr node containing all
parameter declaration nodes as siblingsvariableDeclarations - the antlr node containing all
variable declaration nodes as siblingsorderingExpressions - the antlr node containing all
ordering nodes as siblingsfilter - the filter expression| Method Detail |
protected java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class NodeImpljava.lang.CloneNotSupportedException - thrown by super.clone()public void setCandidateClass(java.lang.Class clazz)
NullPointerException if the argument
clazz is null.
Otherwise this method invalidates this tree:
Parameters, variables, orderings and the filter are nullified.
setCandidateClass in interface QueryTreeclazz - the candidate class
NullPointerException - if the argument clazz is null
public void declareParameter(java.lang.Class clazz,
java.lang.String parameter)
NullPointerException if one of the arguments
type or parameter are null.
If a parameter is already declared having the same name
as the argument parameter, then that declaration is
replaced by this declaration.
Once you have declared a parameter, you can access it using method
newIdentifier.
Please note: You can not declare a parameter and a variable having the same name.
declareParameter in interface QueryTreeclazz - the instance of a Java class which is the type of the declared parameterparameter - the name of the declared parameter
java.lang.NullPointerException - if type or parameter are null
JDOQueryException - if a variable has been declared with the same name
public void declareVariable(java.lang.Class clazz,
java.lang.String variable)
NullPointerException if one of the arguments
type or variable are null.
If a variable is already declared having the same name
as the argument variable, then that declaration is
replaced by this declaration.
Once you have declared a variable, you can access it using method
newIdentifier.
Please note: You can not declare a parameter and a variable having the same name.
declareVariable in interface QueryTreeclazz - the instance of a Java class which is the type of the declared variablevariable - the name of the declared variable
java.lang.NullPointerException - if type or variable are null
JDOQueryException - if a parameter has been declared with the same namepublic void addAscendingOrdering(Expression expression)
NullPointerException if the argument
expression is null.
The order of adding ascending and descending ordering expressions defines
the order of instances in the result collection of an executed query
instance corresponding with this query tree.
addAscendingOrdering in interface QueryTreeexpression - the order expression
java.lang.NullPointerException - if expression is nullpublic void addDescendingOrdering(Expression expression)
NullPointerException if the argument
expression is null.
The order of adding ascending and descending ordering expressions defines
the order of instances in the result collection of an executed query
instance corresponding with this query tree.
addDescendingOrdering in interface QueryTreeexpression - the order expression
java.lang.NullPointerException - if expression is nullpublic void setFilter(Expression filter)
NullPointerException if the argument
filter is null.
setFilter in interface QueryTreefilter - the filter expression
java.lang.NullPointerException - if filter is null
JDOQueryException - if the result type of filter is a non boolean typepublic java.lang.Class getCandidateClass()
getCandidateClass in interface QueryTreepublic java.util.Map getDeclaredVariables()
VariableDeclaration as values.
getDeclaredVariables in interface QueryTreepublic java.util.Map getDeclaredParameters()
ParameterDeclaration as values.
getDeclaredParameters in interface QueryTreepublic java.util.List getDeclaredParametersAsList()
declareParameter.
This list contains instances of
ParametersDeclaration as entries.
getDeclaredParametersAsList in interface QueryTreepublic Expression getFilter()
getFilter in interface QueryTreepublic java.util.List getOrderingExpressions()
addAscendingOrdering and addDescendingOrdering.
This list contains instances of
OrderingExpression as entries.
getOrderingExpressions in interface QueryTreepublic IdentifierExpression newIdentifier(java.lang.String identifier)
ThisExpression or
VariableAccessExpression or
ParameterAccessExpression or FieldAccessExpression
depending on the fact which of the classes the argument
identifier maps to.
This method throws NullPointerException if the argument
identifier is null or the candidate class is not set.
Note: If you pass "this" as an identifier name, then
an instance of ThisExpression is returned. If you pass any
other java key word as an identifier name, then an instance of
JDOQueryException is thrown.
newIdentifier in interface ExpressionFactoryidentifier - the name of the identifier access expression
java.lang.NullPointerException - if identifier is null
JDOQueryException - if identifier is a java key word.
public FieldAccessExpression newFieldAccess(Expression target,
java.lang.String fieldName)
FieldAccessExpression.
This method throws NullPointerException if one of the arguments
target or fieldName are null.
newFieldAccess in interface ExpressionFactorytarget - the target expression of the field access expressionfieldName - the name of the field to access
java.lang.NullPointerException - if target or fieldName are null
public StaticFieldAccessExpression newFieldAccess(java.lang.Class clazz,
java.lang.String fieldName)
StaticFieldAccessExpression.
This method throws NullPointerException if one of the arguments
clazz or fieldName are null.
newFieldAccess in interface ExpressionFactoryclazz - the class instance defining the fieldfieldName - the name of the field to access
java.lang.NullPointerException - if clazz or fieldName are null
public MethodCallExpression newMethodCall(Expression target,
java.lang.String methodName,
Expression[] arguments)
MethodCallExpression.
Note: If the method corresponding with methodName does not have any
arguments, then the argument arguments is ignored.
This method throws NullPointerException if one of the arguments
target or methodName
are null.
newMethodCall in interface ExpressionFactorytarget - the target expression of the method call expressionmethodName - the name of the methodarguments - the array of arguments
java.lang.NullPointerException - if target or methodName are null
JDOQueryException - if methodName is not one of
"contains", "endsWith", "isEmpty"
or "startsWith".
public CastExpression newCast(java.lang.Class clazz,
Expression expression)
CastExpression.
This method throws NullPointerException if one of the arguments
clazz or expression
are null.
newCast in interface ExpressionFactoryclazz - the Java class to cast the argument expression toexpression - the expression to cast
java.lang.NullPointerException - if expression is nullpublic ConstantExpression newConstant(java.lang.Object value)
ConstantExpression.
This method handles null as a constant expression.
newConstant in interface ExpressionFactoryvalue - the object wrapped by the constant expression
public ConstantExpression newConstant(boolean b)
BooleanLiteralExpression.
newConstant in interface ExpressionFactoryb - the value wrapped by the boolean expression
public ConstantExpression newConstant(byte b)
ByteLiteralExpression.
newConstant in interface ExpressionFactoryb - the value wrapped by the byte expression
public ConstantExpression newConstant(char c)
CharLiteralExpression.
newConstant in interface ExpressionFactoryc - the value wrapped by the char expression
public ConstantExpression newConstant(double d)
DoubleLiteralExpression.
newConstant in interface ExpressionFactoryd - the value wrapped by the double expression
public ConstantExpression newConstant(float f)
FloatLiteralExpression.
newConstant in interface ExpressionFactoryf - the value wrapped by the float expression
public ConstantExpression newConstant(int i)
IntLiteralExpression.
newConstant in interface ExpressionFactoryi - the value wrapped by the int expression
public ConstantExpression newConstant(long l)
LongLiteralExpression.
newConstant in interface ExpressionFactoryl - the value wrapped by the long expression
public ConstantExpression newConstant(short s)
ShortLiteralExpression.
newConstant in interface ExpressionFactorys - the value wrapped by the short expression
public ComplementExpression newComplement(Expression expr)
expr.
This method throws NullPointerException if the argument
expr is null.
newComplement in interface ExpressionFactoryexpr - the expression argument for the operation
java.lang.NullPointerException - if expr is nullpublic UnaryMinusExpression newMinus(Expression expr)
expr.
This method throws NullPointerException if the argument
expr is null.
newMinus in interface ExpressionFactoryexpr - the expression argument for the operation
java.lang.NullPointerException - if expr is nullpublic NotExpression newNot(Expression expr)
expr.
This method throws NullPointerException if the argument
expr is null.
newNot in interface ExpressionFactoryexpr - the expression argument for the operation
java.lang.NullPointerException - if expr is nullpublic UnaryPlusExpression newPlus(Expression expr)
expr.
This method throws NullPointerException if the argument
expr is null.
newPlus in interface ExpressionFactoryexpr - the expression argument for the operation
java.lang.NullPointerException - if expr is null
public AndExpression newAnd(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newAnd in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public ConditionalAndExpression newConditionalAnd(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newConditionalAnd in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public ConditionalOrExpression newConditionalOr(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newConditionalOr in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public DivideExpression newDivide(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newDivide in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public EqualsExpression newEquals(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newEquals in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public GreaterThanExpression newGreaterThan(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newGreaterThan in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public GreaterThanEqualsExpression newGreaterThanEquals(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newGreaterThanEquals in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public LessThanExpression newLessThan(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newLessThan in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public LessThanEqualsExpression newLessThanEquals(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newLessThanEquals in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public MinusExpression newMinus(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newMinus in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public NotEqualsExpression newNotEquals(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newNotEquals in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public PlusExpression newPlus(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newPlus in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public OrExpression newOr(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newOr in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are null
public TimesExpression newTimes(Expression left,
Expression right)
left and right.
This method throws NullPointerException if one of the arguments
left or right are null.
newTimes in interface ExpressionFactoryleft - the left expression argument for the operationright - the right expression argument for the operation
java.lang.NullPointerException - if left or right are nullpublic Node[] getChildren()
getChildren in interface NodegetChildren in class NodeImplJDOQueryException - if the candidate class is not setpublic void arrive(NodeVisitor visitor)
visitor.
arrive in interface Nodearrive in class NodeImplvisitor - the node visitor
public java.lang.Object leave(NodeVisitor visitor,
java.lang.Object[] results)
visitor.
leave in interface Nodeleave in class NodeImplvisitor - the node visitorresults - the result array
public boolean walkNextChild(NodeVisitor visitor,
java.lang.Object resultOfPreviousChild,
int indexOfNextChild)
visitor.
walkNextChild in interface NodewalkNextChild in class NodeImplvisitor - the node visitorresultOfPreviousChild - the result computed by leaving the
previous child node.indexOfNextChild - the index of the next child node
public void initANTLRAST()
JDOQueryException - if the candidate class is not setprivate void reset()
private void init()
static java.lang.Class toWrapperClass(java.lang.Class clazz)
public java.lang.String getSerializedCandidateClassName()
private void writeObject(java.io.ObjectOutputStream out)
throws java.io.IOException
java.io.IOException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||