Top Description Inners Fields Constructors Methods
javax.el

public Class CompositeELResolver

extends ELResolver
Class Inheritance
Imports
java.util.ArrayList, .Iterator, java.beans.FeatureDescriptor

Maintains an ordered composite list of child ELResolvers.

Though only a single ELResolver is associated with an ELContext, there are usually multiple resolvers considered for any given variable or property resolution. ELResolvers are combined together using a CompositeELResolver, to define rich semantics for evaluating an expression.

For the getValue, getType, setValue and isReadOnly methods, an ELResolver is not responsible for resolving all possible (base, property) pairs. In fact, most resolvers will only handle a base of a single type. To indicate that a resolver has successfully resolved a particular (base, property) pair, it must set the propertyResolved property of the ELContext to true. If it could not handle the given pair, it must leave this property alone. The caller must ignore the return value of the method if propertyResolved is false.

The CompositeELResolver initializes the ELContext.propertyResolved flag to false, and uses it as a stop condition for iterating through its component resolvers.

The ELContext.propertyResolved flag is not used for the design-time methods getFeatureDescriptors and getCommonPropertyType. Instead, results are collected and combined from all child ELResolvers for these methods.

Since
JSP 2.1
See Also
ELContext, ELResolver

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private ELResolver[]
private int
Inherited from javax.el.ELResolver:
RESOLVABLE_AT_DESIGN_TIMETYPE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(ELResolver
The component resolver to add.
elResolver
)

Adds the given resolver to the list of component resolvers.

public Object
convertToType(ELContext
The context of this evaluation.
context
,
Object
The object to convert.
obj
,
Class<?>
The target type for the convertion.
targetType
)

Overrides javax.el.ELResolver.convertToType.

Converts an object to a specific type.
public Class<?>

Returns:

null if this ELResolver does not know how to handle the given base object; otherwise Object.class if any type of property is accepted; otherwise the most general property type accepted for the given base.
getCommonPropertyType
(ELContext
The context of this evaluation.
context
,
Object
The base object to return the most general property type for, or null to enumerate the set of top-level variables that this resolver can evaluate.
base
)

Implements abstract javax.el.ELResolver.getCommonPropertyType.

Returns the most general type that this resolver accepts for the property argument, given a base object.
public Iterator<FeatureDescriptor>

Returns:

An Iterator containing zero or more (possibly infinitely more) FeatureDescriptor objects, or null if this resolver does not handle the given base object or that the results are too complex to represent with this method
getFeatureDescriptors
(ELContext
The context of this evaluation.
context
,
Object
The base object whose set of valid properties is to be enumerated, or null to enumerate the set of top-level variables that this resolver can evaluate.
base
)

Implements abstract javax.el.ELResolver.getFeatureDescriptors.

Returns information about the set of variables or properties that can be resolved for the given base object.
public Class<?>

Returns:

If the propertyResolved property of ELContext was set to true, then the most general acceptable type; otherwise undefined.
getType
(ELContext
The context of this evaluation.
context
,
Object
The base object whose property value is to be analyzed, or null to analyze a top-level variable.
base
,
Object
The property or variable to return the acceptable type for.
property
)

Implements abstract javax.el.ELResolver.getType.

For a given base and property, attempts to identify the most general type that is acceptable for an object to be passed as the value parameter in a future call to the setValue method.
public Object

Returns:

If the propertyResolved property of ELContext was set to true, then the result of the variable or property resolution; otherwise undefined.
getValue
(ELContext
The context of this evaluation.
context
,
Object
The base object whose property value is to be returned, or null to resolve a top-level variable.
base
,
Object
The property or variable to be resolved.
property
)

Implements abstract javax.el.ELResolver.getValue.

Attempts to resolve the given property object on the given base object by querying all component resolvers.
public Object

Returns:

The result of the method invocation (null if the method has a void return type).
invoke
(ELContext
The context of this evaluation.
context
,
Object
The bean on which to invoke the method
base
,
Object
The simple name of the method to invoke. Will be coerced to a String.
method
,
Class<?>[]
An array of Class objects identifying the method's formal parameter types, in declared order. Use an empty array if the method has no parameters. Can be null, in which case the method's formal parameter types are assumed to be unknown.
paramTypes
,
Object[]
The parameters to pass to the method, or null if no parameters.
params
)

