public abstract class SimpleNode extends Expression implements Node
Some parts of the parser are based on OGNL parser, copyright (c) 2002, Drew Davidson and Luke Blanshard.
Modifier and Type | Field and Description |
---|---|
protected Node[] |
children |
protected int |
id |
protected Node |
parent |
ADD, 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
Modifier | Constructor and Description |
---|---|
protected |
SimpleNode(int i) |
Modifier and Type | Method and Description |
---|---|
void |
appendAsEJBQL(Appendable out,
String rootId)
Stores a String representation of Expression as EJBQL using a provided
Appendable.
|
void |
appendAsEJBQL(List<Object> parameterAccumulator,
Appendable out,
String rootId)
Stores a String representation of Expression as EJBQL using a provided
PrintWriter.
|
protected static void |
appendAsEscapedString(Appendable out,
String source)
Utility method that prints a string to the provided Appendable, escaping special characters.
|
void |
appendAsString(Appendable out)
Appends own content as a String to the provided Appendable.
|
protected void |
appendChildrenAsEJBQL(List<Object> parameterAccumulator,
Appendable out,
String rootId)
Encodes child of this node with specified index to EJBQL
|
protected static void |
appendScalarAsString(Appendable out,
Object scalar,
char quoteChar)
Utility method that encodes an object that is not an expression Node to
String.
|
protected void |
connectChildren()
Sets the parent to this for all children.
|
void |
encodeAsEJBQL(PrintWriter pw,
String rootId)
Deprecated.
since 4.0 use
appendAsEJBQL(Appendable, String) . |
void |
encodeAsString(PrintWriter pw)
Deprecated.
since 4.0 use
appendAsString(Appendable) . |
protected static void |
encodeScalarAsEJBQL(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 supplied
PrintWriter or is able
to add the scalar to the parameters and to instead write a positional
parameter to the EJBQL written to the PrintWriter . |
Object |
evaluate(Object o)
Calculates expression value with object as a context for path
expressions.
|
protected Object |
evaluateChild(int index,
Object o) |
protected abstract Object |
evaluateNode(Object o)
Evaluates itself with object, pushing result on the stack.
|
String |
expName()
Implemented for backwards compatibility with exp package.
|
protected 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.
|
protected String |
getEJBQLExpressionOperator(int index)
Returns operator for EJBQL statements, which can differ for Cayenne expression operator
|
protected abstract String |
getExpressionOperator(int index) |
Object |
getOperand(int index)
Returns a value of operand at
index . |
int |
getOperandCount()
Returns a count of operands of this expression.
|
Map<String,String> |
getPathAliases()
Always returns empty map.
|
void |
jjtAddChild(Node n,
int i)
This method tells the node to add its argument to the node's
list of children.
|
void |
jjtClose()
Called after all the child nodes have been
added.
|
Node |
jjtGetChild(int i)
This method returns a child node.
|
int |
jjtGetNumChildren()
Return the number of children the node has.
|
Node |
jjtGetParent() |
void |
jjtOpen()
Called after the node has been made the current
node.
|
void |
jjtSetParent(Node n)
This pair of methods are used to inform the node of its
parent.
|
Expression |
notExp()
Returns a logical NOT of current expression.
|
protected boolean |
pruneNodeForPrunedChild(Object prunedChild)
Returns true if this node should be pruned from expression tree in the
event a child is removed.
|
void |
setOperand(int index,
Object value)
Sets a value of operand at
index . |
protected Object |
unwrapChild(Node child) |
protected Node |
wrapChild(Object child) |
andExp, andExp, deepCopy, encodeAsXML, equals, expWithParameters, expWithParameters, filter, filterObjects, first, fromString, getType, hashCode, joinExp, joinExp, match, orExp, orExp, params, params, paramsArray, setType, shallowCopy, toEJBQL, toEJBQL, toString, transform, transformExpression, traverse, traverse
protected static void encodeScalarAsEJBQL(List<Object> parameterAccumulator, Appendable out, Object scalar) throws IOException
This is a utility method that can represent the supplied scalar as either
an EJBQL literal into the supplied PrintWriter
or is able
to add the scalar to the parameters and to instead write a positional
parameter to the EJBQL written to the PrintWriter
. 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.
IOException
protected static void appendScalarAsString(Appendable out, Object scalar, char quoteChar) throws IOException
IOException
protected static void appendAsEscapedString(Appendable out, String source) throws IOException
IOException
public Map<String,String> getPathAliases()
getPathAliases
in class Expression
protected abstract String getExpressionOperator(int index)
protected String getEJBQLExpressionOperator(int index)
protected boolean pruneNodeForPrunedChild(Object prunedChild)
Expression
pruneNodeForPrunedChild
in class Expression
public String expName()
expName
in class Expression
protected void flattenTree()
flattenTree
in class Expression
public void appendAsString(Appendable out) throws IOException
Expression
appendAsString
in class Expression
IOException
@Deprecated public void encodeAsString(PrintWriter pw)
appendAsString(Appendable)
.Expression
encodeAsString
in class Expression
public Object getOperand(int index)
Expression
index
. Operand indexing starts
at 0.getOperand
in class Expression
public int getOperandCount()
Expression
getOperandCount
in class Expression
public void setOperand(int index, Object value)
Expression
index
. Operand indexing starts at
0.setOperand
in class Expression
public void jjtOpen()
Node
public void jjtClose()
Node
public void jjtSetParent(Node n)
Node
jjtSetParent
in interface Node
public Node jjtGetParent()
jjtGetParent
in interface Node
public void jjtAddChild(Node n, int i)
Node
jjtAddChild
in interface Node
public Node jjtGetChild(int i)
Node
jjtGetChild
in interface Node
public final int jjtGetNumChildren()
Node
jjtGetNumChildren
in interface Node
protected abstract Object evaluateNode(Object o) throws Exception
Exception
protected void connectChildren()
protected Object evaluateChild(int index, Object o) throws Exception
Exception
public Expression notExp()
Expression
notExp
in class Expression
public Object evaluate(Object o)
Expression
evaluate
in class Expression
@Deprecated public void encodeAsEJBQL(PrintWriter pw, String rootId)
appendAsEJBQL(Appendable, String)
.Expression
encodeAsEJBQL
in class Expression
public void appendAsEJBQL(Appendable out, String rootId) throws IOException
Expression
appendAsEJBQL
in class Expression
IOException
public void appendAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId) throws IOException
Expression
appendAsEJBQL
in class Expression
IOException
protected void appendChildrenAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId) throws IOException
IOException
Copyright © 2001–2017 Apache Cayenne. All rights reserved.