|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.el Class CompositeELResolver
java.lang.Object javax.el.ELResolver javax.el.CompositeELResolver
public class CompositeELResolver
- extends ELResolver
维护一个按顺序排列的子
ELResolver
的复合列表。
尽管只有一个 ELResolver
与 ELContext
关联,但对于任何给定的变量或属性解析,通常可以使用多个解析器。ELResolver
使用 CompositeELResolver
连接到一起,以定义丰富语义来计算表达式。
对于 #getValue
、#getType
、#setValue
和 #isReadOnly
方法,ELResolver
不负责解析所有可能的 (base, property) 对。实际上,大部分解析器将仅能处理一种类型的 base
。要指示解析器能够成功的解析特定 (base, property) 对,它必须将 ELContext
的 propertyResolved
属性设置为 true
。如果它无法处理给定对,则必须保持此属性不变。如果 propertyResolved
为 false
,则调用者必须忽略该方法的返回值。
CompositeELResolver
将 ELContext.propertyResolved
标志初始化为 false
,并将其用作迭代其解析器组件的一个停止条件。
设计时方法 #getFeatureDescriptors
和 #getCommonPropertyType
不使用 ELContext.propertyResolved
标志。而是从所有子 ELResolver
中进行收集和组合形成这些方法的结果。
since | JSP 2.1 |
See also | javax.el.ELContext, javax.el.ELResolver |
Maintains an ordered composite list of child ELResolver
s.
Though only a single ELResolver
is associated with an
ELContext
, there are usually multiple resolvers considered
for any given variable or property resolution. ELResolver
s
are combined together using a CompositeELResolver
, to define
rich semantics for evaluating an expression.
For the getValue(javax.el.ELContext, java.lang.Object, java.lang.Object)
, getType(javax.el.ELContext, java.lang.Object, java.lang.Object)
, setValue(javax.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object)
and
isReadOnly(javax.el.ELContext, java.lang.Object, java.lang.Object)
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(javax.el.ELContext, java.lang.Object)
and
getCommonPropertyType(javax.el.ELContext, java.lang.Object)
. Instead, results are collected and
combined from all child ELResolver
s for these methods.
- Since:
- JSP 2.1
- See Also:
ELContext
,ELResolver
Field Summary |
---|
Fields inherited from class javax.el.ELResolver |
---|
RESOLVABLE_AT_DESIGN_TIME, TYPE |
Constructor Summary | |
---|---|
CompositeELResolver()
|
Method Summary | |
---|---|
void |
add(ELResolver elResolver)
Adds the given resolver to the list of component resolvers. |
Class<?> |
getCommonPropertyType(ELContext context,
Object base)
Returns the most general type that this resolver accepts for the property argument, given a base object. |
Iterator<FeatureDescriptor> |
getFeatureDescriptors(ELContext context,
Object base)
Returns information about the set of variables or properties that can be resolved for the given base object. |
Class<?> |
getType(ELContext context,
Object base,
Object property)
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(javax.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object) method. |
Object |
getValue(ELContext context,
Object base,
Object property)
Attempts to resolve the given property object on the given
base object by querying all component resolvers. |
boolean |
isReadOnly(ELContext context,
Object base,
Object property)
For a given base and property , attempts to
determine whether a call to setValue(javax.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object) will always fail. |
void |
setValue(ELContext context,
Object base,
Object property,
Object val)
Attempts to set the value of the given property
object on the given base object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public
CompositeELResolver()
英文文档:
CompositeELResolver
public CompositeELResolver()
Method Detail |
---|
public void
add(ELResolver elResolver)
将给定的解析器添加到解析器组件列表中。
将按添加的顺序参考解析器。
elResolver | 要添加的解析器组件。 |
Throws | NullPointerException:
如果提供的解析器为 null 。 |
add
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
- The component resolver to add.- Throws:
NullPointerException
- If the provided resolver isnull
.
public Object
getValue(ELContext context, Object base, Object property)
尝试通过查询所有解析器组件解析给定 base
对象上的给定 property
对象。
如果此解析器处理给定的 (base, property) 对,则在返回前,ELContext
对象的 propertyResolved
属性必须设置为 true
。如果调用此方法后此属性不为 true
,则调用者应该忽略返回值。
首先,在提供的 ELContext
上将 propertyResolved
设置为 false
。
接下来,对于此组合中的每个解析器组件:
- 调用
getValue()
方法,传入提供的context
、base
和property
。 - 如果
ELContext
的propertyResolved
标志为false
,则继续迭代。 - 否则,迭代将停止,并不再考虑其他解析器组件。此方法返回
getValue()
返回的值。
如果没有一个解析器组件能够执行此操作,则返回值 null
,并且 propertyResolved
标志仍然设置为 false
。
迭代期间解析器组件抛出的任何异常都将传播到此方法的调用者。
context | 此计算的上下文。 |
base |
将返回属性值的 base 对象;或者为 null ,表示解析顶级变量。 |
property | 要解析的属性或变量。 |
return |
如果 ELContext 的 propertyResolved 属性设置为 true ,则返回变量或属性解析的结果;其他情况未定义。 |
Throws | NullPointerException:
如果 context 为 null |
Throws | PropertyNotFoundException:
如果此 ELResolver 处理了给定的 (base, property) 对,但指定变量或属性不存在或不可读。 |
Throws | ELException: 如果执行属性或变量解析时抛出异常。抛出的异常必须作为此异常的 cause 属性包含(如果可用)。 |
getValue
public Object getValue(ELContext context, Object base, Object property)
- Attempts to resolve the given
property
object on the givenbase
object by querying all component resolvers.If this resolver handles the given (base, property) pair, the
propertyResolved
property of theELContext
object must be set totrue
by the resolver, before returning. If this property is nottrue
after this method is called, the caller should ignore the return value.First,
propertyResolved
is set tofalse
on the providedELContext
.Next, for each component resolver in this composite:
- The
getValue()
method is called, passing in the providedcontext
,base
andproperty
. - If the
ELContext
'spropertyResolved
flag isfalse
then iteration continues. - 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 thepropertyResolved
flag remains set tofalse
Any exception thrown by component resolvers during the iteration is propagated to the caller of this method.
- The
- Specified by:
getValue
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The base object whose property value is to be returned, ornull
to resolve a top-level variable.property
- The property or variable to be resolved.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, then the result of the variable or property resolution; otherwise undefined. - Throws:
NullPointerException
- if context isnull
PropertyNotFoundException
- if the given (base, property) pair is handled by thisELResolver
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.
public Class<T>
getType(ELContext context, Object base, Object property)
对于给定的 base
和 property
,尝试标识最一般的对象类型,该类型对于将来调用 #setValue
方法时作为 value
参数传递的对象而言是可接受的。将通过查询所有解析器组件获取结果。
如果此解析器处理给定的 (base, property) 对,则在返回前,ELContext
对象的 propertyResolved
属性必须设置为 true
。如果调用此方法后此属性不为 true
,则调用者应该忽略返回值。
首先,在提供的 ELContext
上将 propertyResolved
设置为 false
。
接下来,对于此组合中的每个组件解析器:
- 调用
getType()
方法,传入提供的context
、base
和property
。 - 如果
ELContext
的propertyResolved
标志为false
,则继续迭代。 - 否则,迭代将停止,并不再考虑其他解析器组件。此方法返回
getType()
返回的值。
如果没有一个解析器组件能够执行此操作,则返回值 null
,并且 propertyResolved
标志仍然设置为 false
。
迭代期间解析器组件抛出的任何异常都将传播到此方法的调用者。
context | 此计算的上下文。 |
base |
将分析属性值的 base 对象;或者为 null ,表示分析顶级变量。 |
property | 要返回可接受类型的属性或变量。 |
return |
如果 ELContext 的 propertyResolved 属性设置为 true ,则返回最一般的可接受类型;其他情况未定义。 |
Throws | NullPointerException:
如果 context 为 null |
Throws | PropertyNotFoundException:
如果此 ELResolver 处理了给定的 (base, property) 对,但指定变量或属性不存在或不可读。 |
Throws | ELException: 如果执行属性或变量解析时抛出异常。抛出的异常必须作为此异常的 cause 属性包含(如果可用)。 |
getType
public Class<?> getType(ELContext context, Object base, Object property)
- For a given
base
andproperty
, attempts to identify the most general type that is acceptable for an object to be passed as thevalue
parameter in a future call to thesetValue(javax.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object)
method. The result is obtained by querying all component resolvers.If this resolver handles the given (base, property) pair, the
propertyResolved
property of theELContext
object must be set totrue
by the resolver, before returning. If this property is nottrue
after this method is called, the caller should ignore the return value.First,
propertyResolved
is set tofalse
on the providedELContext
.Next, for each component resolver in this composite:
- The
getType()
method is called, passing in the providedcontext
,base
andproperty
. - If the
ELContext
'spropertyResolved
flag isfalse
then iteration continues. - 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 thepropertyResolved
flag remains set tofalse
Any exception thrown by component resolvers during the iteration is propagated to the caller of this method.
- The
- Specified by:
getType
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The base object whose property value is to be analyzed, ornull
to analyze a top-level variable.property
- The property or variable to return the acceptable type for.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, then the most general acceptable type; otherwise undefined. - Throws:
NullPointerException
- if context isnull
PropertyNotFoundException
- if the given (base, property) pair is handled by thisELResolver
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.
public void
setValue(ELContext context, Object base, Object property, Object val)
尝试在给定的 base
对象上设置给定的 property
对象的值。要求所有解析器组件尝试设置此值。
如果此解析器处理给定的 (base, property) 对,则在返回前,ELContext
对象的 propertyResolved
属性必须设置为 true
。如果调用此方法后此属性不为 true
,则调用者可以放心地假定没有设置任何值。
首先,在提供的 ELContext
上将 propertyResolved
设置为 false
。
接下来,对于此组合中的每个解析器组件:
- 调用
setValue()
方法,传入提供的context
、base
、property
和value
。 - 如果
ELContext
的propertyResolved
标志为false
,则继续迭代。 - 否则,迭代将停止,并不再考虑其他解析器组件。
如果没有一个解析器组件能够执行此操作,则 propertyResolved
标志仍然设置为 false
。
迭代期间解析器组件抛出的任何异常都将传播到此方法的调用者。
context | 此计算的上下文。 |
base |
将设置属性值的 base 对象;或者为 null ,表示设置顶级变量。 |
property | 要设置的属性或变量。 |
val | 用于设置属性或变量的值。 |
Throws | NullPointerException:
如果 context 为 null |
Throws | PropertyNotFoundException:
如果此 ELResolver 处理了给定的 (base, property) 对,但指定变量或属性不存在。 |
Throws | PropertyNotWritableException:
如果此 ELResolver 处理了给定的 (base, property) 对,但指定的变量或属性不可写。 |
Throws | ELException: 如果尝试设置属性或变量时抛出异常。抛出的异常必须作为此异常的 cause 属性包含(如果可用)。 |
setValue
public void setValue(ELContext context, Object base, Object property, Object val)
- Attempts to set the value of the given
property
object on the givenbase
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 theELContext
object must be set totrue
by the resolver, before returning. If this property is nottrue
after this method is called, the caller can safely assume no value has been set.First,
propertyResolved
is set tofalse
on the providedELContext
.Next, for each component resolver in this composite:
- The
setValue()
method is called, passing in the providedcontext
,base
,property
andvalue
. - If the
ELContext
'spropertyResolved
flag isfalse
then iteration continues. - 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 tofalse
Any exception thrown by component resolvers during the iteration is propagated to the caller of this method.
- The
- Specified by:
setValue
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The base object whose property value is to be set, ornull
to set a top-level variable.property
- The property or variable to be set.val
- The value to set the property or variable to.- Throws:
NullPointerException
- if context isnull
PropertyNotFoundException
- if the given (base, property) pair is handled by thisELResolver
but the specified variable or property does not exist.PropertyNotWritableException
- if the given (base, property) pair is handled by thisELResolver
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.
public boolean
isReadOnly(ELContext context, Object base, Object property)
对于给定的 base
和 property
,尝试确定调用 #setValue
是否将总是失败。将通过查询所有解析器组件获取结果。
如果此解析器处理给定的 (base, property) 对,则在返回前,ELContext
对象的 propertyResolved
属性必须设置为 true
。如果调用此方法后此属性不为 true
,则调用者应该忽略返回值。
首先,在提供的 ELContext
上将 propertyResolved
设置为 false
。
接下来,对于此组合中的每个解析器组件:
- 调用
isReadOnly()
方法,传入提供的context
、base
和property
。 - 如果
ELContext
的propertyResolved
标志为false
,则继续迭代。 - 否则,迭代将停止,并不再考虑其他解析器组件。此方法返回
isReadOnly()
返回的值。
如果没有一个解析器组件能够执行此操作,则返回值 false
,并且 propertyResolved
标志仍然设置为 false
。
迭代期间解析器组件抛出的任何异常都将传播到此方法的调用者。
context | 此计算的上下文。 |
base |
将分析属性值的 base 对象;或者为 null ,表示分析顶级变量。 |
property | 要返回只读状态的属性或变量。 |
return |
如果 ELContext 的 propertyResolved 属性被设置为 true ,则在属性为只读的情况下返回 true ,在非只读的情况下返回 false ;其他情况未定义。 |
Throws | NullPointerException:
如果 context 为 null |
Throws | PropertyNotFoundException:
如果此 ELResolver 处理了给定的 (base, property) 对,但指定变量或属性不存在。 |
Throws | ELException: 如果执行属性或变量解析时抛出异常。抛出的异常必须作为此异常的 cause 属性包含(如果可用)。 |
isReadOnly
public boolean isReadOnly(ELContext context, Object base, Object property)
- For a given
base
andproperty
, attempts to determine whether a call tosetValue(javax.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object)
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 theELContext
object must be set totrue
by the resolver, before returning. If this property is nottrue
after this method is called, the caller should ignore the return value.First,
propertyResolved
is set tofalse
on the providedELContext
.Next, for each component resolver in this composite:
- The
isReadOnly()
method is called, passing in the providedcontext
,base
andproperty
. - If the
ELContext
'spropertyResolved
flag isfalse
then iteration continues. - 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 thepropertyResolved
flag remains set tofalse
Any exception thrown by component resolvers during the iteration is propagated to the caller of this method.
- The
- Specified by:
isReadOnly
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The base object whose property value is to be analyzed, ornull
to analyze a top-level variable.property
- The property or variable to return the read-only status for.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, thentrue
if the property is read-only orfalse
if not; otherwise undefined. - Throws:
NullPointerException
- if context isnull
PropertyNotFoundException
- if the given (base, property) pair is handled by thisELResolver
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.
public java.util.Iterator<E>
getFeatureDescriptors(ELContext context, Object base)
返回可以为给定 base
对象解析的变量或属性集的有关信息。此方法可以用于自动完成的辅助工具。结果将从所有解析器组件搜集得来。
ELContext
的 propertyResolved
属性与此方法无关。所有 ELResolver
的结果都连在一起。
返回的 Iterator
是一个迭代器,它对每个解析器组件的 getFeatureDescriptors
方法所返回迭代器返回的 FeatureDescriptor
对象 Collection 进行迭代。如果解析器返回 null
,则跳过。
context | 此计算的上下文。 |
base |
要枚举有效属性集合的 base 对象;或者为 null ,表示枚举此解析器可以计算的顶级变量集合。 |
return |
包含 0 个或多个(可能无限多个)FeatureDescriptor 对象的 Iterator ;如果此解析器不处理给定的 base 对象,或者结果太复杂而无法用此方法表示,则返回 null |
getFeatureDescriptors
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
- 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 theELContext
is not relevant to this method. The results of allELResolver
s are concatenated.The
Iterator
returned is an iterator over the collection ofFeatureDescriptor
objects returned by the iterators returned by each component resolver'sgetFeatureDescriptors
method. Ifnull
is returned by a resolver, it is skipped. - Specified by:
getFeatureDescriptors
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The base object whose set of valid properties is to be enumerated, ornull
to enumerate the set of top-level variables that this resolver can evaluate.- Returns:
- An
Iterator
containing zero or more (possibly infinitely more)FeatureDescriptor
objects, ornull
if this resolver does not handle the givenbase
object or that the results are too complex to represent with this method - See Also:
FeatureDescriptor
public Class<T>
getCommonPropertyType(ELContext context, Object base)
在给定 base
对象的情况下,返回对于 property
参数此解析器可以接受的最一般类型。此方法可以用于自动完成的辅助工具。将通过查询所有解析器组件获取结果。
返回的 Class
是最具体的类,它是每个解析器组件的 getCommonPropertyType
方法所返回的所有类中的一个常见超类。如果解析器返回 null
,则跳过。
context | 此计算的上下文。 |
base |
要返回最一般属性类型的 base 对象;或者为 null ,表示枚举此解析器可以计算的顶级变量集合。 |
return |
如果此 ELResolver 不了解如何处理给定的 base 对象,则返回 null ;否则,如果接受任何 property 类型,则返回 Object.class ;其他情况下,返回给定 base 可接受的最一般的 property 类型。 |
getCommonPropertyType
public Class<?> getCommonPropertyType(ELContext context, Object base)
- Returns the most general type that this resolver accepts for the
property
argument, given abase
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'sgetCommonPropertyType
method. Ifnull
is returned by a resolver, it is skipped. - Specified by:
getCommonPropertyType
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The base object to return the most general property type for, ornull
to enumerate the set of top-level variables that this resolver can evaluate.- Returns:
null
if thisELResolver
does not know how to handle the givenbase
object; otherwiseObject.class
if any type ofproperty
is accepted; otherwise the most generalproperty
type accepted for the givenbase
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!