Class ASTComparisonNode
- java.lang.Object
-
- org.apache.velocity.runtime.parser.node.SimpleNode
-
- org.apache.velocity.runtime.parser.node.ASTBinaryOperator
-
- org.apache.velocity.runtime.parser.node.ASTComparisonNode
-
- All Implemented Interfaces:
Cloneable
,Node
,Renderable
public abstract class ASTComparisonNode extends ASTBinaryOperator
Numeric comparison support- Author:
- Will Glass-Husain, Peter Romianowski, Nathan Bubna
-
-
Constructor Summary
Constructors Constructor Description ASTComparisonNode(int id)
ASTComparisonNode(Parser p, int id)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
compareNonNumber(Object left, Object right)
boolean
compareNull(Object left, Object right)
Always false by default, != and == subclasses must override this.Boolean
compareNumbers(Object left, Object right)
compare numbersboolean
evaluate(InternalContextAdapter context)
abstract String
getLiteralOperator()
get the string representing the mathematical operatorObject
jjtAccept(StandardParserVisitor visitor, Object data)
abstract boolean
numberTest(int compareResult)
performs the actual comparisonObject
value(InternalContextAdapter context)
-
Methods inherited from class org.apache.velocity.runtime.parser.node.ASTBinaryOperator
init, literal
-
Methods inherited from class org.apache.velocity.runtime.parser.node.SimpleNode
childrenAccept, cleanupParserAndTokens, clone, clone, dump, dump, dump, 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
-
ASTComparisonNode
public ASTComparisonNode(int id)
- Parameters:
id
-
-
ASTComparisonNode
public ASTComparisonNode(Parser p, int id)
- Parameters:
p
-id
-
-
-
Method Detail
-
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:
SimpleNode.jjtAccept(org.apache.velocity.runtime.parser.node.StandardParserVisitor, java.lang.Object)
-
evaluate
public boolean evaluate(InternalContextAdapter context) throws MethodInvocationException
- Specified by:
evaluate
in interfaceNode
- Overrides:
evaluate
in classSimpleNode
- Returns:
- The evaluation result.
- Throws:
MethodInvocationException
- See Also:
SimpleNode.evaluate(org.apache.velocity.context.InternalContextAdapter)
-
compareNull
public boolean compareNull(Object left, Object right)
Always false by default, != and == subclasses must override this.- Parameters:
left
-right
-- Returns:
- comparison result
-
compareNumbers
public Boolean compareNumbers(Object left, Object right)
compare numbers- Parameters:
left
-right
-- Returns:
- comparison result
-
getLiteralOperator
public abstract String getLiteralOperator()
get the string representing the mathematical operator- Specified by:
getLiteralOperator
in classASTBinaryOperator
- Returns:
- operator string
-
numberTest
public abstract boolean numberTest(int compareResult)
performs the actual comparison- Parameters:
compareResult
-- Returns:
- comparison result
-
value
public Object value(InternalContextAdapter context) throws MethodInvocationException
- Specified by:
value
in interfaceNode
- Overrides:
value
in classSimpleNode
- Returns:
- The node value.
- Throws:
MethodInvocationException
- See Also:
SimpleNode.value(org.apache.velocity.context.InternalContextAdapter)
-
-