Top Description Fields Constructors Methods
jakarta.el

public Class CompositeELResolver

extends ELResolver
Class Inheritance

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 method getCommonPropertyType. Instead, results are collected and combined from all child ELResolvers for this method.

Since
Jakarta Server Pages 2.1
See Also
ELContext, ELResolver

Field Summary

Modifier and TypeField and Description
private ELResolver[]
private int

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 <T> T
convertToType(ELContext
The context of this evaluation.
context
,
Object
The object to convert.
obj
,
Class<T>
The target type for the convertion.
targetType
)

Overrides jakarta.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 jakarta.el.ELResolver.getCommonPropertyType.

Returns the most general type that this resolver accepts for the property argument, given a base object.

public Class<?>

Returns:

If the propertyResolved property of ELContext was set to true, then the most general acceptable type which must be null if the either the property or the resolver is read-only; 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 jakarta.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 jakarta.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 jakarta.el.ELResolver.invoke.

Attempts 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 jakarta.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 jakarta.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 <T> T convertToType(ELContext context, Object obj, Class<T> targetType)

Overrides jakarta.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<T>

The target type for the convertion.

Returns:T

Doc from jakarta.el.ELResolver.convertToType.

object converted to targetType

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

Implements abstract jakarta.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.

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

Implements abstract jakarta.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 which must be null if the either the property or the resolver is read-only; otherwise undefined

Annotations
@Override
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 jakarta.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.

Annotations
@Override
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 jakarta.el.ELResolver.invoke.

Attempts 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).

Annotations
@Override
Since
Jakarta Expression Language 2.2
isReadOnlyback to summary
public boolean isReadOnly(ELContext context, Object base, Object property)

Implements abstract jakarta.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.

Annotations
@Override
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 jakarta.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.

Annotations
@Override
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.