org.apache.velocity.runtime.parser.node
Class ASTMathNode

java.lang.Object
  extended by org.apache.velocity.runtime.parser.node.SimpleNode
      extended by 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 $
Author:
Will Glass-Husain, Peter Romianowski, Jason van Zyl, Geir Magnusson Jr., Nathan Bubna

Field Summary
protected  boolean strictMode
           
 
Fields inherited from class org.apache.velocity.runtime.parser.node.SimpleNode
children, first, id, info, invalid, last, log, parent, parser, rsvc, state, templateName
 
Constructor Summary
ASTMathNode(int id)
           
ASTMathNode(Parser p, int id)
           
 
Method Summary
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(ParserVisitor 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.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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

strictMode

protected boolean strictMode
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 interface Node
Overrides:
init in class SimpleNode
Returns:
The init result.
Throws:
TemplateInitException
See Also:
Node.init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)

jjtAccept

public Object jjtAccept(ParserVisitor visitor,
                        Object data)

Specified by:
jjtAccept in interface Node
Overrides:
jjtAccept in class SimpleNode
Returns:
The Node execution result object.
See Also:
Node.jjtAccept(org.apache.velocity.runtime.parser.node.ParserVisitor, 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 interface Node
Overrides:
value in class SimpleNode
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.

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.



Copyright © 2000-2012 The Apache Software Foundation. All Rights Reserved.