public abstract class ExpressionNode extends SimpleNode implements IParsedExpression
Modifier and Type | Field and Description |
---|---|
protected boolean |
constant
Is the node value constant
(independent of evaluation context and parameters)?
|
protected java.lang.Object |
constant_value
The constant value (if any).
|
protected java.lang.String |
expressiontext
The expression text (if any).
|
protected java.lang.String[] |
imports
The imports (if any).
|
protected java.lang.Class |
static_type
The static type (if any).
|
protected java.lang.String |
text
The token text (if any).
|
children, id, parent
Constructor and Description |
---|
ExpressionNode(ParserImpl p,
int id)
Create an expression node.
|
Modifier and Type | Method and Description |
---|---|
void |
appendText(java.lang.String text)
Append to the token text.
|
boolean |
equals(java.lang.Object o)
Test if two nodes are equal.
|
java.lang.Object |
getConstantValue()
Get the constant value.
|
java.lang.String |
getExpressionText()
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.String |
getText()
Get the expression text.
|
ParameterNode[] |
getUnboundParameterNodes()
Get unbound parameter nodes.
|
abstract java.lang.Object |
getValue(IValueFetcher fetcher)
Evaluate the expression in the given state
with respect to given parameters.
|
int |
hashCode()
Get the hash code for the node.
|
boolean |
isConstant()
Get if the node is constant.
|
void |
precompile()
This method should be overridden to perform
all possible checks and precompute all values
(e.g.
|
void |
precompileTree()
Precompile this node and all subnodes.
|
void |
setConstant(boolean constant)
Set if the node is constant.
|
void |
setConstantValue(java.lang.Object constant_value)
Set the constant value.
|
void |
setExpressionText(java.lang.String expressiontext)
Get the full expression text.
|
void |
setStaticType(java.lang.Class static_type)
Set the static type.
|
void |
setText(java.lang.String text)
Set the token text.
|
protected java.lang.String |
subnodeToString(int subnode)
Create a string for a subnode.
|
protected void |
throwEvaluationException(java.lang.Throwable ex)
(Re)throw an exception that occured during evaluation
and add a useful error message.
|
protected void |
throwParseException(java.lang.Throwable ex)
(Re)throw an exception that occured during parsing
and add a useful error message.
|
java.lang.String |
toPlainString()
Create a string representation of this node for dumping in a tree.
|
java.lang.String |
toString()
Create a string representation of this node for dumping in a tree.
|
java.lang.String |
toString(java.lang.String prefix)
Create a string representation of this node for dumping in a tree.
|
dump, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent
protected java.lang.String text
protected java.lang.String expressiontext
protected java.lang.String[] imports
protected java.lang.Class static_type
protected boolean constant
protected java.lang.Object constant_value
public ExpressionNode(ParserImpl p, int id)
p
- The parser.id
- The id.public void setExpressionText(java.lang.String expressiontext)
text
- The expression text.public java.lang.String getExpressionText()
getExpressionText
in interface IParsedExpression
public void setText(java.lang.String text)
text
- The token text.public void appendText(java.lang.String text)
text
- The text to append.public void setStaticType(java.lang.Class static_type)
static_type
- The static type.public void setConstantValue(java.lang.Object constant_value)
constant_value
- The constant value.public java.lang.Object getConstantValue()
public void setConstant(boolean constant)
constant
- The constant.public boolean isConstant()
public java.lang.String toString(java.lang.String prefix)
toString
in class SimpleNode
public java.lang.String toPlainString()
toPlainString
in interface Node
public java.lang.String toString()
toString
in class SimpleNode
protected java.lang.String subnodeToString(int subnode)
subnode
- The index of the subnode.public java.lang.String getText()
public abstract java.lang.Object getValue(IValueFetcher fetcher)
getValue
in interface IParsedExpression
params
- The parameters (string, value pairs), if any.public java.lang.Class<?> getStaticType()
getStaticType
in interface IParsedExpression
public java.util.Set<java.lang.String> getParameters()
getParameters
in interface IParsedExpression
public ParameterNode[] getUnboundParameterNodes()
public void precompile()
public void precompileTree()
protected void throwParseException(java.lang.Throwable ex) throws ParseException
ex
- The exception to be rethrown (if any).ParseException
protected void throwEvaluationException(java.lang.Throwable ex) throws java.lang.RuntimeException
ex
- The exception to be rethrown (if any).java.lang.RuntimeException
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object