org.apache.commons.jexl.parser
Class ASTMethod

java.lang.Object
  extended by org.apache.commons.jexl.parser.SimpleNode
      extended by org.apache.commons.jexl.parser.ASTMethod
All Implemented Interfaces:
Node

public class ASTMethod
extends SimpleNode

Method execution.


Field Summary
private static Info DUMMY
          dummy velocity info.
 
Fields inherited from class org.apache.commons.jexl.parser.SimpleNode
children, id, parent, parser
 
Constructor Summary
ASTMethod(int id)
          Create the node given an id.
ASTMethod(Parser p, int id)
          Create a node with the given parser and id.
 
Method Summary
 java.lang.Object execute(java.lang.Object obj, JexlContext jc)
          evaluate a method invocation upon a base object.
 java.lang.Object jjtAccept(ParserVisitor visitor, java.lang.Object data)
          Accept the visitor.
private  java.lang.Number narrow(java.lang.Number original)
          Given a Number, return back the value using the smallest type the result will fit into.
 
Methods inherited from class org.apache.commons.jexl.parser.SimpleNode
childrenAccept, dump, interpret, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, setValue, toString, toString, value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DUMMY

private static final Info DUMMY
dummy velocity info.

Constructor Detail

ASTMethod

public ASTMethod(int id)
Create the node given an id.

Parameters:
id - node id.

ASTMethod

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

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

jjtAccept

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

Specified by:
jjtAccept in interface Node
Overrides:
jjtAccept in class SimpleNode
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)

execute

public java.lang.Object execute(java.lang.Object obj,
                                JexlContext jc)
                         throws java.lang.Exception
evaluate a method invocation upon a base object. foo.bar(2)

Overrides:
execute in class SimpleNode
Parameters:
jc - the JexlContext to evaluate against.
obj - The object to have the method invoked.
Returns:
the value of the method invocation.
Throws:
java.lang.Exception - on any error

narrow

private java.lang.Number narrow(java.lang.Number original)
Given a Number, return back the value using the smallest type the result will fit into. This works hand in hand with parameter 'widening' in java method calls, e.g. a call to substring(int,int) with an int and a long will fail, but a call to substring(int,int) with an int and a short will succeed.

Parameters:
original - the original number.
Returns:
a value of the smallest type the original number will fit into.
Since:
1.1