Class ASTMathNode
- java.lang.Object
-
- org.apache.velocity.runtime.parser.node.SimpleNode
-
- org.apache.velocity.runtime.parser.node.ASTMathNode
-
- All Implemented Interfaces:
Node
,Renderable
- Direct Known Subclasses:
ASTAddNode
,ASTDivNode
,ASTModNode
,ASTMulNode
,ASTSubtractNode
public abstract class ASTMathNode extends SimpleNode
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 $
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
strictMode
-
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 java.lang.Object
handleSpecial(java.lang.Object left, java.lang.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.java.lang.Object
init(InternalContextAdapter context, java.lang.Object data)
java.lang.Object
jjtAccept(ParserVisitor visitor, java.lang.Object data)
abstract java.lang.Number
perform(java.lang.Number left, java.lang.Number right, InternalContextAdapter context)
Performs the math operation represented by this node.java.lang.Object
value(InternalContextAdapter context)
gets the two args and performs the operation on them-
Methods inherited from class org.apache.velocity.runtime.parser.node.SimpleNode
childrenAccept, dump, evaluate, execute, getColumn, getFirstToken, getInfo, getLastToken, getLine, getLocation, getRuntimeServices, getTemplateName, getType, isInvalid, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, literal, render, setFirstToken, setInfo, setInvalid, toString, toString
-
-
-
-
Constructor Detail
-
ASTMathNode
public ASTMathNode(int id)
-
ASTMathNode
public ASTMathNode(Parser p, int id)
-
-
Method Detail
-
init
public java.lang.Object init(InternalContextAdapter context, java.lang.Object data) throws TemplateInitException
- Specified by:
init
in interfaceNode
- Overrides:
init
in classSimpleNode
- Returns:
- The init result.
- Throws:
TemplateInitException
- See Also:
Node.init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
-
jjtAccept
public java.lang.Object jjtAccept(ParserVisitor visitor, java.lang.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.ParserVisitor, java.lang.Object)
-
value
public java.lang.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 java.lang.Object handleSpecial(java.lang.Object left, java.lang.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.
-
perform
public abstract java.lang.Number perform(java.lang.Number left, java.lang.Number right, InternalContextAdapter context)
Performs the math operation represented by this node.
-
-