Overrides javax.el.ELResolver.invoke.

Attemps to resolve and invoke the given method on the given base object by querying all component resolvers.
public boolean

Returns:

If the propertyResolved property of ELContext was set to true, then true if the property is read-only or false if not; otherwise undefined.
isReadOnly
(ELContext
The context of this evaluation.
context
,
Object
The base object whose property value is to be analyzed, or null to analyze a top-level variable.
base
,
Object
The property or variable to return the read-only status for.
property
)

Implements abstract javax.el.ELResolver.isReadOnly.

For a given base and property, attempts to determine whether a call to setValue will always fail.
public void
setValue(ELContext
The context of this evaluation.
context
,
Object
The base object whose property value is to be set, or null to set a top-level variable.
base
,
Object
The property or variable to be set.
property
,
Object
The value to set the property or variable to.
val
)

Implements abstract javax.el.ELResolver.setValue.

Attempts to set the value of the given property object on the given base object.

Field Detail

elResolversback to summary
private ELResolver[] elResolvers
sizeback to summary
private int size

Constructor Detail

CompositeELResolverback to summary
public CompositeELResolver()

Method Detail

addback to summary
public void add(ELResolver elResolver)

Adds the given resolver to the list of component resolvers.

Resolvers are consulted in the order in which they are added.

Parameters
elResolver:ELResolver

The component resolver to add.

Exceptions
NullPointerException:
If the provided resolver is null.
convertToTypeback to summary
public Object convertToType(ELContext context, Object obj, Class<?> targetType)

Overrides javax.el.ELResolver.convertToType.

Converts an object to a specific type.

An ELException is thrown if an error occurs during the conversion.

Parameters
context:ELContext

The context of this evaluation.

obj:Object

The object to convert.

targetType:Class<?>

The target type for the convertion.

Annotations
@Override
Exceptions
ELException:
thrown if errors occur.
Since
EL 3.0
getCommonPropertyTypeback to summary
public Class<?> getCommonPropertyType(ELContext context, Object base)

Implements abstract javax.el.ELResolver.getCommonPropertyType.

Returns the most general type that this resolver accepts for the property argument, given a base object. One use for this method is to assist tools in auto-completion. The result is obtained by querying all component resolvers.

The Class returned is the most specific class that is a common superclass of all the classes returned by each component resolver's getCommonPropertyType method. If null is returned by a resolver, it is skipped.

Parameters
context:ELContext

The context of this evaluation.

base:Object

The base object to return the most general property type for, or null to enumerate the set of top-level variables that this resolver can evaluate.

Returns:Class<?>

null if this ELResolver does not know how to handle the given base object; otherwise Object.class if any type of property is accepted; otherwise the most general property type accepted for the given base.

getFeatureDescriptorsback to summary
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)

Implements abstract javax.el.ELResolver.getFeatureDescriptors.

Returns information about the set of variables or properties that can be resolved for the given base object. One use for this method is to assist tools in auto-completion. The results are collected from all component resolvers.

The propertyResolved property of the ELContext is not relevant to this method. The results of all ELResolvers are concatenated.

The Iterator returned is an iterator over the collection of FeatureDescriptor objects returned by the iterators returned by each component resolver's getFeatureDescriptors method. If null is returned by a resolver, it is skipped.

Parameters
context:ELContext

The context of this evaluation.

base:Object

The base object whose set of valid properties is to be enumerated, or null to enumerate the set of top-level variables that this resolver can evaluate.

Returns:Iterator<FeatureDescriptor>

An Iterator containing zero or more (possibly infinitely more) FeatureDescriptor objects, or null if this resolver does not handle the given base object or that the results are too complex to represent with this method

getTypeback to summary
public Class<?> getType(ELContext context, Object base, Object property)

Implements abstract javax.el.ELResolver.getType.

