Package org.apache.cayenne.exp.parser
Class SimpleNode
java.lang.Object
org.apache.cayenne.exp.Expression
org.apache.cayenne.exp.parser.SimpleNode
- All Implemented Interfaces:
- Serializable,- Node,- XMLSerializable
- Direct Known Subclasses:
- AggregateConditionNode,- ASTAsterisk,- ASTFullObject,- ASTList,- ASTNegate,- ASTPath,- ASTScalar,- ConditionNode,- EvaluatedNode
public abstract class SimpleNode extends Expression implements Node
Superclass of AST* expressions that implements Node interface defined by JavaCC framework.
 
Some parts of the parser are based on OGNL parser, copyright (c) 2002, Drew Davidson and Luke Blanshard.
- Since:
- 1.1
- See Also:
- Serialized Form
- 
Field SummaryFields Modifier and Type Field Description protected Node[]childrenprotected intidprotected NodeparentFields inherited from class org.apache.cayenne.exp.ExpressionADD, AND, ASTERISK, BETWEEN, BITWISE_AND, BITWISE_LEFT_SHIFT, BITWISE_NOT, BITWISE_OR, BITWISE_RIGHT_SHIFT, BITWISE_XOR, DB_PATH, DIVIDE, EQUAL_TO, FALSE, FULL_OBJECT, FUNCTION_CALL, GREATER_THAN, GREATER_THAN_EQUAL_TO, IN, LESS_THAN, LESS_THAN_EQUAL_TO, LIKE, LIKE_IGNORE_CASE, LIST, MULTIPLY, NEGATIVE, NOT, NOT_BETWEEN, NOT_EQUAL_TO, NOT_IN, NOT_LIKE, NOT_LIKE_IGNORE_CASE, OBJ_PATH, OR, PRUNED_NODE, SUBTRACT, TRUE, type
- 
Constructor SummaryConstructors Modifier Constructor Description protectedSimpleNode(int i)
- 
Method SummaryModifier and Type Method Description voidappendAsEJBQL(Appendable out, String rootId)Stores a String representation of Expression as EJBQL using a provided Appendable.voidappendAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId)Stores a String representation of Expression as EJBQL using a provided PrintWriter.protected static voidappendAsEscapedString(Appendable out, String source)Utility method that prints a string to the provided Appendable, escaping special characters.voidappendAsString(Appendable out)Appends own content as a String to the provided Appendable.protected voidappendChildrenAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId)Encodes child of this node with specified index to EJBQLprotected static voidappendScalarAsString(Appendable out, Object scalar, char quoteChar)Utility method that encodes an object that is not an expression Node to String.protected voidconnectChildren()Sets the parent to this for all children.protected static voidencodeScalarAsEJBQL(List<Object> parameterAccumulator, Appendable out, Object scalar)This is a utility method that can represent the supplied scalar as either an EJBQL literal into the suppliedPrintWriteror is able to add the scalar to the parameters and to instead write a positional parameter to the EJBQL written to thePrintWriter.Objectevaluate(Object o)Calculates expression value with object as a context for path expressions.protected ObjectevaluateChild(int index, Object o)protected abstract ObjectevaluateNode(Object o)Evaluates itself with object, pushing result on the stack.StringexpName()Implemented for backwards compatibility with exp package.protected voidflattenTree()Flattens the tree under this node by eliminating any children that are of the same class as this node and copying their children to this node.protected StringgetEJBQLExpressionOperator(int index)Returns operator for EJBQL statements, which can differ for Cayenne expression operatorprotected abstract StringgetExpressionOperator(int index)ObjectgetOperand(int index)Returns a value of operand atindex.intgetOperandCount()Returns a count of operands of this expression.Map<String,String>getPathAliases()Always returns empty map.voidjjtAddChild(Node n, int i)This method tells the node to add its argument to the node's list of children.voidjjtClose()Called after all the child nodes have been added.NodejjtGetChild(int i)This method returns a child node.intjjtGetNumChildren()Return the number of children the node has.NodejjtGetParent()voidjjtOpen()Called after the node has been made the current node.voidjjtSetParent(Node n)This pair of methods are used to inform the node of its parent.ExpressionnotExp()Returns a logical NOT of current expression.protected booleanpruneNodeForPrunedChild(Object prunedChild)Returns true if this node should be pruned from expression tree in the event a child is removed.voidsetOperand(int index, Object value)Sets a value of operand atindex.protected ObjectunwrapChild(Node child)protected NodewrapChild(Object child)Methods inherited from class org.apache.cayenne.exp.ExpressionandExp, andExp, deepCopy, encodeAsXML, equals, filter, filterObjects, first, getType, hashCode, joinExp, joinExp, match, orExp, orExp, params, params, paramsArray, setType, shallowCopy, toEJBQL, toEJBQL, toString, transform, transformExpression, traverse, traverse
- 
Field Details- 
parent
- 
children
- 
idprotected int id
 
- 
- 
Constructor Details- 
SimpleNodeprotected SimpleNode(int i)
 
