Top Description Fields Constructors Methods
jakarta.el

public Class StaticFieldELResolver

extends ELResolver
Class Inheritance
Static Imports
java.lang.reflect.Modifier.isPublic, .Modifier.isStatic, jakarta.el.ELUtil.getExceptionMessageString

An ELResolver for resolving static fields, enum constants and static methods. Also handles constructor calls as a special case.

The resolver handles base objects of the type ELClass, which is usually generated by a Jakarta Expression Language implementation.

Since
Jakarta Expression Language 3.0
See Also
ELClass

Field Summary

Inherited from jakarta.el.ELResolver:
RESOLVABLE_AT_DESIGN_TIMETYPE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Class<?>

Returns:

String.class.
getCommonPropertyType
(ELContext
The context of this evaluation.
context
,
Object
An ELClass.
base
)

Implements abstract jakarta.el.ELResolver.getCommonPropertyType.

Returns the type of the property.
public Iterator<FeatureDescriptor>

Returns:

null.
getFeatureDescriptors
(ELContext
The context of this evaluation.
context
,
Object
An ELClass.
base
)

Overrides jakarta.el.ELResolver.getFeatureDescriptors.

Deprecated for removal since 5.0. This method will be removed without replacement in EL 6.0
Returns the properties that can be resolved.
public Class<?>

Returns:

If the propertyResolved property of ELContext was set to true, then null; otherwise undefined.
getType
(ELContext
The context of this evaluation.
context
,
Object
An ELClass.
base
,
Object
The name of the field.
property
)

Implements abstract jakarta.el.ELResolver.getType.

Returns the type of a static field.
public Object

Returns:

If the propertyResolved property of ELContext was set to true, then the static field value.
getValue
(ELContext
The context of this evaluation.
context
,
Object
An ELClass.
base
,
Object
A static field name.
property
)

Implements abstract jakarta.el.ELResolver.getValue.

Returns the value of a static field.

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
An ELClass
base
,
Object
When coerced to a String, the simple name of the method.
methodName
,
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.

Invokes a public static method or the constructor for a class.
public boolean

Returns:

true
isReadOnly
(ELContext
The context of this evaluation.
context
,
Object
An ELClass.
base
,
Object
The name of the bean.
property
)

Implements abstract jakarta.el.ELResolver.isReadOnly.

Inquires whether the static field is writable.

public void
setValue(ELContext
The context of this evaluation.
context
,
Object
An ELClass
base
,
Object
The name of the field
property
,
Object
The value to set the field of the class to.
value
)

Implements abstract jakarta.el.ELResolver.setValue.

Attempts to write to a static field.

Inherited from jakarta.el.ELResolver:
convertToType

Constructor Detail

StaticFieldELResolverback to summary
public StaticFieldELResolver()

Method Detail

getCommonPropertyTypeback to summary
public Class<?> getCommonPropertyType(ELContext context, Object base)

Implements abstract jakarta.el.ELResolver.getCommonPropertyType.

Returns the type of the property. Always returns String.class, since a field name is a String.

Parameters
context:ELContext

The context of this evaluation.

base:Object

An ELClass.

Returns:Class<?>

String.class.

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

Overrides jakarta.el.ELResolver.getFeatureDescriptors.

Deprecated

for removal since 5.0.

This method will be removed without replacement in EL 6.0

Returns the properties that can be resolved. Always returns null, since there is no reason to iterate through a list of one element: field name.

Parameters
context:ELContext

The context of this evaluation.

base:Object

An ELClass.

Returns:Iterator<FeatureDescriptor>

null.

Annotations
@Deprecated
forRemoval:true
since:5.0
@Override
getTypeback to summary
public Class<?> getType(ELContext context, Object base, Object property)

Implements abstract jakarta.el.ELResolver.getType.

Returns the type of a static field.

If the base object is an instance of ELClassand the property is a String, 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.

Parameters
context:ELContext

The context of this evaluation.

base:Object

An ELClass.

property:Object

The name of the field.

Returns:Class<?>

If the propertyResolved property of ELContext was set to true, then null; otherwise undefined.

Annotations
@Override
Exceptions
NullPointerException:
if context is null.
PropertyNotFoundException:
if field is not a public static filed of the class, or if the field is inaccessible.
getValueback to summary
public Object getValue(ELContext context, Object base, Object property)

Implements abstract jakarta.el.ELResolver.getValue.

Returns the value of a static field.

If the base object is an instance of ELClass and the property is String, the propertyResolved property of the ELContext object must be set to true by this resolver, before returning. If this property is not true after this method is called, the caller should ignore the return value.

If the property is a public static field of class specified in ELClass, return the value of the static field. An Enum constant is a public static field of an Enum object, and is a special case of this.
Parameters
context:ELContext

The context of this evaluation.

base:Object

An ELClass.

property:Object

A static field name.

Returns:Object

If the propertyResolved property of ELContext was set to true, then the static field value.

Annotations
@Override
Exceptions
NullPointerException:
if context is null.
PropertyNotFoundException:
if the specified class does not exist, or if the field is not a public static filed of the class, or if the field is inaccessible.
invokeback to summary
public Object invoke(ELContext context, Object base, Object methodName, Class<?>[] paramTypes, Object[] params)

Overrides jakarta.el.ELResolver.invoke.

Invokes a public static method or the constructor for a class.

If the base object is an instance of ELClass and the method is a String, 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.

Invoke the public static method specified by method.

The process involved in the method selection is the same as that used in BeanELResolver.

As a special case, if the name of the method is "<init>", the constructor for the class will be invoked.

Parameters
context:ELContext

Doc from jakarta.el.ELResolver.invoke.

The context of this evaluation.

base:Object

An ELClass

methodName:Object

When coerced to a String, the simple name of the method.

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
Exceptions
MethodNotFoundException:
if no suitable method can be found.
ELException:
if an exception was thrown while performing (base, method) resolution. The thrown exception must be included as the cause property of this exception, if available. If the exception thrown is an InvocationTargetException, extract its cause and pass it to the ELException constructor.
isReadOnlyback to summary
public boolean isReadOnly(ELContext context, Object base, Object property)

Implements abstract jakarta.el.ELResolver.isReadOnly.

Inquires whether the static field is writable.

If the base object is an instance of ELClassand the property is a String, 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.

Always returns a true because writing to a static field is not allowed.

Parameters
context:ELContext

The context of this evaluation.

base:Object

An ELClass.

property:Object

The name of the bean.

Returns:boolean

true

Annotations
@Override
Exceptions
NullPointerException:
if context is null.
setValueback to summary
public void setValue(ELContext context, Object base, Object property, Object value)

Implements abstract jakarta.el.ELResolver.setValue.

Attempts to write to a static field.

If the base object is an instance of ELClassand the property is String, a PropertyNotWritableException will always be thrown, because writing to a static field is not allowed.

Parameters
context:ELContext

The context of this evaluation.

base:Object

An ELClass

property:Object

The name of the field

value:Object

The value to set the field of the class to.

Annotations
@Override
Exceptions
NullPointerException:
if context is null
PropertyNotWritableException:
if base object instance of ELClassand property instance of String