Package de.odysseus.el
Class TreeValueExpression
- java.lang.Object
-
- javax.el.Expression
-
- javax.el.ValueExpression
-
- de.odysseus.el.TreeValueExpression
-
- All Implemented Interfaces:
java.io.Serializable
public final class TreeValueExpression extends javax.el.ValueExpressionA 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.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private Bindingsbindingsprivate TreeBuilderbuilderprivate booleandeferredprivate java.lang.Stringexprprivate ExpressionNodenodeprivate static longserialVersionUIDprivate java.lang.Stringstructureprivate java.lang.Class<?>type
-
Constructor Summary
Constructors Constructor Description TreeValueExpression(TreeStore store, javax.el.FunctionMapper functions, javax.el.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()java.lang.StringgetExpressionString()private java.lang.StringgetStructuralId()java.lang.Class<?>getType(javax.el.ELContext context)Evaluates the expression as an lvalue and answers the result type.java.lang.ObjectgetValue(javax.el.ELContext context)Evaluates the expression as an rvalue and answers the result.javax.el.ValueReferencegetValueReference(javax.el.ELContext context)inthashCode()booleanisDeferred()Answertrueif this is a deferred expression (containing sub-expressions starting with#{)booleanisLeftValue()Answertrueif this could be used as an lvalue.booleanisLiteralText()booleanisReadOnly(javax.el.ELContext context)Evaluates the expression as an lvalue and determines ifsetValue(ELContext, Object)will always fail.private voidreadObject(java.io.ObjectInputStream in)voidsetValue(javax.el.ELContext context, java.lang.Object value)Evaluates the expression as an lvalue and assigns the given value.java.lang.StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
builder
private final TreeBuilder builder
-
bindings
private final Bindings bindings
-
expr
private final java.lang.String expr
-
type
private final java.lang.Class<?> type
-
deferred
private final boolean deferred
-
node
private transient ExpressionNode node
-
structure
private java.lang.String structure
-
-
Constructor Detail
-
TreeValueExpression
public TreeValueExpression(TreeStore store, javax.el.FunctionMapper functions, javax.el.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
-
getStructuralId
private java.lang.String getStructuralId()
-
getExpectedType
public java.lang.Class<?> getExpectedType()
- Specified by:
getExpectedTypein classjavax.el.ValueExpression
-
getExpressionString
public java.lang.String getExpressionString()
- Specified by:
getExpressionStringin classjavax.el.Expression
-
getType
public java.lang.Class<?> getType(javax.el.ELContext context) throws javax.el.ELExceptionEvaluates the expression as an lvalue and answers the result type.- Specified by:
getTypein classjavax.el.ValueExpression- 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:
javax.el.ELException- if evaluation fails (e.g. property not found, type conversion failed, ...)
-
getValue
public java.lang.Object getValue(javax.el.ELContext context) throws javax.el.ELExceptionEvaluates the expression as an rvalue and answers the result.- Specified by:
getValuein classjavax.el.ValueExpression- 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:
javax.el.ELException- if evaluation fails (e.g. property not found, type conversion failed, ...)
-
isReadOnly
public boolean isReadOnly(javax.el.ELContext context) throws javax.el.ELExceptionEvaluates the expression as an lvalue and determines ifsetValue(ELContext, Object)will always fail.- Specified by:
isReadOnlyin classjavax.el.ValueExpression- 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:
javax.el.ELException- if evaluation fails (e.g. property not found, type conversion failed, ...)
-
setValue
public void setValue(javax.el.ELContext context, java.lang.Object value) throws javax.el.ELExceptionEvaluates the expression as an lvalue and assigns the given value.- Specified by:
setValuein classjavax.el.ValueExpression- Parameters:
context- used to resolve properties (base.propertyandbase[property]) and to perform the assignment to the last base/property pair- Throws:
javax.el.ELException- if evaluation fails (e.g. property not found, type conversion failed, assignment failed...)
-
isLiteralText
public boolean isLiteralText()
- Specified by:
isLiteralTextin classjavax.el.Expression- Returns:
trueif this is a literal text expression
-
getValueReference
public javax.el.ValueReference getValueReference(javax.el.ELContext context)
- Overrides:
getValueReferencein classjavax.el.ValueExpression
-
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 classjavax.el.Expression
-
hashCode
public int hashCode()
- Specified by:
hashCodein classjavax.el.Expression
-
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-
-
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-