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:
java.io.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, java.lang.String expr, java.lang.Class<?> type)Create a new value expression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddump(java.io.PrintWriter writer)Print the parse tree.booleanequals(java.lang.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.java.lang.Class<?>getExpectedType()Returns the type the result of the expression will be coerced to after evaluation.java.lang.StringgetExpressionString()Returns the original String used to create this Expression, unmodified.java.lang.Class<?>getType(ELContext context)Evaluates the expression as an lvalue and answers the result type.java.lang.ObjectgetValue(ELContext context)Evaluates the expression as an rvalue and answers the result.ValueReferencegetValueReference(ELContext context)Returns aValueReferencefor this expression instance.inthashCode()Returns the hash code for this Expression.booleanisDeferred()Answertrueif this is a deferred expression (containing sub-expressions starting with#{)booleanisLeftValue()Answertrueif this could be used as an lvalue.booleanisLiteralText()Returns whether this expression was created from only literal text.booleanisReadOnly(ELContext context)Evaluates the expression as an lvalue and determines ifsetValue(ELContext, Object)will always fail.voidsetValue(ELContext context, java.lang.Object value)Evaluates the expression as an lvalue and assigns the given value.java.lang.StringtoString()
-
-
-
Constructor Detail
-
TreeValueExpression
public TreeValueExpression(TreeStore store, FunctionMapper functions, VariableMapper variables, TypeConverter converter, java.lang.String expr, java.lang.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 java.lang.Class<?> getExpectedType()
Description copied from class:ValueExpressionReturns the type the result of the expression will be coerced to after evaluation.- Specified by:
getExpectedTypein classValueExpression- Returns:
- the expectedType passed to the ExpressionFactory.createValueExpression method that created this ValueExpression.
-
getExpressionString
public java.lang.String getExpressionString()
Description copied from class:ExpressionReturns 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:
getExpressionStringin classExpression- Returns:
- The original expression String.
-
getType
public java.lang.Class<?> getType(ELContext context) throws ELException
Evaluates the expression as an lvalue and answers the result type.- Specified by:
getTypein classValueExpression- Parameters:
context- used to resolve properties (base.propertyandbase[property]) and to determine the result from the last base/property pair- Returns:
- lvalue evaluation type or
nullfor rvalue expressions - Throws:
ELException- if evaluation fails (e.g. property not found, type conversion failed, ...)
-
getValue
public java.lang.Object getValue(ELContext context) throws ELException
Evaluates the expression as an rvalue and answers the result.- Specified by:
getValuein classValueExpression- Parameters:
context- used to resolve properties (base.propertyandbase[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:
isReadOnlyin classValueExpression- Parameters:
context- used to resolve properties (base.propertyandbase[property]) and to determine the result from the last base/property pair- Returns:
trueifsetValue(ELContext, Object)always fails.- Throws:
ELException- if evaluation fails (e.g. property not found, type conversion failed, ...)
-
setValue
public void setValue(ELContext context, java.lang.Object value) throws ELException
Evaluates the expression as an lvalue and assigns the given value.- Specified by:
setValuein classValueExpression- Parameters:
context- used to resolve properties (base.propertyandbase[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:ExpressionReturns 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:
isLiteralTextin classExpression- Returns:
trueif this is a literal text expression
-
getValueReference
public ValueReference getValueReference(ELContext context)
Description copied from class:ValueExpressionReturns aValueReferencefor this expression instance.- Overrides:
getValueReferencein classValueExpression- Parameters:
context- the context of this evaluation- Returns:
- the
ValueReferencefor thisValueExpression, ornullif thisValueExpressionis 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 theValueReferencefor theValueExpressionassociated with this EL variable.
-
isLeftValue
public boolean isLeftValue()
Answertrueif 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()
Answertrueif this is a deferred expression (containing sub-expressions starting with#{)
-
equals
public boolean equals(java.lang.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:
equalsin 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:ExpressionReturns 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:
hashCodein classExpression- Returns:
- The hash code for this Expression.
- See Also:
Expression.equals(Object),Hashtable,Object.hashCode()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
dump
public void dump(java.io.PrintWriter writer)
Print the parse tree.- Parameters:
writer-
-
-