Class ValueExpressionImpl
- java.lang.Object
-
- org.jdesktop.el.Expression
-
- org.jdesktop.el.ValueExpression
-
- org.jdesktop.el.impl.ValueExpressionImpl
-
- All Implemented Interfaces:
Externalizable,Serializable
public final class ValueExpressionImpl extends ValueExpression implements Externalizable
AnExpressionthat can get or set a value.In previous incarnations of this API, expressions could only be read.
ValueExpressionobjects 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 returntruefromisReadOnly().TheExpressionFactory.createValueExpression(org.jdesktop.el.ELContext, java.lang.String, java.lang.Class<?>)method can be used to parse an expression string and return a concrete instance ofValueExpressionthat encapsulates the parsed expression. TheFunctionMapperis used at parse time, not evaluation time, so one is not needed to evaluate an expression using this class. However, theELContextis needed at evaluation time.The
getValue(org.jdesktop.el.ELContext),setValue(org.jdesktop.el.ELContext, java.lang.Object),isReadOnly(org.jdesktop.el.ELContext)andgetType(org.jdesktop.el.ELContext)methods will evaluate the expression each time they are called. TheELResolverin theELContextis used to resolve the top-level variables and to determine the behavior of the.and[]operators. For any of the four methods, theELResolver.getValue(org.jdesktop.el.ELContext, java.lang.Object, java.lang.Object)method is used to resolve all properties up to but excluding the last one. This provides thebaseobject. At the last resolution, theValueExpressionwill call the correspondingELResolver.getValue(org.jdesktop.el.ELContext, java.lang.Object, java.lang.Object),ELResolver.setValue(org.jdesktop.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object),ELResolver.isReadOnly(org.jdesktop.el.ELContext, java.lang.Object, java.lang.Object)orELResolver.getType(org.jdesktop.el.ELContext, java.lang.Object, java.lang.Object)method, depending on which was called on theValueExpression.See the notes about comparison, serialization and immutability in the
Expressionjavadocs.- Version:
- $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: spuhl $
- Author:
- Jacob Hookom [jacob@hookom.net]
- See Also:
javax.el.ELResolver,javax.el.Expression,javax.el.ExpressionFactory,javax.el.ValueExpression, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jdesktop.el.Expression
Expression.ResolvedProperty, Expression.Result
-
-
Constructor Summary
Constructors Constructor Description ValueExpressionImpl()ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class expectedType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Determines whether the specified object is equal to thisExpression.ClassgetExpectedType()Returns the type the result of the expression will be coerced to after evaluation.StringgetExpressionString()Returns the type the result of the expression will be coerced to after evaluation.Expression.ResultgetResult(ELContext context, boolean trackResolvedObjects)ClassgetType(ELContext context)Evaluates the expression relative to the provided context, and returns the most general type that is acceptable for an object to be passed as thevalueparameter in a future call to theValueExpression.setValue(org.jdesktop.el.ELContext, java.lang.Object)method.ObjectgetValue(ELContext context)Evaluates the expression relative to the provided context, and returns the resulting value.inthashCode()Returns the hash code for thisExpression.booleanisLiteralText()Returns whether this expression was created from only literal text.booleanisReadOnly(ELContext context)Evaluates the expression relative to the provided context, and returnstrueif a call toValueExpression.setValue(org.jdesktop.el.ELContext, java.lang.Object)will always fail.voidreadExternal(ObjectInput in)voidsetValue(ELContext context, Object value)Evaluates the expression relative to the provided context, and sets the result to the provided value.StringtoString()voidwriteExternal(ObjectOutput out)-
Methods inherited from class org.jdesktop.el.ValueExpression
getSource, setSource
-
-
-
-
Constructor Detail
-
ValueExpressionImpl
public ValueExpressionImpl()
-
ValueExpressionImpl
public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class expectedType)
-
-
Method Detail
-
equals
public boolean equals(Object obj)
Description copied from class:ExpressionDetermines whether the specified object is equal to thisExpression.The result is
trueif and only if the argument is notnull, is anExpressionobject that is the of the same type (ValueExpressionorMethodExpression), and has an identical parsed representation.Note that two expressions can be equal if their expression Strings are different. For example,
${fn1:foo()}and${fn2:foo()}are equal if their correspondingFunctionMappers mappedfn1:fooandfn2:footo the same method.- Specified by:
equalsin classExpression- Parameters:
obj- theObjectto test for equality.- Returns:
trueifobjequals thisExpression;falseotherwise.- See Also:
Hashtable,Object.equals(java.lang.Object)
-
getExpectedType
public 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
expectedTypepassed to theExpressionFactory.createValueExpressionmethod that created thisValueExpression.
-
getExpressionString
public String getExpressionString()
Returns the type the result of the expression will be coerced to after evaluation.- Specified by:
getExpressionStringin classExpression- Returns:
- the
expectedTypepassed to theExpressionFactory.createValueExpressionmethod that created thisValueExpression. - See Also:
javax.el.Expression#getExpressionString()
-
getType
public Class getType(ELContext context) throws PropertyNotFoundException, ELException
Description copied from class:ValueExpressionEvaluates the expression relative to the provided context, and returns the most general type that is acceptable for an object to be passed as thevalueparameter in a future call to theValueExpression.setValue(org.jdesktop.el.ELContext, java.lang.Object)method.This is not always the same as
getValue().getClass(). For example, in the case of an expression that references an array element, thegetTypemethod will return the element type of the array, which might be a superclass of the type of the actual element that is currently in the specified array element.- Specified by:
getTypein classValueExpression- Parameters:
context- The context of this evaluation.- Returns:
- the most general acceptable type; otherwise undefined.
- Throws:
PropertyNotFoundException- if one of the property resolutions failed because a specified variable or property does not exist or is not readable.ELException- if an exception was thrown while performing property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
-
getValue
public Object getValue(ELContext context) throws PropertyNotFoundException, ELException
Description copied from class:ValueExpressionEvaluates the expression relative to the provided context, and returns the resulting value.The resulting value is automatically coerced to the type returned by
getExpectedType(), which was provided to theExpressionFactorywhen this expression was created.- Specified by:
getValuein classValueExpression- Parameters:
context- The context of this evaluation.- Returns:
- The result of the expression evaluation.
- Throws:
PropertyNotFoundException- if one of the property resolutions failed because a specified variable or property does not exist or is not readable.ELException- if an exception was thrown while performing property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
-
getResult
public Expression.Result getResult(ELContext context, boolean trackResolvedObjects) throws PropertyNotFoundException, ELException
- Overrides:
getResultin classValueExpression- Throws:
PropertyNotFoundExceptionELException
-
hashCode
public int hashCode()
Description copied from class:ExpressionReturns the hash code for thisExpression.See the note in the
Expression.equals(java.lang.Object)method on how two expressions can be equal if their expression Strings are different. Recall that if two objects are equal according to theequals(Object)method, then calling thehashCodemethod on each of the two objects must produce the same integer result. Implementations must take special note and implementhashCodecorrectly.- Specified by:
hashCodein classExpression- Returns:
- The hash code for this
Expression. - See Also:
Expression.equals(java.lang.Object),Hashtable,Object.hashCode()
-
isLiteralText
public boolean isLiteralText()
Description copied from class:ExpressionReturns whether this expression was created from only literal text.This method must return
trueif and only if the expression string this expression was created from contained no unescaped EL delimeters (${...}or#{...}).- Specified by:
isLiteralTextin classExpression- Returns:
trueif this expression was created from only literal text;falseotherwise.
-
isReadOnly
public boolean isReadOnly(ELContext context) throws PropertyNotFoundException, ELException
Description copied from class:ValueExpressionEvaluates the expression relative to the provided context, and returnstrueif a call toValueExpression.setValue(org.jdesktop.el.ELContext, java.lang.Object)will always fail.- Specified by:
isReadOnlyin classValueExpression- Parameters:
context- The context of this evaluation.- Returns:
trueif the expression is read-only orfalseif not.- Throws:
PropertyNotFoundException- if one of the property resolutions failed because a specified variable or property does not exist or is not readable.ELException- if an exception was thrown while performing property or variable resolution. The thrown exception must be included as the cause property of this exception, if available. * @throws NullPointerException if context isnull
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
setValue
public void setValue(ELContext context, Object value) throws PropertyNotFoundException, PropertyNotWritableException, ELException
Description copied from class:ValueExpressionEvaluates the expression relative to the provided context, and sets the result to the provided value.- Specified by:
setValuein classValueExpression- Parameters:
context- The context of this evaluation.value- The new value to be set.- Throws:
PropertyNotFoundException- if one of the property resolutions failed because a specified variable or property does not exist or is not readable.PropertyNotWritableException- if the final variable or property resolution failed because the specified variable or property is not writable.ELException- if an exception was thrown while attempting to set the property or variable. The thrown exception must be included as the cause property of this exception, if available.
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
-