Package ognl
Class SimpleNode
- java.lang.Object
-
- ognl.SimpleNode
-
- All Implemented Interfaces:
java.io.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
public abstract class SimpleNode extends java.lang.Object implements Node, java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Node[]childrenprivate java.lang.ObjectconstantValueprivate booleanconstantValueCalculatedprivate ExpressionAccessorexpressionAccessorprivate booleanhasConstantValueprotected intidprotected Nodeparentprotected OgnlParserparserprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description SimpleNode(int i)SimpleNode(OgnlParser p, int i)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voiddump(java.io.PrintWriter writer, java.lang.String prefix)protected java.lang.ObjectevaluateGetValueBody(OgnlContext context, java.lang.Object source)protected voidevaluateSetValueBody(OgnlContext context, java.lang.Object target, java.lang.Object value)protected voidflattenTree()This method may be called from subclasses' jjtClose methods.ExpressionAccessorgetAccessor()Gets the compiled bytecode enhanced expression accessor for getting/setting values.intgetIndexInParent()NodegetNextSibling()java.lang.ObjectgetValue(OgnlContext context, java.lang.Object source)Extracts the value from the given source object that is appropriate for this node within the given context.protected abstract java.lang.ObjectgetValueBody(OgnlContext context, java.lang.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.NodejjtGetChild(int i)This method returns a child node.intjjtGetNumChildren()Return the number of children the node has.NodejjtGetParent()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.voidsetValue(OgnlContext context, java.lang.Object target, java.lang.Object value)Sets the given value in the given target as appropriate for this node within the given context.protected voidsetValueBody(OgnlContext context, java.lang.Object target, java.lang.Object value)Subclasses implement this method to do the actual work of setting the appropriate value in the target object.java.lang.StringtoGetSourceString(OgnlContext context, java.lang.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.java.lang.StringtoSetSourceString(OgnlContext context, java.lang.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.java.lang.StringtoString()java.lang.StringtoString(java.lang.String prefix)
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
parent
protected Node parent
-
children
protected Node[] children
-
id
protected int id
-
parser
protected OgnlParser parser
-
constantValueCalculated
private boolean constantValueCalculated
-
hasConstantValue
private volatile boolean hasConstantValue
-
constantValue
private java.lang.Object constantValue
-
expressionAccessor
private ExpressionAccessor expressionAccessor
-
-
Constructor Detail
-
SimpleNode
public SimpleNode(int i)
-
SimpleNode
public SimpleNode(OgnlParser p, int i)
-
-
Method Detail
-
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
public void jjtSetParent(Node n)
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
public Node jjtGetParent()
- Specified by:
jjtGetParentin interfaceNode
-
jjtAddChild
public void jjtAddChild(Node n, int i)
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
public Node jjtGetChild(int i)
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toString
public java.lang.String toString(java.lang.String prefix)
-
toGetSourceString
public java.lang.String toGetSourceString(OgnlContext context, java.lang.Object target)
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
public java.lang.String toSetSourceString(OgnlContext context, java.lang.Object target)
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
public void dump(java.io.PrintWriter writer, java.lang.String prefix)
-
getIndexInParent
public int getIndexInParent()
-
getNextSibling
public Node getNextSibling()
-
evaluateGetValueBody
protected java.lang.Object evaluateGetValueBody(OgnlContext context, java.lang.Object source) throws OgnlException
- Throws:
OgnlException
-
evaluateSetValueBody
protected void evaluateSetValueBody(OgnlContext context, java.lang.Object target, java.lang.Object value) throws OgnlException
- Throws:
OgnlException
-
getValue
public final java.lang.Object getValue(OgnlContext context, java.lang.Object source) throws OgnlException
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
protected abstract java.lang.Object getValueBody(OgnlContext context, java.lang.Object source) throws OgnlException
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
public final void setValue(OgnlContext context, java.lang.Object target, java.lang.Object value) throws OgnlException
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
protected void setValueBody(OgnlContext context, java.lang.Object target, java.lang.Object value) throws OgnlException
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
public boolean isNodeConstant(OgnlContext context) throws OgnlException
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
public boolean isConstant(OgnlContext context) throws OgnlException
- Throws:
OgnlException
-
isNodeSimpleProperty
public boolean isNodeSimpleProperty(OgnlContext context) throws OgnlException
- Throws:
OgnlException
-
isSimpleProperty
public boolean isSimpleProperty(OgnlContext context) throws OgnlException
- Throws:
OgnlException
-
isSimpleNavigationChain
public boolean isSimpleNavigationChain(OgnlContext context) throws OgnlException
- Throws:
OgnlException
-
isEvalChain
public boolean isEvalChain(OgnlContext context) throws OgnlException
- Throws:
OgnlException
-
isSequence
public boolean isSequence(OgnlContext context) throws OgnlException
- Throws:
OgnlException
-
isOperation
public boolean isOperation(OgnlContext context) throws OgnlException
- Throws:
OgnlException
-
isChain
public boolean isChain(OgnlContext context) throws OgnlException
- Throws:
OgnlException
-
isSimpleMethod
public boolean isSimpleMethod(OgnlContext context) throws OgnlException
- Throws:
OgnlException
-
lastChild
protected boolean lastChild(OgnlContext context)
-
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
public ExpressionAccessor 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
public void setAccessor(ExpressionAccessor accessor)
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.
-
-