Package ognl
Class SimpleNode
java.lang.Object
ognl.SimpleNode
- All Implemented Interfaces:
Serializable,JavaSource,Node
- Direct Known Subclasses:
ASTAssign,ASTChain,ASTConst,ASTCtor,ASTEval,ASTIn,ASTInstanceof,ASTKeyValue,ASTList,ASTMap,ASTMethod,ASTNotIn,ASTProject,ASTProperty,ASTSelect,ASTSelectFirst,ASTSelectLast,ASTSequence,ASTStaticField,ASTStaticMethod,ASTVarRef,ExpressionNode
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Node[]private Objectprivate booleanprivate ExpressionAccessorprivate booleanprotected intprotected Nodeprotected OgnlParserprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddump(PrintWriter writer, String prefix) protected ObjectevaluateGetValueBody(OgnlContext context, Object source) protected voidevaluateSetValueBody(OgnlContext context, Object target, Object value) protected voidThis method may be called from subclasses' jjtClose methods.Gets the compiled bytecode enhanced expression accessor for getting/setting values.intfinal ObjectgetValue(OgnlContext context, Object source) Extracts the value from the given source object that is appropriate for this node within the given context.protected abstract ObjectgetValueBody(OgnlContext context, Object source) Subclasses implement this method to do the actual work of extracting the appropriate value from the source object.booleanisChain(OgnlContext context) booleanisConstant(OgnlContext context) booleanisEvalChain(OgnlContext context) booleanisNodeConstant(OgnlContext context) Returns true iff this node is constant without respect to the children.booleanisNodeSimpleProperty(OgnlContext context) booleanisOperation(OgnlContext context) booleanisSequence(OgnlContext context) booleanisSimpleMethod(OgnlContext context) booleanisSimpleNavigationChain(OgnlContext context) booleanisSimpleProperty(OgnlContext context) voidjjtAddChild(Node n, int i) This method tells the node to add its argument to the node's list of children.voidjjtClose()This method is called after all the child nodes have been added.jjtGetChild(int i) This method returns a child node.intReturn the number of children the node has.voidjjtOpen()This method is 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.protected booleanlastChild(OgnlContext context) voidsetAccessor(ExpressionAccessor accessor) Sets a new compiled accessor for this node expression.final voidsetValue(OgnlContext context, Object target, Object value) Sets the given value in the given target as appropriate for this node within the given context.protected voidsetValueBody(OgnlContext context, Object target, Object value) Subclasses implement this method to do the actual work of setting the appropriate value in the target object.toGetSourceString(OgnlContext context, Object target) Expected to return a java source representation of itself such that it could be turned into a literal java expression to be compiled and executed forExpressionAccessor.get(OgnlContext, Object)calls.toSetSourceString(OgnlContext context, Object target) Expected to return a java source representation of itself such that it could be turned into a literal java expression to be compiled and executed forExpressionAccessor.get(OgnlContext, Object)calls.toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
parent
-
children
-
id
protected int id -
parser
-
constantValueCalculated
private boolean constantValueCalculated -
hasConstantValue
private volatile boolean hasConstantValue -
constantValue
-
expressionAccessor
-
-
Constructor Details
-
SimpleNode
public SimpleNode(int i) -
SimpleNode
-
-
Method Details
-
jjtOpen
public void jjtOpen()Description copied from interface:NodeThis method is called after the node has been made the current node. It indicates that child nodes can now be added to it. -
jjtClose
public void jjtClose()Description copied from interface:NodeThis method is called after all the child nodes have been added. -
jjtSetParent
Description copied from interface:NodeThis pair of methods are used to inform the node of its parent.- Specified by:
jjtSetParentin interfaceNode- Parameters:
n- the Node to make the parent of this node.
-
jjtGetParent
- Specified by:
jjtGetParentin interfaceNode
-
jjtAddChild
Description copied from interface:NodeThis method tells the node to add its argument to the node's list of children.- Specified by:
jjtAddChildin interfaceNode- Parameters:
n- the Node to add as a child of this node.i- the position at which to add the child node.
-
jjtGetChild
Description copied from interface:NodeThis method returns a child node. The children are numbered from zero, left to right.- Specified by:
jjtGetChildin interfaceNode- Parameters:
i- the position from which to get the child node.- Returns:
- the child Node at position i.
-
jjtGetNumChildren
public int jjtGetNumChildren()Description copied from interface:NodeReturn the number of children the node has.- Specified by:
jjtGetNumChildrenin interfaceNode- Returns:
- the number of children for this node.
-
toString
-
toString
-
toGetSourceString
Description copied from interface:JavaSourceExpected to return a java source representation of itself such that it could be turned into a literal java expression to be compiled and executed forExpressionAccessor.get(OgnlContext, Object)calls.- Specified by:
toGetSourceStringin interfaceJavaSource- Parameters:
context- the OgnlContext within which to perform the operation.target- the Object from which to retrieve the get source string.- Returns:
- Literal java string representation of an object get.
-
toSetSourceString
Description copied from interface:JavaSourceExpected to return a java source representation of itself such that it could be turned into a literal java expression to be compiled and executed forExpressionAccessor.get(OgnlContext, Object)calls.- Specified by:
toSetSourceStringin interfaceJavaSource- Parameters:
context- the OgnlContext within which to perform the operation.target- the Object from which to retrieve the set source string.- Returns:
- Literal java string representation of an object set.
-
dump
-
getIndexInParent
public int getIndexInParent() -
getNextSibling
-
evaluateGetValueBody
- Throws:
OgnlException
-
evaluateSetValueBody
protected void evaluateSetValueBody(OgnlContext context, Object target, Object value) throws OgnlException - Throws:
OgnlException
-
getValue
Description copied from interface:NodeExtracts the value from the given source object that is appropriate for this node within the given context.- Specified by:
getValuein interfaceNode- Parameters:
context- the OgnlContext within which to perform the operation.source- the Object from which to get the value.- Returns:
- the value from the source (as appropriate within the provided context).
- Throws:
OgnlException- if the value get fails.
-
getValueBody
Subclasses implement this method to do the actual work of extracting the appropriate value from the source object.- Parameters:
context- the OgnlContext within which to perform the operation.source- the Object from which to get the value body.- Returns:
- the value body from the source (as appropriate within the provided context).
- Throws:
OgnlException- if the value body get fails.
-
setValue
Description copied from interface:NodeSets the given value in the given target as appropriate for this node within the given context.- Specified by:
setValuein interfaceNode- Parameters:
context- the OgnlContext within which to perform the operation.target- the Object upon which to set the value.value- the Object representing the value to apply to the target.- Throws:
OgnlException- if the value set fails.
-
setValueBody
Subclasses implement this method to do the actual work of setting the appropriate value in the target object. The default implementation throws anInappropriateExpressionException, meaning that it cannot be a set expression.- Parameters:
context- the OgnlContext within which to perform the operation.target- the Object upon which to set the value body.value- the Object representing the value body to apply to the target.- Throws:
OgnlException- if the value body set fails.
-
isNodeConstant
Returns true iff this node is constant without respect to the children.- Parameters:
context- the OgnlContext within which to perform the operation.- Returns:
- true if this node is a constant, false otherwise.
- Throws:
OgnlException- if the check fails.
-
isConstant
- Throws:
OgnlException
-
isNodeSimpleProperty
- Throws:
OgnlException
-
isSimpleProperty
- Throws:
OgnlException
-
isEvalChain
- Throws:
OgnlException
-
isSequence
- Throws:
OgnlException
-
isOperation
- Throws:
OgnlException
-
isChain
- Throws:
OgnlException
-
isSimpleMethod
- Throws:
OgnlException
-
lastChild
-
flattenTree
protected void flattenTree()This method may be called from subclasses' jjtClose methods. It 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. -
getAccessor
Description copied from interface:NodeGets the compiled bytecode enhanced expression accessor for getting/setting values.- Specified by:
getAccessorin interfaceNode- Returns:
- The accessor for this node, or null if none has been compiled for it.
-
setAccessor
Description copied from interface:NodeSets a new compiled accessor for this node expression.- Specified by:
setAccessorin interfaceNode- Parameters:
accessor- The compiled representation of this node.
-