org.apache.commons.jexl.parser
Class SimpleNode

java.lang.Object
  |
  +--org.apache.commons.jexl.parser.SimpleNode
All Implemented Interfaces:
Node
Direct Known Subclasses:
ASTAddNode, ASTAndNode, ASTArrayAccess, ASTAssignment, ASTBitwiseAndNode, ASTBitwiseComplNode, ASTBitwiseOrNode, ASTBitwiseXorNode, ASTBlock, ASTDivNode, ASTEmptyFunction, ASTEQNode, ASTExpression, ASTExpressionExpression, ASTFalseNode, ASTFloatLiteral, ASTForeachStatement, ASTGENode, ASTGTNode, ASTIdentifier, ASTIfStatement, ASTIntegerLiteral, ASTJexlScript, ASTLENode, ASTLTNode, ASTMethod, ASTModNode, ASTMulNode, ASTNENode, ASTNotNode, ASTNullLiteral, ASTOrNode, ASTReference, ASTReferenceExpression, ASTSizeFunction, ASTSizeMethod, ASTStatementExpression, ASTStringLiteral, ASTSubtractNode, ASTTrueNode, ASTUnaryMinusNode, ASTWhileStatement

public class SimpleNode
extends Object
implements Node

A Useful implementation of Node. Mostly autogenerated by javacc

Version:
$Id: SimpleNode.java 398328 2006-04-30 12:46:59Z dion $

Field Summary
protected  Node[] children
          children of this node.
protected  int id
          id of the node.
protected  Node parent
          parent node.
protected  Parser parser
          parser that created the node.
 
Constructor Summary
SimpleNode(int i)
          Create the node given an id.
SimpleNode(Parser p, int i)
          Create a node with the given parser and id.
 
Method Summary
 Object childrenAccept(ParserVisitor visitor, Object data)
          Visit all children.
 void dump(String prefix)
          Dump the node and all children.
 Object execute(Object o, JexlContext ctx)
          Used to let a node calcuate it's value..
 boolean interpret(JexlContext pc)
          basic interpret - just invoke interpret on all children.
 Object jjtAccept(ParserVisitor visitor, Object data)
          Accept the visitor.
 void jjtAddChild(Node n, int i)
          This method tells the node to add its argument to the node's list of children.
 void jjtClose()
          End of the node.
 Node jjtGetChild(int i)
          This method returns a child node. The children are numbered from zero, left to right.
 int jjtGetNumChildren()
          Gets the number of children the node has.
 Node jjtGetParent()
          Gets the parent node.
 void jjtOpen()
          Start of the node.
 void jjtSetParent(Node n)
          This pair of methods are used to inform the node of its parent.
 Object setValue(JexlContext context, Object value)
          Sets the value for the node - again, only makes sense for some nodes but lazyness tempts me to put it here.
 String toString()
          Gets a string representation of the node.
 String toString(String prefix)
          Used during dumping to output the node with a prefix.
 Object value(JexlContext context)
          Gets the value of this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected Node parent
parent node.


children

protected Node[] children
children of this node.


id

protected int id
id of the node.


parser

protected Parser parser
parser that created the node.

Constructor Detail

SimpleNode

public SimpleNode(int i)
Create the node given an id.

Parameters:
i - node id.

SimpleNode

public SimpleNode(Parser p,
                  int i)
Create a node with the given parser and id.

Parameters:
p - a parser.
i - node id.
Method Detail

jjtOpen

public void jjtOpen()
Start of the node.

Specified by:
jjtOpen in interface Node

jjtClose

public void jjtClose()
End of the node.

Specified by:
jjtClose in interface Node

jjtSetParent

public void jjtSetParent(Node n)
This pair of methods are used to inform the node of its parent.

Specified by:
jjtSetParent in interface Node
Parameters:
n - the parent node.

jjtGetParent

public Node jjtGetParent()
Gets the parent node.

Specified by:
jjtGetParent in interface Node
Returns:
the parent to this node.

jjtAddChild

public void jjtAddChild(Node n,
                        int i)
This method tells the node to add its argument to the node's list of children.

Specified by:
jjtAddChild in interface Node
Parameters:
n - the child node to add
i - the index to add it at.

jjtGetChild

public Node jjtGetChild(int i)
This method returns a child node. The children are numbered from zero, left to right.

Specified by:
jjtGetChild in interface Node
Parameters:
i - the index of the child to get.
Returns:
the child at the given index.

jjtGetNumChildren

public int jjtGetNumChildren()
Gets the number of children the node has.

Specified by:
jjtGetNumChildren in interface Node
Returns:
the number of children the node has.

jjtAccept

public Object jjtAccept(ParserVisitor visitor,
                        Object data)
Accept the visitor.

Specified by:
jjtAccept in interface Node
Parameters:
visitor - a ParserVisitor.
data - data to be passed along to the visitor.
Returns:
the value from visiting.
See Also:
ParserVisitor.visit(org.apache.commons.jexl.parser.SimpleNode, java.lang.Object)

childrenAccept

public Object childrenAccept(ParserVisitor visitor,
                             Object data)
Visit all children.

Parameters:
visitor - a ParserVisitor.
data - data to be passed along to the visitor.
Returns:
the value from visiting.
See Also:
ParserVisitor.visit(org.apache.commons.jexl.parser.SimpleNode, java.lang.Object)

toString

public String toString()
Gets a string representation of the node.

Overrides:
toString in class Object
Returns:
the node name.

toString

public String toString(String prefix)
Used during dumping to output the node with a prefix.

Parameters:
prefix - text to prefix toString()
Returns:
text.

dump

public void dump(String prefix)
Dump the node and all children.

Parameters:
prefix - text to prefix the node output.

interpret

public boolean interpret(JexlContext pc)
                  throws Exception
basic interpret - just invoke interpret on all children.

Parameters:
pc - the context to interpret against.
Returns:
true if interpretation worked.
Throws:
Exception - on any error.

value

public Object value(JexlContext context)
             throws Exception
Gets the value of this node.

Parameters:
context - the context to retrieve values from.
Returns:
the value of the node.
Throws:
Exception - when evaluating the operands fails.

setValue

public Object setValue(JexlContext context,
                       Object value)
                throws Exception
Sets the value for the node - again, only makes sense for some nodes but lazyness tempts me to put it here. Keeps things simple.

Parameters:
context - the context to retrieve values from.
value - the value.
Returns:
the result.
Throws:
Exception - when evaluating the operands fails.

execute

public Object execute(Object o,
                      JexlContext ctx)
               throws Exception
Used to let a node calcuate it's value..

Parameters:
o - the object to calculate with.
ctx - the context to retrieve values from.
Returns:
the result of the calculation.
Throws:
Exception - when calculating the value fails.


Copyright © 2003-2006 The Apache Software Foundation. All Rights Reserved.