public class PropertyExpressionEvaluation
extends java.lang.Object
Constructor and Description |
---|
PropertyExpressionEvaluation(PropertyExpression expression,
java.lang.Object bean)
Constructs a new PropertyExpressionEvaluation for the expression and bean supplied.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Class<?> |
convertToClass(java.lang.reflect.Type type,
NodeEvaluation evaluation)
Attempts to convert the
Type object into a Class object. |
java.lang.Object |
getBean()
Fetches the bean which was supplied as the starting point for evaluation in the
constructor to this evaluation.
|
protected java.lang.reflect.Type |
getBeanPropertyType(java.lang.Class<?> beanClass,
java.lang.String property)
Fetches the type of a property with the given name on the Class of the specified type.
|
PropertyExpression |
getExpression()
Fetches the expression of which this is an evaluation.
|
NodeEvaluation |
getRootNode()
Fetches the root (first) node in the evaluation, which can be used to traverse
through the nodes in series.
|
java.lang.Class<?> |
getScalarType()
Returns a scalar type appropriate to the expression evaluation.
|
java.lang.Class<?> |
getType()
Fetches the type of value that can be get/set with this expression evaluation.
|
protected java.lang.reflect.Type |
getTypeVariableValue(NodeEvaluation evaluation,
java.lang.reflect.TypeVariable<?> typeVar)
Scans backwards in the expression for the last node which contained a JavaBean type
and attempts to use the type arguments to that class to find a match for the
TypeParameter provided.
|
protected java.lang.reflect.Type |
getTypeViaInstances(NodeEvaluation end)
Determines the type of the supplied node and sets appropriate information on the node.
|
java.lang.Object |
getValue()
Fetches the value of this expression evaluated against the bean.
|
protected java.lang.reflect.Type |
getWildcardTypeBound(java.lang.reflect.WildcardType wtype)
Gets the preferred bound from the WildcardType provided.
|
void |
setToNull()
Sets the value of this expression to "null" for the bean.
|
void |
setValue(java.lang.Object propertyValue)
Sets the value of the expression evaluated against the bean.
|
protected java.lang.reflect.Method |
untangleBridgeMethod(java.lang.reflect.Method m)
Deprecated.
This method is no longer used. Bridge methods are handled transparently by
ReflectUtil.getPropertyDescriptors(Class) . |
public PropertyExpressionEvaluation(PropertyExpression expression, java.lang.Object bean)
expression
- a PropertyExpressionbean
- a non-null bean against which to evaluate the expressionpublic java.lang.Object getBean()
public NodeEvaluation getRootNode()
public PropertyExpression getExpression()
protected java.lang.reflect.Type getBeanPropertyType(java.lang.Class<?> beanClass, java.lang.String property)
beanClass
- the class of the JavaBean containing the propertyproperty
- the name of the property@Deprecated protected java.lang.reflect.Method untangleBridgeMethod(java.lang.reflect.Method m)
ReflectUtil.getPropertyDescriptors(Class)
.Locates and returns a non-bridge method for the method supplied. In certain cases the Introspector will return PropertyDescriptors that contain bridge methods for read and write methods. This usually results from classes implementing generic interfaces that contain accessor method specifications with type parameters. Since the bridge methods have inappropriate/unhelpful return and parameter types it is necessary to locate the non-bridge method and use that instead.
When supplied with a non-bridge method, the method parameter passed in is returned immediately and no other work is performed.
m
- a Method instance, potentially a bridge methodprotected java.lang.reflect.Type getTypeViaInstances(NodeEvaluation end) throws EvaluationException, NoSuchPropertyException
Determines the type of the supplied node and sets appropriate information on the node. The type is discovered by fetching (and instantiating if necessary) all prior values in the expression to determine the actual type of the prior node. The prior node is then examined to determine the type of the node provided.
After this method executes either 1) all necessary type information will be set on the node and the appropriate type object returned or 2) an exception will be thrown.
end
- the node to instantiate up to and determine the type ofNoSuchPropertyException
- if the previous node is a JavaBean (i.e. non-collection)
node and does not contain a property with the corresponding nameEvaluationException
- if the previous node is a List or Map and does not contain
enough information to determine the typeprotected java.lang.Class<?> convertToClass(java.lang.reflect.Type type, NodeEvaluation evaluation)
Type
object into a Class object. Currently will extract the
raw type from a ParameterizedType
and the appropriate bound from a
WildcardType
. If the result after these operations is a Class object it will
be cast and returned. Otherwise will return null.type
- the Type object to try and render as a Classprotected java.lang.reflect.Type getTypeVariableValue(NodeEvaluation evaluation, java.lang.reflect.TypeVariable<?> typeVar)
evaluation
- the current NodeEvaluationtypeVar
- the TypeVariable to try and find a more concrete type forprotected java.lang.reflect.Type getWildcardTypeBound(java.lang.reflect.WildcardType wtype)
wtype
- the WildcardType to fetch the bounds ofpublic java.lang.Class<?> getType()
public java.lang.Class<?> getScalarType()
getType()
returns a scalar type then this method will return the identical class. However, when
getType() returns an Array, a Collection or a Map this method will attempt to determine
the type of element stored in that Array/Collection/Map and return that Class. If
getType() returns null due to insufficient type information this method will also
return null. Similarly if the type of item in the Array/Collection/May cannot be determined
then String.class will be returned.public java.lang.Object getValue()
Fetches the value of this expression evaluated against the bean. This is equivalent to calling the appropriate get() methods in sequence in order to fetch the property indicated by the expression.
If the property or any intermediate property in the expression is null this method will return null and will not alter the state of the object graph.
public void setValue(java.lang.Object propertyValue) throws EvaluationException
Sets the value of the expression evaluated against the bean. This is loosely equivalent to calling the appropriate getter() on intermediate properties and then calling the appropriate setter on the final sub-property.
During set operations null intermediate nodes will be instantiated and linked into the object graph in order to persistently set the desired property. When this is not possible (e.g. because of a lack of default constructors) an exception will be thrown.
propertyValue
- the value to be set for the property of the beanEvaluationException
- if intermediate null properties cannot be instantiatedpublic void setToNull() throws EvaluationException
Sets the value of this expression to "null" for the bean. In reality this is not always null, but the logical interpretation of "null" for a given type. For primitives the value is set to be the default value for the primitive type as used by the JVM when initializing instance variables. For Map entries the key is removed from the Map instead of leaving the key present with a null value.
If any intermediate properties in the expression are null this method will return immediately. The sole purpose of this method is to blank out a value if one is present. Therefore if no value is present, nothing will be changed.
EvaluationException
- if any exceptions are thrown during the process of nulling out? Copyright 2005-2006, Stripes Development Team.