Package jadex.javaparser.javaccimpl
Class ExpressionNode
- java.lang.Object
-
- jadex.javaparser.javaccimpl.SimpleNode
-
- jadex.javaparser.javaccimpl.ExpressionNode
-
- All Implemented Interfaces:
IParsedExpression,Node,java.io.Serializable
- Direct Known Subclasses:
ArgumentsNode,ArrayNode,BooleanNode,CastNode,CollectionNode,CompareNode,ConditionalNode,ConstantNode,MathNode,ParameterNode,ReflectNode,SelectionNode,SelectNode,TypeNode
public abstract class ExpressionNode extends SimpleNode implements IParsedExpression
Base class of expression node hierarchy.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanconstantIs the node value constant (independent of evaluation context and parameters)?protected java.lang.Objectconstant_valueThe constant value (if any).protected java.lang.StringexpressiontextThe expression text (if any).protected java.lang.String[]importsThe imports (if any).protected java.lang.Classstatic_typeThe static type (if any).protected java.lang.StringtextThe token text (if any).-
Fields inherited from class jadex.javaparser.javaccimpl.SimpleNode
children, id, parent
-
-
Constructor Summary
Constructors Constructor Description ExpressionNode(jadex.javaparser.javaccimpl.ParserImpl p, int id)Create an expression node.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidappendText(java.lang.String text)Append to the token text.booleanequals(java.lang.Object o)Test if two nodes are equal.java.lang.ObjectgetConstantValue()Get the constant value.java.lang.StringgetExpressionText()Get the full expression text.java.util.Set<java.lang.String>getParameters()Get the parameters used in the expression.java.lang.Class<?>getStaticType()Get the static type.java.lang.StringgetText()Get the expression text.ParameterNode[]getUnboundParameterNodes()Get unbound parameter nodes.abstract java.lang.ObjectgetValue(IValueFetcher fetcher)Evaluate the expression in the given state with respect to given parameters.inthashCode()Get the hash code for the node.booleanisConstant()Get if the node is constant.voidprecompile()This method should be overridden to perform all possible checks and precompute all values (e.g.voidprecompileTree()Precompile this node and all subnodes.voidsetConstant(boolean constant)Set if the node is constant.voidsetConstantValue(java.lang.Object constant_value)Set the constant value.voidsetExpressionText(java.lang.String expressiontext)Get the full expression text.voidsetStaticType(java.lang.Class static_type)Set the static type.voidsetText(java.lang.String text)Set the token text.protected java.lang.StringsubnodeToString(int subnode)Create a string for a subnode.protected voidthrowEvaluationException(java.lang.Throwable ex)(Re)throw an exception that occured during evaluation and add a useful error message.protected voidthrowParseException(java.lang.Throwable ex)(Re)throw an exception that occured during parsing and add a useful error message.java.lang.StringtoPlainString()Create a string representation of this node for dumping in a tree.java.lang.StringtoString()Create a string representation of this node for dumping in a tree.java.lang.StringtoString(java.lang.String prefix)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 Detail
-
text
protected java.lang.String text
The token text (if any).
-
expressiontext
protected java.lang.String expressiontext
The expression text (if any).
-
imports
protected java.lang.String[] imports
The imports (if any).
-
static_type
protected java.lang.Class static_type
The static type (if any).
-
constant
protected boolean constant
Is the node value constant (independent of evaluation context and parameters)?
-
constant_value
protected java.lang.Object constant_value
The constant value (if any).
-
-
Method Detail
-
setExpressionText
public void setExpressionText(java.lang.String expressiontext)
Get the full expression text.- Parameters:
text- The expression text.
-
getExpressionText
public java.lang.String getExpressionText()
Get the full expression text.- Specified by:
getExpressionTextin interfaceIParsedExpression- Returns:
- The expression text.
-
setText
public void setText(java.lang.String text)
Set the token text.- Parameters:
text- The token text.
-
appendText
public void appendText(java.lang.String text)
Append to the token text.- Parameters:
text- The text to append.
-
setStaticType
public void setStaticType(java.lang.Class static_type)
Set the static type.- Parameters:
static_type- The static type.
-
setConstantValue
public void setConstantValue(java.lang.Object constant_value)
Set the constant value.- Parameters:
constant_value- The constant value.
-
getConstantValue
public java.lang.Object 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
public java.lang.String toString(java.lang.String prefix)
Create a string representation of this node for dumping in a tree.- Overrides:
toStringin classSimpleNode- Returns:
- A string representation of this node.
-
toPlainString
public java.lang.String 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
public java.lang.String toString()
Create a string representation of this node for dumping in a tree.- Overrides:
toStringin classSimpleNode- Returns:
- A string representation of this node.
-
subnodeToString
protected java.lang.String subnodeToString(int subnode)
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
public java.lang.String getText()
Get the expression text.- Returns:
- The text.
-
getValue
public abstract java.lang.Object getValue(IValueFetcher fetcher)
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
public java.lang.Class<?> 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
public java.util.Set<java.lang.String> getParameters()
Get the parameters used in the expression.- Specified by:
getParametersin interfaceIParsedExpression
-
getUnboundParameterNodes
public ParameterNode[] 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
protected void throwParseException(java.lang.Throwable ex) throws ParseException(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
protected void throwEvaluationException(java.lang.Throwable ex) throws java.lang.RuntimeException(Re)throw an exception that occured during evaluation and add a useful error message.- Parameters:
ex- The exception to be rethrown (if any).- Throws:
java.lang.RuntimeException
-
equals
public boolean equals(java.lang.Object o)
Test if two nodes are equal.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Get the hash code for the node.- Overrides:
hashCodein classjava.lang.Object
-
-