|
||||||||||
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
public final class 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.
Field Summary |
---|
Fields inherited from class org.apache.jdo.impl.jdoql.jdoqlc.JDOQLAST |
---|
column, line, typeInfo |
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. |
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 . |
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. |
boolean |
walkNextChild(NodeVisitor visitor,
java.lang.Object resultOfPreviousChild,
int indexOfNextChild)
Delegates to the argument visitor . |
Methods inherited from class org.apache.jdo.impl.jdoql.tree.NodeImpl |
---|
getJavaClass, getObject, getParent, getTokenType, 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 |
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 expressionMethod Detail |
---|
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class NodeImpl
java.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 QueryTree
clazz
- the candidate class
NullPointerException
- if the argument clazz
is nullpublic 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 QueryTree
clazz
- 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 namepublic 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 QueryTree
clazz
- 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 QueryTree
expression
- 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 QueryTree
expression
- the order expression
java.lang.NullPointerException
- if expression is nullpublic void setFilter(Expression filter)
NullPointerException
if the argument
filter
is null
.
setFilter
in interface QueryTree
filter
- 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 QueryTree
public java.util.Map getDeclaredVariables()
VariableDeclaration
as values.
getDeclaredVariables
in interface QueryTree
public java.util.Map getDeclaredParameters()
ParameterDeclaration
as values.
getDeclaredParameters
in interface QueryTree
public java.util.List getDeclaredParametersAsList()
declareParameter
.
This list contains instances of
ParametersDeclaration
as entries.
getDeclaredParametersAsList
in interface QueryTree
public Expression getFilter()
getFilter
in interface QueryTree
public java.util.List getOrderingExpressions()
addAscendingOrdering
and addDescendingOrdering
.
This list contains instances of
OrderingExpression
as entries.
getOrderingExpressions
in interface QueryTree
public 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 ExpressionFactory
identifier
- 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 ExpressionFactory
target
- the target expression of the field access expressionfieldName
- the name of the field to access
java.lang.NullPointerException
- if target or fieldName are nullpublic 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 ExpressionFactory
clazz
- the class instance defining the fieldfieldName
- the name of the field to access
java.lang.NullPointerException
- if clazz or fieldName are nullpublic 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 ExpressionFactory
target
- 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 ExpressionFactory
clazz
- 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 ExpressionFactory
value
- the object wrapped by the constant expression
public ConstantExpression newConstant(boolean b)
BooleanLiteralExpression
.
newConstant
in interface ExpressionFactory
b
- the value wrapped by the boolean expression
public ConstantExpression newConstant(byte b)
ByteLiteralExpression
.
newConstant
in interface ExpressionFactory
b
- the value wrapped by the byte expression
public ConstantExpression newConstant(char c)
CharLiteralExpression
.
newConstant
in interface ExpressionFactory
c
- the value wrapped by the char expression
public ConstantExpression newConstant(double d)
DoubleLiteralExpression
.
newConstant
in interface ExpressionFactory
d
- the value wrapped by the double expression
public ConstantExpression newConstant(float f)
FloatLiteralExpression
.
newConstant
in interface ExpressionFactory
f
- the value wrapped by the float expression
public ConstantExpression newConstant(int i)
IntLiteralExpression
.
newConstant
in interface ExpressionFactory
i
- the value wrapped by the int expression
public ConstantExpression newConstant(long l)
LongLiteralExpression
.
newConstant
in interface ExpressionFactory
l
- the value wrapped by the long expression
public ConstantExpression newConstant(short s)
ShortLiteralExpression
.
newConstant
in interface ExpressionFactory
s
- 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 ExpressionFactory
expr
- 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 ExpressionFactory
expr
- 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 ExpressionFactory
expr
- 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 ExpressionFactory
expr
- the expression argument for the operation
java.lang.NullPointerException
- if expr is nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- the left expression argument for the operationright
- the right expression argument for the operation
java.lang.NullPointerException
- if left or right are nullpublic 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 ExpressionFactory
left
- 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 Node
getChildren
in class NodeImpl
JDOQueryException
- if the candidate class is not setpublic void arrive(NodeVisitor visitor)
visitor
.
arrive
in interface Node
arrive
in class NodeImpl
visitor
- the node visitorpublic java.lang.Object leave(NodeVisitor visitor, java.lang.Object[] results)
visitor
.
leave
in interface Node
leave
in class NodeImpl
visitor
- the node visitorresults
- the result array
public boolean walkNextChild(NodeVisitor visitor, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
visitor
.
walkNextChild
in interface Node
walkNextChild
in class NodeImpl
visitor
- 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 setpublic java.lang.String getSerializedCandidateClassName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |