Expression that can get or set a value.
In previous incarnations of this API, expressions could only be read. ValueExpression objects can now be
used both to retrieve a value and to set a value. Expressions that can have a value set on them are referred to as
l-value expressions. Those that cannot are referred to as r-value expressions. Not all r-value expressions can be
used as l-value expressions (e.g. "${1+1}" or "${firstName} ${lastName}"). See the EL
Specification for details. Expressions that cannot be used as l-values must always return true from
isReadOnly().
The ExpressionFactory#createValueExpression method can be used to parse an expression string and return a
concrete instance of ValueExpression that encapsulates the parsed expression. The FunctionMapper
is used at parse time, not evaluation time, so one is not needed to evaluate an expression using this class. However,
the ELContext is needed at evaluation time.
The getValue, setValue, isReadOnly and getType methods will evaluate the
expression each time they are called. The ELResolver in the ELContext is used to resolve the
top-level variables and to determine the behavior of the . and [] operators. For any of the
four methods, the ELResolver#getValue method is used to resolve all properties up to but excluding the last
one. This provides the base object. At the last resolution, the ValueExpression will call
the corresponding ELResolver#getValue, ELResolver#setValue, ELResolver#isReadOnly or
ELResolver#getType method, depending on which was called on the ValueExpression.
See the notes about comparison, serialization and immutability in the Expression javadocs.
javax.el.ELResolver , javax.el.Expression , javax.el.ExpressionFactory , javax.el.ValueExpression
| Modifier and Type | Field and Description |
|---|---|
| private Class | |
| private String | |
| private FunctionMapper | |
| private transient Node | |
| private VariableMapper |
| Access | Constructor and Description |
|---|---|
| public | |
| public | ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType)
|
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the obj)Object to test for equality.Implements abstract javax. Expression.
|
| public Class | getExpectedType()
Implements abstract javax. |
| public String | Returns: theexpectedType passed to the ExpressionFactory.createValueExpression method that
created this ValueExpression.Implements abstract javax. |
| private Node | |
| public Class | getType(ELContext
The context of this evaluation. context)Implements abstract javax. value parameter in a future call
to the setValue method.
|
| public Object | getValue(ELContext
The context of this evaluation. context)Implements abstract javax. |
| public ValueReference | getValueReference(ELContext
the context of this evaluation context)Overrides javax. ValueReference for this expression instance.
|
| public int | hashCode()
Implements abstract javax. Expression.
|
| public boolean | isLiteralText()
Implements abstract javax. |
| public boolean | isReadOnly(ELContext
The context of this evaluation. context)Implements abstract javax. true if a call to setValue will
always fail.
|
| public void | readExternal(ObjectInput
the stream to read data from in order to restore the object in)Implements java. |
| public void | setValue(ELContext
The context of this evaluation. context, Object The new value to be set. value)Implements abstract javax. |
| public String | |
| public void | writeExternal(ObjectOutput
the stream to write the object to out)Implements java. |
| expectedType | back to summary |
|---|---|
| private Class<?> expectedType | |
| expr | back to summary |
|---|---|
| private String expr | |
| fnMapper | back to summary |
|---|---|
| private FunctionMapper fnMapper | |
| node | back to summary |
|---|---|
| private transient Node node | |
| varMapper | back to summary |
|---|---|
| private VariableMapper varMapper | |
| ValueExpressionImpl | back to summary |
|---|---|
| public ValueExpressionImpl() | |
| ValueExpressionImpl | back to summary |
|---|---|
| public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Implements abstract javax. Doc from javax. Determines whether the specified object is equal to this
The result is Note that two expressions can be equal if their expression
Strings are different. For example, | |
| getExpectedType | back to summary |
|---|---|
| public Class Implements abstract javax. Doc from javax. Returns the type the result of the expression will be coerced to after evaluation. | |
| getExpressionString | back to summary |
|---|---|
| public String getExpressionString() Implements abstract javax. Returns the type the result of the expression will be coerced to after evaluation.
| |
| getNode | back to summary |
|---|---|
private Node getNode() throws ELException
| |
| getType | back to summary |
|---|---|
| public Class Implements abstract javax. Doc from javax. Evaluates the expression relative to the provided context, and
returns the most general type that is acceptable for an object to be
passed as the This is not always the same as
| |
| getValue | back to summary |
|---|---|
| public Object getValue(ELContext context) throws PropertyNotFoundException, ELException Implements abstract javax. Doc from javax. Evaluates the expression relative to the provided context, and returns the resulting value. The resulting value is automatically coerced to the type
returned by
| |
| getValueReference | back to summary |
|---|---|
| public ValueReference getValueReference(ELContext context) throws PropertyNotFoundException, ELException Overrides javax. Doc from javax. Returns a
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Implements abstract javax. Doc from javax. Returns the hash code for this See the note in the
| |
| isLiteralText | back to summary |
|---|---|
| public boolean isLiteralText() Implements abstract javax. Doc from javax. Returns whether this expression was created from only literal text. This method must return
| |
| isReadOnly | back to summary |
|---|---|
| public boolean isReadOnly(ELContext context) throws PropertyNotFoundException, ELException Implements abstract javax. Doc from javax. Evaluates the expression relative to the provided context, and
returns
| |
| readExternal | back to summary |
|---|---|
| public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException Implements java. Doc from java. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
| |
| setValue | back to summary |
|---|---|
| public void setValue(ELContext context, Object value) throws PropertyNotFoundException, PropertyNotWritableException, ELException Implements abstract javax. Doc from javax. Evaluates the expression relative to the provided context, and sets the result to the provided value.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| writeExternal | back to summary |
|---|---|
| public void writeExternal(ObjectOutput out) throws IOException Implements java. Doc from java. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
| |