Package jadex.javaparser.javaccimpl
Class ExpressionNode
java.lang.Object
jadex.javaparser.javaccimpl.SimpleNode
jadex.javaparser.javaccimpl.ExpressionNode
- All Implemented Interfaces:
IParsedExpression,Node,Serializable
- Direct Known Subclasses:
ArgumentsNode,ArrayNode,BooleanNode,CastNode,CollectionNode,CompareNode,ConditionalNode,ConstantNode,MathNode,ParameterNode,ReflectNode,SelectionNode,SelectNode,TypeNode
Base class of expression node hierarchy.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanIs the node value constant (independent of evaluation context and parameters)?protected ObjectThe constant value (if any).protected StringThe expression text (if any).protected String[]The imports (if any).protected ClassThe static type (if any).protected StringThe token text (if any).Fields inherited from class jadex.javaparser.javaccimpl.SimpleNode
children, id, parent -
Constructor Summary
ConstructorsConstructorDescriptionExpressionNode(jadex.javaparser.javaccimpl.ParserImpl p, int id) Create an expression node. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendText(String text) Append to the token text.booleanTest if two nodes are equal.Get the constant value.Get the full expression text.Get the parameters used in the expression.Class<?>Get the static type.getText()Get the expression text.Get unbound parameter nodes.abstract ObjectgetValue(jadex.common.IValueFetcher fetcher) Evaluate the expression in the given state with respect to given parameters.inthashCode()Get the hash code for the node.booleanGet if the node is constant.voidThis method should be overridden to perform all possible checks and precompute all values (e.g.voidPrecompile this node and all subnodes.voidsetConstant(boolean constant) Set if the node is constant.voidsetConstantValue(Object constant_value) Set the constant value.voidsetExpressionText(String expressiontext) Get the full expression text.voidsetStaticType(Class static_type) Set the static type.voidSet the token text.protected StringsubnodeToString(int subnode) Create a string for a subnode.protected void(Re)throw an exception that occured during evaluation and add a useful error message.protected void(Re)throw an exception that occured during parsing and add a useful error message.Create a string representation of this node for dumping in a tree.toString()Create a string representation of this node for dumping in a tree.Create a string representation of this node for dumping in a tree.Methods inherited from class jadex.javaparser.javaccimpl.SimpleNode
dump, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent
-
Field Details
-
text
The token text (if any). -
expressiontext
The expression text (if any). -
imports
The imports (if any). -
static_type
The static type (if any). -
constant
protected boolean constantIs the node value constant (independent of evaluation context and parameters)? -
constant_value
The constant value (if any).
-
-
Constructor Details
-
ExpressionNode
public ExpressionNode(jadex.javaparser.javaccimpl.ParserImpl p, int id) Create an expression node.- Parameters:
p- The parser.id- The id.
-
-
Method Details
-
setExpressionText
Get the full expression text.- Parameters:
text- The expression text.
-
getExpressionText
Get the full expression text.- Specified by:
getExpressionTextin interfaceIParsedExpression- Returns:
- The expression text.
-
setText
Set the token text.- Parameters:
text- The token text.
-
appendText
Append to the token text.- Parameters:
text- The text to append.
-
setStaticType
Set the static type.- Parameters:
static_type- The static type.
-
setConstantValue
Set the constant value.- Parameters:
constant_value- The constant value.
-
getConstantValue
Get the constant value. The constant value of a node may be known, when it is independent of the evaluation context, and the child nodes are constant, too.- Returns:
- The constant value.
-
setConstant
public void setConstant(boolean constant) Set if the node is constant.- Parameters:
constant- The constant.
-
isConstant
public boolean isConstant()Get if the node is constant. The node is constant, when it is independent of the evaluation context, and the child nodes are constant, too.- Returns:
- The constant flag.
-
toString
Create a string representation of this node for dumping in a tree.- Overrides:
toStringin classSimpleNode- Returns:
- A string representation of this node.
-
toPlainString
Create a string representation of this node for dumping in a tree.- Specified by:
toPlainStringin interfaceNode- Returns:
- A string representation of this node.
-
toString
Create a string representation of this node for dumping in a tree.- Overrides:
toStringin classSimpleNode- Returns:
- A string representation of this node.
-
subnodeToString
Create a string for a subnode. Automatically adds braces if necessary.- Parameters:
subnode- The index of the subnode.- Returns:
- The string for the subnode.
-
getText
Get the expression text.- Returns:
- The text.
-
getValue
Evaluate the expression in the given state with respect to given parameters.- Specified by:
getValuein interfaceIParsedExpression- Parameters:
params- The parameters (string, value pairs), if any.- Returns:
- The value of the term.
-
getStaticType
Get the static type. If no information about the return type of an expression is available (e.g. because it depends on the evaluation context), the static type is null.- Specified by:
getStaticTypein interfaceIParsedExpression- Returns:
- The static type.
-
getParameters
Get the parameters used in the expression.- Specified by:
getParametersin interfaceIParsedExpression
-
getUnboundParameterNodes
Get unbound parameter nodes.- Returns:
- The unbound parameter nodes.
-
precompile
public void precompile()This method should be overridden to perform all possible checks and precompute all values (e.g. the static_type), which are independent of the evaluation context and parameters. -
precompileTree
public void precompileTree()Precompile this node and all subnodes. -
throwParseException
(Re)throw an exception that occured during parsing and add a useful error message.- Parameters:
ex- The exception to be rethrown (if any).- Throws:
ParseException
-
throwEvaluationException
(Re)throw an exception that occured during evaluation and add a useful error message.- Parameters:
ex- The exception to be rethrown (if any).- Throws:
RuntimeException
-
equals
Test if two nodes are equal. -
hashCode
public int hashCode()Get the hash code for the node.
-