Package org.camunda.bpm.engine.impl.juel
Class TreeValueExpression
- java.lang.Object
-
- org.camunda.bpm.engine.impl.javax.el.Expression
-
- org.camunda.bpm.engine.impl.javax.el.ValueExpression
-
- org.camunda.bpm.engine.impl.juel.TreeValueExpression
-
- All Implemented Interfaces:
Serializable
public final class TreeValueExpression extends ValueExpression
A value expression is ready to be evaluated (by calling eithergetType(ELContext)
,getValue(ELContext)
,isReadOnly(ELContext)
orsetValue(ELContext, Object)
. Instances of this class are usually created using anExpressionFactoryImpl
.- Author:
- Christoph Beck
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TreeValueExpression(TreeStore store, FunctionMapper functions, VariableMapper variables, TypeConverter converter, String expr, Class<?> type)
Create a new value expression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dump(PrintWriter writer)
Print the parse tree.boolean
equals(Object obj)
Expressions are compared using the concept of a structural id: variable and function names are anonymized such that two expressions with same tree structure will also have the same structural id and vice versa.Class<?>
getExpectedType()
Returns the type the result of the expression will be coerced to after evaluation.String
getExpressionString()
Returns the original String used to create this Expression, unmodified.Class<?>
getType(ELContext context)
Evaluates the expression as an lvalue and answers the result type.Object
getValue(ELContext context)
Evaluates the expression as an rvalue and answers the result.ValueReference
getValueReference(ELContext context)
Returns aValueReference
for this expression instance.int
hashCode()
Returns the hash code for this Expression.boolean
isDeferred()
Answertrue
if this is a deferred expression (containing sub-expressions starting with#{
)boolean
isLeftValue()
Answertrue
if this could be used as an lvalue.boolean
isLiteralText()
Returns whether this expression was created from only literal text.boolean
isReadOnly(ELContext context)
Evaluates the expression as an lvalue and determines ifsetValue(ELContext, Object)
will always fail.void
setValue(ELContext context, Object value)
Evaluates the expression as an lvalue and assigns the given value.String
toString()
-
-
-
Constructor Detail
-
TreeValueExpression
public TreeValueExpression(TreeStore store, FunctionMapper functions, VariableMapper variables, TypeConverter converter, String expr, Class<?> type)
Create a new value expression.- Parameters:
store
- used to get the parse tree from.functions
- the function mapper used to bind functionsvariables
- the variable mapper used to bind variablesexpr
- the expression stringtype
- the expected type (may benull
)
-
-
Method Detail
-
getExpectedType
public Class<?> getExpectedType()
Description copied from class:ValueExpression
Returns the type the result of the expression will be coerced to after evaluation.- Specified by:
getExpectedType
in classValueExpression
- Returns:
- the expectedType passed to the ExpressionFactory.createValueExpression method that created this ValueExpression.
-
getExpressionString
public String getExpressionString()
Description copied from class:Expression
Returns the original String used to create this Expression, unmodified. This is used for debugging purposes but also for the purposes of comparison (e.g. to ensure the expression in a configuration file has not changed). This method does not provide sufficient information to re-create an expression. Two different expressions can have exactly the same expression string but different function mappings. Serialization should be used to save and restore the state of an Expression.- Specified by:
getExpressionString
in classExpression
- Returns:
- The original expression String.
-
getType
public Class<?> getType(ELContext context) throws ELException
Evaluates the expression as an lvalue and answers the result type.- Specified by:
getType
in classValueExpression
- Parameters:
context
- used to resolve properties (base.property
andbase[property]
) and to determine the result from the last base/property pair- Returns:
- lvalue evaluation type or
null
for rvalue expressions - Throws:
ELException
- if evaluation fails (e.g. property not found, type conversion failed, ...)
-
getValue
public Object getValue(ELContext context) throws ELException
Evaluates the expression as an rvalue and answers the result.- Specified by:
getValue
in classValueExpression
- Parameters:
context
- used to resolve properties (base.property
andbase[property]
) and to determine the result from the last base/property pair- Returns:
- rvalue evaluation result
- Throws:
ELException
- if evaluation fails (e.g. property not found, type conversion failed, ...)
-
isReadOnly
public boolean isReadOnly(ELContext context) throws ELException
Evaluates the expression as an lvalue and determines ifsetValue(ELContext, Object)
will always fail.- Specified by:
isReadOnly
in classValueExpression
- Parameters:
context
- used to resolve properties (base.property
andbase[property]
) and to determine the result from the last base/property pair- Returns:
true
ifsetValue(ELContext, Object)
always fails.- Throws:
ELException
- if evaluation fails (e.g. property not found, type conversion failed, ...)
-
setValue
public void setValue(ELContext context, Object value) throws ELException
Evaluates the expression as an lvalue and assigns the given value.- Specified by:
setValue
in classValueExpression
- Parameters:
context
- used to resolve properties (base.property
andbase[property]
) and to perform the assignment to the last base/property pairvalue
- The new value to be set.- Throws:
ELException
- if evaluation fails (e.g. property not found, type conversion failed, assignment failed...)
-
isLiteralText
public boolean isLiteralText()
Description copied from class:Expression
Returns whether this expression was created from only literal text. This method must return true if and only if the expression string this expression was created from contained no unescaped EL delimeters (${...} or #{...}).- Specified by:
isLiteralText
in classExpression
- Returns:
true
if this is a literal text expression
-
getValueReference
public ValueReference getValueReference(ELContext context)
Description copied from class:ValueExpression
Returns aValueReference
for this expression instance.- Overrides:
getValueReference
in classValueExpression
- Parameters:
context
- the context of this evaluation- Returns:
- the
ValueReference
for thisValueExpression
, ornull
if thisValueExpression
is not a reference to a base (null or non-null) and a property. If the base is null, and the property is a EL variable, return theValueReference
for theValueExpression
associated with this EL variable.
-
isLeftValue
public boolean isLeftValue()
Answertrue
if this could be used as an lvalue. This is the case for eval expressions consisting of a simple identifier or a nonliteral prefix, followed by a sequence of property operators (.
or[]
)
-
isDeferred
public boolean isDeferred()
Answertrue
if this is a deferred expression (containing sub-expressions starting with#{
)
-
equals
public boolean equals(Object obj)
Expressions are compared using the concept of a structural id: variable and function names are anonymized such that two expressions with same tree structure will also have the same structural id and vice versa. Two value expressions are equal if- their structural id's are equal
- their bindings are equal
- their expected types are equal
- Specified by:
equals
in classExpression
- Parameters:
obj
- the Object to test for equality.- Returns:
- true if obj equals this Expression; false otherwise.
-
hashCode
public int hashCode()
Description copied from class:Expression
Returns the hash code for this Expression. See the note in theExpression.equals(Object)
method on how two expressions can be equal if their expression Strings are different. Recall that if two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. Implementations must take special note and implement hashCode correctly.- Specified by:
hashCode
in classExpression
- Returns:
- The hash code for this Expression.
- See Also:
Expression.equals(Object)
,Hashtable
,Object.hashCode()
-
dump
public void dump(PrintWriter writer)
Print the parse tree.- Parameters:
writer
-
-
-