For a given base and property, attempts to identify the most general type that is acceptable for an object to be passed as the value parameter in a future call to the setValue method. The result is obtained by querying all component resolvers.

If this resolver handles the given (base, property) pair, the propertyResolved property of the ELContext object must be set to true by the resolver, before returning. If this property is not true after this method is called, the caller should ignore the return value.

First, propertyResolved is set to false on the provided ELContext.

Next, for each component resolver in this composite:

  1. The getType() method is called, passing in the provided context, base and property.
  2. If the ELContext's propertyResolved flag is false then iteration continues.
  3. Otherwise, iteration stops and no more component resolvers are considered. The value returned by getType() is returned by this method.

If none of the component resolvers were able to perform this operation, the value null is returned and the propertyResolved flag remains set to false

.

Any exception thrown by component resolvers during the iteration is propagated to the caller of this method.

Parameters
context:ELContext

The context of this evaluation.

base:Object

The base object whose property value is to be analyzed, or null to analyze a top-level variable.

property:Object

The property or variable to return the acceptable type for.

Returns:Class<?>

If the propertyResolved property of ELContext was set to true, then the most general acceptable type; otherwise undefined.

Exceptions
NullPointerException:
if context is null
PropertyNotFoundException:
if the given (base, property) pair is handled by this ELResolver but the specified variable or property does not exist or is not readable.
ELException:
if an exception was thrown while performing the property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
getValueback to summary
public Object getValue(ELContext context, Object base, Object property)

Implements abstract javax.el.ELResolver.getValue.

Attempts to resolve the given property object on the given base object by querying all component resolvers.

If this resolver handles the given (base, property) pair, the propertyResolved property of the ELContext object must be set to true by the resolver, before returning. If this property is not true after this method is called, the caller should ignore the return value.

First, propertyResolved is set to false on the provided ELContext.

Next, for each component resolver in this composite:

  1. The getValue() method is called, passing in the provided context, base and property.
  2. If the ELContext's propertyResolved flag is false then iteration continues.
  3. Otherwise, iteration stops and no more component resolvers are considered. The value returned by getValue() is returned by this method.

If none of the component resolvers were able to perform this operation, the value null is returned and the propertyResolved flag remains set to false

.

Any exception thrown by component resolvers during the iteration is propagated to the caller of this method.

Parameters
context:ELContext

The context of this evaluation.

base:Object

The base object whose property value is to be returned, or null to resolve a top-level variable.

property:Object

The property or variable to be resolved.

Returns:Object

If the propertyResolved property of ELContext was set to true, then the result of the variable or property resolution; otherwise undefined.

Exceptions
NullPointerException:
if context is null
PropertyNotFoundException:
if the given (base, property) pair is handled by this ELResolver but the specified variable or property does not exist or is not readable.
ELException:
if an exception was thrown while performing the property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
invokeback to summary
public Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params)

Overrides javax.el.ELResolver.invoke.

Attemps to resolve and invoke the given method on the given base object by querying all component resolvers.

If this resolver handles the given (base, method) pair, the propertyResolved property of the ELContext object must be set to true by the resolver, before returning. If this property is not true after this method is called, the caller should ignore the return value.

First, propertyResolved is set to false on the provided ELContext.

Next, for each component resolver in this composite:

  1. The invoke() method is called, passing in the provided context, base, method, paramTypes, and params.
  2. If the ELContext's propertyResolved flag is false then iteration continues.
  3. Otherwise, iteration stops and no more component resolvers are considered. The value returned by getValue() is returned by this method.

If none of the component resolvers were able to perform this operation, the value null is returned and the propertyResolved flag remains set to false

.

Any exception thrown by component resolvers during the iteration is propagated to the caller of this method.

Parameters
context:ELContext

The context of this evaluation.

base:Object

The bean on which to invoke the method

method:Object

The simple name of the method to invoke. Will be coerced to a String.

paramTypes:Class<?>[]

An array of Class objects identifying the method's formal parameter types, in declared order. Use an empty array if the method has no parameters. Can be null, in which case the method's formal parameter types are assumed to be unknown.

params:Object[]

