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 boolean
Is the node value constant (independent of evaluation context and parameters)?protected Object
The constant value (if any).protected String
The expression text (if any).protected String[]
The imports (if any).protected Class
The static type (if any).protected String
The 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 TypeMethodDescriptionvoid
appendText
(String text) Append to the token text.boolean
Test 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 Object
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.boolean
Get if the node is constant.void
This method should be overridden to perform all possible checks and precompute all values (e.g.void
Precompile this node and all subnodes.void
setConstant
(boolean constant) Set if the node is constant.void
setConstantValue
(Object constant_value) Set the constant value.void
setExpressionText
(String expressiontext) Get the full expression text.void
setStaticType
(Class static_type) Set the static type.void
Set the token text.protected String
subnodeToString
(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:
getExpressionText
in 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:
toString
in classSimpleNode
- Returns:
- A string representation of this node.
-
toPlainString
Create a string representation of this node for dumping in a tree.- Specified by:
toPlainString
in interfaceNode
- Returns:
- A string representation of this node.
-
toString
Create a string representation of this node for dumping in a tree.- Overrides:
toString
in 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:
getValue
in 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:
getStaticType
in interfaceIParsedExpression
- Returns:
- The static type.
-
getParameters
Get the parameters used in the expression.- Specified by:
getParameters
in 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.
-