Class ASTMathNode
- java.lang.Object
-
- org.apache.velocity.runtime.parser.node.SimpleNode
-
- org.apache.velocity.runtime.parser.node.ASTBinaryOperator
-
- org.apache.velocity.runtime.parser.node.ASTMathNode
-
- All Implemented Interfaces:
Cloneable
,Node
,Renderable
- Direct Known Subclasses:
ASTAddNode
,ASTDivNode
,ASTModNode
,ASTMulNode
,ASTSubtractNode
public abstract class ASTMathNode extends ASTBinaryOperator
Helps handle math
Please look at the Parser.jjt file which is what controls the generation of this class.- Version:
- $Id: ASTMathNode.java 517553 2007-03-13 06:09:58Z wglass $
- Author:
- Will Glass-Husain, Peter Romianowski, Jason van Zyl, Geir Magnusson Jr., Nathan Bubna
-
-
Constructor Summary
Constructors Constructor Description ASTMathNode(int id)
ASTMathNode(Parser p, int id)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Object
handleSpecial(Object left, Object right, InternalContextAdapter context)
Extension hook to allow special behavior by subclasses If this method returns a non-null value, that is returned, rather than the result of the math operation.Object
init(InternalContextAdapter context, Object data)
Object
jjtAccept(StandardParserVisitor visitor, Object data)
abstract Number
perform(Number left, Number right, InternalContextAdapter context)
Performs the math operation represented by this node.Object
value(InternalContextAdapter context)
gets the two args and performs the operation on them-
Methods inherited from class org.apache.velocity.runtime.parser.node.ASTBinaryOperator
getLiteralOperator, literal
-
Methods inherited from class org.apache.velocity.runtime.parser.node.SimpleNode
childrenAccept, cleanupParserAndTokens, clone, clone, dump, dump, dump, evaluate, execute, getColumn, getFirstToken, getFirstTokenImage, getInfo, getLastToken, getLastTokenImage, getLine, getLocation, getParser, getRuntimeServices, getTemplate, getTemplateName, getType, isInvalid, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, render, saveTokenImages, setFirstToken, setInfo, setInvalid, toString, toString
-
-
-
-
Constructor Detail
-
ASTMathNode
public ASTMathNode(int id)
-
ASTMathNode
public ASTMathNode(Parser p, int id)
-
-
Method Detail
-
init
public Object init(InternalContextAdapter context, Object data) throws TemplateInitException
- Specified by:
init
in interfaceNode
- Overrides:
init
in classASTBinaryOperator
- Returns:
- The init result.
- Throws:
TemplateInitException
- See Also:
Node.init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
-
jjtAccept
public Object jjtAccept(StandardParserVisitor visitor, Object data)
- Specified by:
jjtAccept
in interfaceNode
- Overrides:
jjtAccept
in classSimpleNode
- Returns:
- The Node execution result object.
- See Also:
Node.jjtAccept(org.apache.velocity.runtime.parser.node.StandardParserVisitor, java.lang.Object)
-
value
public Object value(InternalContextAdapter context) throws MethodInvocationException
gets the two args and performs the operation on them- Specified by:
value
in interfaceNode
- Overrides:
value
in classSimpleNode
- Parameters:
context
-- Returns:
- result or null
- Throws:
MethodInvocationException
- See Also:
Node.value(org.apache.velocity.context.InternalContextAdapter)
-
handleSpecial
protected Object handleSpecial(Object left, Object right, InternalContextAdapter context)
Extension hook to allow special behavior by subclasses If this method returns a non-null value, that is returned, rather than the result of the math operation.- Parameters:
left
-right
-context
-- Returns:
- special value
- See Also:
ASTAddNode.handleSpecial(java.lang.Object, java.lang.Object, org.apache.velocity.context.InternalContextAdapter)
-
perform
public abstract Number perform(Number left, Number right, InternalContextAdapter context)
Performs the math operation represented by this node.- Parameters:
left
-right
-context
-- Returns:
- computed value
- See Also:
ASTAddNode.perform(Number, Number, InternalContextAdapter)
-
-