Package ognl
Class SimpleNode
java.lang.Object
ognl.SimpleNode
- All Implemented Interfaces:
Serializable
,JavaSource
,Node
- Direct Known Subclasses:
ASTChain
,ASTConst
,ASTCtor
,ASTInstanceof
,ASTList
,ASTMethod
,ASTProperty
,ASTSequence
,ASTStaticField
,ASTStaticMethod
,ASTVarRef
,ExpressionNode
- Author:
- Luke Blanshard (blanshlu@netscape.net), Drew Davidson (drew@ognl.org)
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
dump
(PrintWriter writer, String prefix) protected Object
evaluateGetValueBody
(OgnlContext context, Object source) protected void
evaluateSetValueBody
(OgnlContext context, Object target, Object value) protected void
This method may be called from subclasses' jjtClose methods.Gets the compiled bytecode enhanced expression accessor for getting/setting values.int
final Object
getValue
(OgnlContext context, Object source) Extracts the value from the given source object that is appropriate for this node within the given context.protected abstract Object
getValueBody
(OgnlContext context, Object source) Subclasses implement this method to do the actual work of extracting the appropriate value from the source object.boolean
isConstant
(OgnlContext context) boolean
isNodeConstant
(OgnlContext context) Returns true iff this node is constant without respect to the children.boolean
isNodeSimpleProperty
(OgnlContext context) boolean
isSimpleNavigationChain
(OgnlContext context) boolean
isSimpleProperty
(OgnlContext context) void
jjtAddChild
(Node n, int i) This method tells the node to add its argument to the node's list of children.void
jjtClose()
This method is called after all the child nodes have been added.jjtGetChild
(int i) This method returns a child node.int
Return the number of children the node has.void
jjtOpen()
This method is 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.protected boolean
lastChild
(OgnlContext context) void
setAccessor
(ExpressionAccessor accessor) Sets a new compiled accessor for this node expression.final void
setValue
(OgnlContext context, Object target, Object value) Sets the given value in the given target as appropriate for this node within the given context.protected void
setValueBody
(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
-
_parent
-
_children
-
_id
protected int _id -
_parser
-
-
Constructor Details
-
SimpleNode
public SimpleNode(int i) -
SimpleNode
-
-
Method Details
-
jjtOpen
public void jjtOpen()Description copied from interface:Node
This 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:Node
This method is called after all the child nodes have been added. -
jjtSetParent
Description copied from interface:Node
This pair of methods are used to inform the node of its parent.- Specified by:
jjtSetParent
in interfaceNode
-
jjtGetParent
- Specified by:
jjtGetParent
in interfaceNode
-
jjtAddChild
Description copied from interface:Node
This method tells the node to add its argument to the node's list of children.- Specified by:
jjtAddChild
in interfaceNode
-
jjtGetChild
Description copied from interface:Node
This method returns a child node. The children are numbered from zero, left to right.- Specified by:
jjtGetChild
in interfaceNode
-
jjtGetNumChildren
public int jjtGetNumChildren()Description copied from interface:Node
Return the number of children the node has.- Specified by:
jjtGetNumChildren
in interfaceNode
-
toString
-
toString
-
toGetSourceString
Description copied from interface:JavaSource
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.- Specified by:
toGetSourceString
in interfaceJavaSource
- Returns:
- Literal java string representation of an object get.
-
toSetSourceString
Description copied from interface:JavaSource
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.- Specified by:
toSetSourceString
in interfaceJavaSource
- Returns:
- Literal java string representation of an object get.
-
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:Node
Extracts the value from the given source object that is appropriate for this node within the given context.- Specified by:
getValue
in interfaceNode
- Throws:
OgnlException
-
getValueBody
Subclasses implement this method to do the actual work of extracting the appropriate value from the source object.- Throws:
OgnlException
-
setValue
Description copied from interface:Node
Sets the given value in the given target as appropriate for this node within the given context.- Specified by:
setValue
in interfaceNode
- Throws:
OgnlException
-
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.- Throws:
OgnlException
-
isNodeConstant
Returns true iff this node is constant without respect to the children.- Throws:
OgnlException
-
isConstant
- Throws:
OgnlException
-
isNodeSimpleProperty
- Throws:
OgnlException
-
isSimpleProperty
- 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:Node
Gets the compiled bytecode enhanced expression accessor for getting/setting values.- Specified by:
getAccessor
in interfaceNode
- Returns:
- The accessor for this node, or null if none has been compiled for it.
-
setAccessor
Description copied from interface:Node
Sets a new compiled accessor for this node expression.- Specified by:
setAccessor
in interfaceNode
- Parameters:
accessor
- The compiled representation of this node.
-