- 
- 
Method Details- 
encodeScalarAsEJBQLprotected static void encodeScalarAsEJBQL(List<Object> parameterAccumulator, Appendable out, Object scalar) throws IOExceptionThis is a utility method that can represent the supplied scalar as either an EJBQL literal into the supplied PrintWriteror is able to add the scalar to the parameters and to instead write a positional parameter to the EJBQL written to thePrintWriter. If the parameters are null and the scalar object is not able to be represented as an EJBQL literal then the method will throw a runtime exception to indicate that it has failed to produce valid EJBQL.- Throws:
- IOException
 
- 
appendScalarAsStringprotected static void appendScalarAsString(Appendable out, Object scalar, char quoteChar) throws IOExceptionUtility method that encodes an object that is not an expression Node to String.- Throws:
- IOException
 
- 
appendAsEscapedStringUtility method that prints a string to the provided Appendable, escaping special characters.- Throws:
- IOException
 
- 
getPathAliasesAlways returns empty map.- Specified by:
- getPathAliasesin class- Expression
- Since:
- 3.0
 
- 
getExpressionOperator
- 
getEJBQLExpressionOperatorReturns operator for EJBQL statements, which can differ for Cayenne expression operator
- 
pruneNodeForPrunedChildDescription copied from class:ExpressionReturns true if this node should be pruned from expression tree in the event a child is removed.- Specified by:
- pruneNodeForPrunedChildin class- Expression
 
- 
expNameImplemented for backwards compatibility with exp package.- Overrides:
- expNamein class- Expression
 
- 
flattenTreeprotected void flattenTree()Flattens the tree under this node by eliminating any children that are of the same class as this node and copying their children to this node.- Specified by:
- flattenTreein class- Expression
 
- 
appendAsStringDescription copied from class:ExpressionAppends own content as a String to the provided Appendable.- Specified by:
- appendAsStringin class- Expression
- Throws:
- IOException
- Since:
- 4.0
 
- 
getOperandDescription copied from class:ExpressionReturns a value of operand atindex. Operand indexing starts at 0.- Specified by:
- getOperandin class- Expression
 
- 
wrapChild
- 
unwrapChild
- 
getOperandCountpublic int getOperandCount()Description copied from class:ExpressionReturns a count of operands of this expression. In real life there are unary (count == 1), binary (count == 2) and ternary (count == 3) expressions.- Specified by:
- getOperandCountin class- Expression
 
- 
setOperandDescription copied from class:ExpressionSets a value of operand atindex. Operand indexing starts at 0.- Specified by:
- setOperandin class- Expression
 
- 
jjtOpenpublic void jjtOpen()Description copied from interface:NodeCalled after the node has been made the current node. It indicates that child nodes can now be added to it.
- 
jjtClosepublic void jjtClose()Description copied from interface:NodeCalled after all the child nodes have been added.
- 
jjtSetParentDescription copied from interface:NodeThis pair of methods are used to inform the node of its parent.- Specified by:
- jjtSetParentin interface- Node
 
- 
jjtGetParent- Specified by:
- jjtGetParentin interface- Node
 
- 
jjtAddChildDescription copied from interface:NodeThis method tells the node to add its argument to the node's list of children.- Specified by:
- jjtAddChildin interface- Node
 
- 
jjtGetChildDescription copied from interface:NodeThis method returns a child node. The children are numbered from zero, left to right.- Specified by:
- jjtGetChildin interface- Node
 
- 
jjtGetNumChildrenpublic final int jjtGetNumChildren()Description copied from interface:NodeReturn the number of children the node has.- Specified by:
- jjtGetNumChildrenin interface- Node
 
- 
evaluateNodeEvaluates itself with object, pushing result on the stack.- Throws:
- Exception
 
- 
connectChildrenprotected void connectChildren()Sets the parent to this for all children.- Since:
- 3.0
 
- 
evaluateChild- Throws:
- Exception
 
- 
notExpDescription copied from class:ExpressionReturns a logical NOT of current expression.- Specified by:
- notExpin class- Expression
 
- 
evaluateDescription copied from class:ExpressionCalculates expression value with object as a context for path expressions.- Specified by:
- evaluatein class- Expression
 
- 
appendAsEJBQLDescription copied from class:ExpressionStores a String representation of Expression as EJBQL using a provided Appendable. DB path expressions produce non-standard EJBQL path expressions.- Overrides:
- appendAsEJBQLin class- Expression
- Throws:
- IOException
- Since:
- 4.0
 
- 
appendAsEJBQLpublic void appendAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId) throws IOExceptionDescription copied from class:ExpressionStores a String representation of Expression as EJBQL using a provided PrintWriter. DB path expressions produce non-standard EJBQL path expressions. If the parameterAccumulator is supplied then as the EJBQL is output, it may load parameters into this list. In this case, the EJBQL output will contain reference to positional parameters. If no parameterAccumulator is supplied and a scalar type is encountered for which there is no EJBQL literal representation (such as dates) then this method will throw a runtime exception to indicate that it was not possible to generate a string-only representation of the Expression in EJBQL.- Specified by:
- appendAsEJBQLin class- Expression
- Throws:
- IOException
- Since:
- 4.0
 
- 
appendChildrenAsEJBQLprotected void appendChildrenAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId) throws IOExceptionEncodes child of this node with specified index to EJBQL- Throws:
- IOException
 
 
-