Package jadex.javaparser.javaccimpl
Class CompareNode
java.lang.Object
jadex.javaparser.javaccimpl.SimpleNode
jadex.javaparser.javaccimpl.ExpressionNode
jadex.javaparser.javaccimpl.CompareNode
- All Implemented Interfaces:
IParsedExpression
,Node
,Serializable
Compare node compares it's (two) child nodes.
Also supports instanceof operator
(second child has to evaluate to class object).
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The equal (==) operator.static final int
The greater-than (>) operator.static final int
The greater-equal (>=) operator.static final int
The instanceof operator.static final int
The less-than (invalid input: '<') operator.static final int
The less-equal (invalid input: '<'=) operator.protected int
The operation.static final int
The unequal (!=) operator.Fields inherited from class jadex.javaparser.javaccimpl.ExpressionNode
constant, constant_value, expressiontext, imports, static_type, text
Fields inherited from class jadex.javaparser.javaccimpl.SimpleNode
children, id, parent
-
Constructor Summary
ConstructorsConstructorDescriptionCompareNode
(jadex.javaparser.javaccimpl.ParserImpl p, int id) Create a node. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Compare two values.boolean
Test if two nodes are equal.static int
fromString
(String operator) Convert an operator from a string representation.getValue
(jadex.common.IValueFetcher fetcher) Evaluate the expression in the given state with respect to given parameters.int
hashCode()
Get the hash code for the node.void
Check argument number, and precompute expression when all children are constant.void
Set the token text.Create a string representation of this node and its subnodes.static String
toString
(int operator) Convert an operator to a string representation.Methods inherited from class jadex.javaparser.javaccimpl.ExpressionNode
appendText, getConstantValue, getExpressionText, getParameters, getStaticType, getText, getUnboundParameterNodes, isConstant, precompileTree, setConstant, setConstantValue, setExpressionText, setStaticType, subnodeToString, throwEvaluationException, throwParseException, toString, toString
Methods inherited from class jadex.javaparser.javaccimpl.SimpleNode
dump, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent
-
Field Details
-
EQUAL
public static final int EQUALThe equal (==) operator.- See Also:
-
UNEQUAL
public static final int UNEQUALThe unequal (!=) operator.- See Also:
-
GREATER
public static final int GREATERThe greater-than (>) operator.- See Also:
-
LESS
public static final int LESSThe less-than (invalid input: '<') operator.- See Also:
-
GREATEREQUAL
public static final int GREATEREQUALThe greater-equal (>=) operator.- See Also:
-
LESSEQUAL
public static final int LESSEQUALThe less-equal (invalid input: '<'=) operator.- See Also:
-
INSTANCEOF
public static final int INSTANCEOFThe instanceof operator.- See Also:
-
op
protected int opThe operation.
-
-
Constructor Details
-
CompareNode
public CompareNode(jadex.javaparser.javaccimpl.ParserImpl p, int id) Create a node.- Parameters:
p
- The parser.id
- The id.
-
-
Method Details
-
setText
Set the token text.- Overrides:
setText
in classExpressionNode
- Parameters:
text
- The token text.
-
precompile
public void precompile()Check argument number, and precompute expression when all children are constant.- Overrides:
precompile
in classExpressionNode
-
getValue
Evaluate the expression in the given state with respect to given parameters.- Specified by:
getValue
in interfaceIParsedExpression
- Specified by:
getValue
in classExpressionNode
- Parameters:
params
- The parameters (string, value pairs), if any.- Returns:
- The value of the term.
-
toPlainString
Create a string representation of this node and its subnodes.- Specified by:
toPlainString
in interfaceNode
- Overrides:
toPlainString
in classExpressionNode
- Returns:
- A string representation of this node.
-
compare
Compare two values.- Parameters:
val1
- The first value.val2
- The second value.- Returns:
- A negative integer, zero, or a positive integer as the first value is less than, equal to, or greater than the second value.
- Throws:
ClassCastException
- when the values are not comparable.
-
toString
Convert an operator to a string representation.- Parameters:
operator
- The operator- Returns:
- A string representation of the operator.
-
fromString
Convert an operator from a string representation.- Parameters:
operator
- The operator as string.- Returns:
- The int value of the operator.
-
equals
Test if two nodes are equal.- Overrides:
equals
in classExpressionNode
-
hashCode
public int hashCode()Get the hash code for the node.- Overrides:
hashCode
in classExpressionNode
-