The parameters to pass to the method, or null if no parameters.

Returns:Object

The result of the method invocation (null if the method has a void return type).

Since
EL 2.2
isReadOnlyback to summary
public boolean isReadOnly(ELContext context, Object base, Object property)

Implements abstract javax.el.ELResolver.isReadOnly.

For a given base and property, attempts to determine whether a call to setValue will always fail. The result is obtained by querying all component resolvers.

If this resolver handles the given (base, property) pair, the propertyResolved property of the ELContext object must be set to true by the resolver, before returning. If this property is not true after this method is called, the caller should ignore the return value.

First, propertyResolved is set to false on the provided ELContext.

Next, for each component resolver in this composite:

  1. The isReadOnly() method is called, passing in the provided context, base and property.
  2. If the ELContext's propertyResolved flag is false then iteration continues.
  3. Otherwise, iteration stops and no more component resolvers are considered. The value returned by isReadOnly() is returned by this method.

If none of the component resolvers were able to perform this operation, the value false is returned and the propertyResolved flag remains set to false

.

Any exception thrown by component resolvers during the iteration is propagated to the caller of this method.

Parameters
context:ELContext

The context of this evaluation.

base:Object

The base object whose property value is to be analyzed, or null to analyze a top-level variable.

property:Object

The property or variable to return the read-only status for.

Returns:boolean

If the propertyResolved property of ELContext was set to true, then true if the property is read-only or false if not; otherwise undefined.

Exceptions
NullPointerException:
if context is null
PropertyNotFoundException:
if the given (base, property) pair is handled by this ELResolver but the specified variable or property does not exist.
ELException:
if an exception was thrown while performing the property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
setValueback to summary
public void setValue(ELContext context, Object base, Object property, Object val)

Implements abstract javax.el.ELResolver.setValue.

Attempts to set the value of the given property object on the given base object. All component resolvers are asked to attempt to set the value.

If this resolver handles the given (base, property) pair, the propertyResolved property of the ELContext object must be set to true by the resolver, before returning. If this property is not true after this method is called, the caller can safely assume no value has been set.

First, propertyResolved is set to false on the provided ELContext.

Next, for each component resolver in this composite:

  1. The setValue() method is called, passing in the provided context, base, property and value.
  2. If the ELContext's propertyResolved flag is false then iteration continues.
  3. Otherwise, iteration stops and no more component resolvers are considered.

If none of the component resolvers were able to perform this operation, the propertyResolved flag remains set to false

.

Any exception thrown by component resolvers during the iteration is propagated to the caller of this method.

Parameters
context:ELContext

The context of this evaluation.

base:Object

The base object whose property value is to be set, or null to set a top-level variable.

property:Object

The property or variable to be set.

val:Object

The value to set the property or variable to.

Exceptions
NullPointerException:
if context is null
PropertyNotFoundException:
if the given (base, property) pair is handled by this ELResolver but the specified variable or property does not exist.
PropertyNotWritableException:
if the given (base, property) pair is handled by this ELResolver but 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.
javax.el back to summary

private Class CompositeELResolver.CompositeIterator

extends Object
implements Iterator<FeatureDescriptor>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
pack-priv Object
pack-priv ELContext
pack-priv int
pack-priv Iterator<FeatureDescriptor>
pack-priv ELResolver[]
pack-priv int

Constructor Summary

AccessConstructor and Description
pack-priv
CompositeIterator(ELResolver[] resolvers, int size, ELContext context, Object base)

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public FeatureDescriptor
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseback to summary
pack-priv Object base
contextback to summary
pack-priv ELContext context
indexback to summary
pack-priv int index
propertyIterback to summary
pack-priv Iterator<FeatureDescriptor> propertyIter
resolversback to summary
pack-priv ELResolver[] resolvers
sizeback to summary
pack-priv int size

Constructor Detail

CompositeIteratorback to summary
pack-priv CompositeIterator(ELResolver[] resolvers, int size, ELContext context, Object base)

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

nextback to summary
public FeatureDescriptor next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:FeatureDescriptor

the next element in the iteration

removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.