|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.el Class ArrayELResolver
java.lang.Object javax.el.ELResolver javax.el.ArrayELResolver
public class ArrayELResolver
- extends ELResolver
定义数组上的属性解析行为。
此解析器处理类型为 Java 语言数组的 base 对象。它接受任何对象作为属性,并且将该对象强制匹配为数组中的整数索引。所得值就是数组中位于该索引处的值。
此解析器可以以只读模式构建,这意味着 #isReadOnly
将总是返回 true
,#setValue
将总是抛出 PropertyNotWritableException
。
ELResolver
使用 CompositeELResolver
连接到一起,以定义丰富语义来计算表达式。有关 ELResolver
的详细信息,请参阅 javadoc。
since | JSP 2.1 |
See also | javax.el.CompositeELResolver, javax.el.ELResolver |
Defines property resolution behavior on arrays.
This resolver handles base objects that are Java language arrays. It accepts any object as a property and coerces that object into an integer index into the array. The resulting value is the value in the array at that index.
This resolver can be constructed in read-only mode, which means that
isReadOnly
will always return true
and
setValue(javax.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object)
will always throw
PropertyNotWritableException
.
ELResolver
s are combined together using
CompositeELResolver
s, to define rich semantics for evaluating
an expression. See the javadocs for ELResolver
for details.
- Since:
- JSP 2.1
- See Also:
CompositeELResolver
,ELResolver
Field Summary |
---|
Fields inherited from class javax.el.ELResolver |
---|
RESOLVABLE_AT_DESIGN_TIME, TYPE |
Constructor Summary | |
---|---|
ArrayELResolver()
Creates a new read/write ArrayELResolver . |
|
ArrayELResolver(boolean isReadOnly)
Creates a new ArrayELResolver whose read-only status is
determined by the given parameter. |
Method Summary | |
---|---|
Class<?> |
getCommonPropertyType(ELContext context,
Object base)
If the base object is a Java language array, returns the most general type that this resolver accepts for the property argument. |
Iterator<FeatureDescriptor> |
getFeatureDescriptors(ELContext context,
Object base)
Always returns null , since there is no reason to
iterate through set set of all integers. |
Class<?> |
getType(ELContext context,
Object base,
Object property)
If the base object is an array, returns the most general acceptable type for a value in this array. |
Object |
getValue(ELContext context,
Object base,
Object property)
If the base object is a Java language array, returns the value at the given index. |
boolean |
isReadOnly(ELContext context,
Object base,
Object property)
If the base object is a Java language array, returns 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)
If the base object is a Java language array, attempts to set the value at the given index with the given value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public
ArrayELResolver()
创建新的读/写 ArrayELResolver
。
英文文档:
ArrayELResolver
public ArrayELResolver()
- Creates a new read/write
ArrayELResolver
.
public
ArrayELResolver(boolean isReadOnly)
创建新的 ArrayELResolver
,其只读状态由给定的参数确定。
isReadOnly |
如果此解析器无法修改数组,则为 true ;否则为 false 。 |
ArrayELResolver
public ArrayELResolver(boolean isReadOnly)
- Creates a new
ArrayELResolver
whose read-only status is determined by the given parameter.- Parameters:
isReadOnly
-true
if this resolver cannot modify arrays;false
otherwise.
Method Detail |
---|
public Class<T>
getType(ELContext context, Object base, Object property)
如果 base 对象是数组,则返回此数组中的值可以接受的最一般类型。
如果 base 为 array
,则在返回前,此解析器必须将 ELContext
对象的 propertyResolved
属性设置为 true
。如果调用此方法后此属性不为 true
,则调用者应该忽略返回值。
如果 base 为 array
,则此方法将总是返回 base.getClass().getComponentType()
,这是可以在数组的任何给定索引位置存储的最一般组件类型。
context | 此计算的上下文。 |
base | 要分析的数组。此解析器仅处理属于 Java 语言数组的 base。 |
property | 返回可接受类型的数组元素的索引。将强制匹配为整数,其他情况下将被此解析器忽略。 |
return |
如果 ELContext 的 propertyResolved 属性设置为 true ,则返回最一般的可接受类型;其他情况未定义。 |
Throws | PropertyNotFoundException: 如果给定索引超出此数组的范围。 |
Throws | NullPointerException:
如果 context 为 null |
Throws | ELException: 如果执行属性或变量解析时抛出异常。抛出的异常必须作为此异常的 cause 属性包含(如果可用)。 |
getType
public Class<?> getType(ELContext context, Object base, Object property)
- If the base object is an array, returns the most general acceptable type
for a value in this array.
If the base is a
array
, thepropertyResolved
property of theELContext
object must be set totrue
by this resolver, before returning. If this property is nottrue
after this method is called, the caller should ignore the return value.Assuming the base is an
array
, this method will always returnbase.getClass().getComponentType()
, which is the most general type of component that can be stored at any given index in the array. - Specified by:
getType
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The array to analyze. Only bases that are Java language arrays are handled by this resolver.property
- The index of the element in the array to return the acceptable type for. Will be coerced into an integer, but otherwise ignored by this resolver.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, then the most general acceptable type; otherwise undefined. - Throws:
PropertyNotFoundException
- if the given index is out of bounds for this array.NullPointerException
- if context isnull
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 Object
getValue(ELContext context, Object base, Object property)
如果 base 对象为 Java 语言数组,则返回给定索引位置的值。property
参数指定的索引,强制匹配为整数。如果无法执行强制匹配,则抛出 IllegalArgumentException
。如果索引超出边界,则返回 null
。
如果 base 为 Java 语言数组,则在返回前,此解析器必须将 ELContext
对象的 propertyResolved
属性设置为 true
。如果调用此方法后此属性不为 true
,则调用者应该忽略返回值。
context | 此计算的上下文。 |
base | 要分析的数组。此解析器仅处理属于 Java 语言数组的 base。 |
property | 要返回的值的索引。将强制匹配为整数。 |
return |
如果 ELContext 的 propertyResolved 属性设置为 true ,则返回给定索引处的值;如果索引超出边界,则返回 null 。其他情况未定义。 |
Throws | IllegalArgumentException: 如果属性无法强制匹配为整数。 |
Throws | NullPointerException:
如果 context 为 null 。 |
Throws | ELException: 如果执行属性或变量解析时抛出异常。抛出的异常必须作为此异常的 cause 属性包含(如果可用)。 |
getValue
public Object getValue(ELContext context, Object base, Object property)
- If the base object is a Java language array, returns the value at the
given index. The index is specified by the
property
argument, and coerced into an integer. If the coercion could not be performed, anIllegalArgumentException
is thrown. If the index is out of bounds,null
is returned.If the base is a Java language array, the
propertyResolved
property of theELContext
object must be set totrue
by this resolver, before returning. If this property is nottrue
after this method is called, the caller should ignore the return value. - Specified by:
getValue
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The array to analyze. Only bases that are Java language arrays are handled by this resolver.property
- The index of the value to be returned. Will be coerced into an integer.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, then the value at the given index ornull
if the index was out of bounds. Otherwise, undefined. - Throws:
IllegalArgumentException
- if the property could not be coerced into an integer.NullPointerException
- if context isnull
.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 对象为 Java 语言数组,则尝试用给定的值设置给定索引位置的值。property
参数指定的索引,强制匹配为整数。如果无法执行强制匹配,则抛出 IllegalArgumentException
。如果索引超出边界,则抛出 PropertyNotFoundException
。
如果 base 为 Java 语言数组,则在返回前,此解析器必须将 ELContext
对象的 propertyResolved
属性设置为 true
。如果调用此方法后此属性不为 true
,则调用者可以放心地假定没有设置任何值。
如果此解析器以只读模式构造,则此方法将总是抛出 PropertyNotWritableException
。
context | 此计算的上下文。 |
base | 要修改的数组。此解析器仅处理属于 Java 语言数组的 base。 |
property | 要设置的值的索引。将强制匹配为整数。 |
val | 要在给定索引处设置的值。 |
Throws | ClassCastException: 如果指定元素的类不允许该元素添加到此数组。 |
Throws | NullPointerException:
如果 context 为 null 。 |
Throws | IllegalArgumentException: 如果属性无法强制匹配为整数,或者指定元素的某个方面不允许该元素添加到此数组。 |
Throws | PropertyNotWritableException: 如果此解析器以只读模式构建。 |
Throws | PropertyNotFoundException: 如果给定索引超出此数组的范围。 |
Throws | ELException: 如果执行属性或变量解析时抛出异常。抛出的异常必须作为此异常的 cause 属性包含(如果可用)。 |
setValue
public void setValue(ELContext context, Object base, Object property, Object val)
- If the base object is a Java language array, attempts to set the
value at the given index with the given value. The index is specified
by the
property
argument, and coerced into an integer. If the coercion could not be performed, anIllegalArgumentException
is thrown. If the index is out of bounds, aPropertyNotFoundException
is thrown.If the base is a Java language array, the
propertyResolved
property of theELContext
object must be set totrue
by this resolver, before returning. If this property is nottrue
after this method is called, the caller can safely assume no value was set.If this resolver was constructed in read-only mode, this method will always throw
PropertyNotWritableException
. - Specified by:
setValue
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The array to be modified. Only bases that are Java language arrays are handled by this resolver.property
- The index of the value to be set. Will be coerced into an integer.val
- The value to be set at the given index.- Throws:
ClassCastException
- if the class of the specified element prevents it from being added to this array.NullPointerException
- if context isnull
.IllegalArgumentException
- if the property could not be coerced into an integer, or if some aspect of the specified element prevents it from being added to this array.PropertyNotWritableException
- if this resolver was constructed in read-only mode.PropertyNotFoundException
- if the given index is out of bounds for this array.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 boolean
isReadOnly(ELContext context, Object base, Object property)
如果 base 对象是 Java 语言数组,则返回对 #setValue
的调用是否总是失败。
如果 base 为 Java 语言数组,则在返回前,此解析器必须将 ELContext
对象的 propertyResolved
属性设置为 true
。如果调用此方法后此属性不为 true
,则调用者应该忽略返回值。
如果此解析器以只读模式构造,则此方法将总是返回 true
。否则返回 false
。
context | 此计算的上下文。 |
base | 要分析的数组。此解析器仅处理属于 Java 语言数组的 base。 |
property | 返回可接受类型的数组元素的索引。将强制匹配为整数,其他情况下将被此解析器忽略。 |
return |
如果 ELContext 的 propertyResolved 属性设置为 true ,则调用 setValue 方法总是失败的情况下返回 true ,该调用可能成功的情况下返回 false ;其他情况未定义。 |
Throws | PropertyNotFoundException: 如果给定索引超出此数组的范围。 |
Throws | NullPointerException:
如果 context 为 null |
Throws | ELException: 如果执行属性或变量解析时抛出异常。抛出的异常必须作为此异常的 cause 属性包含(如果可用)。 |
isReadOnly
public boolean isReadOnly(ELContext context, Object base, Object property)
- If the base object is a Java language array, returns whether a call to
setValue(javax.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object)
will always fail.If the base is a Java language array, the
propertyResolved
property of theELContext
object must be set totrue
by this resolver, before returning. If this property is nottrue
after this method is called, the caller should ignore the return value.If this resolver was constructed in read-only mode, this method will always return
true
. Otherwise, it returnsfalse
. - Specified by:
isReadOnly
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The array to analyze. Only bases that are a Java language array are handled by this resolver.property
- The index of the element in the array to return the acceptable type for. Will be coerced into an integer, but otherwise ignored by this resolver.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, thentrue
if calling thesetValue
method will always fail orfalse
if it is possible that such a call may succeed; otherwise undefined. - Throws:
PropertyNotFoundException
- if the given index is out of bounds for this array.NullPointerException
- if context isnull
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)
总是返回 null
,因为没有理由迭代所有整数集。
#getCommonPropertyType
方法返回有关此解析器接受的属性的足够信息。
context | 此计算的上下文。 |
base | 要分析的数组。此解析器仅处理属于 Java 语言数组的 base。 |
return |
null 。
|
getFeatureDescriptors
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
- Always returns
null
, since there is no reason to iterate through set set of all integers.The
getCommonPropertyType(javax.el.ELContext, java.lang.Object)
method returns sufficient information about what properties this resolver accepts. - Specified by:
getFeatureDescriptors
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The array to analyze. Only bases that are a Java language array are handled by this resolver.- Returns:
null
.- See Also:
FeatureDescriptor
public Class<T>
getCommonPropertyType(ELContext context, Object base)
如果 base 对象不是 Java 语言数组,则返回对于 property
参数此解析器可接受的最一般类型。否则返回 null
。
假定 base 为数组,则此方法将总是返回 Integer.class
。这是因为数组接受整数作为其索引。
context | 此计算的上下文。 |
base | 要分析的数组。此解析器仅处理属于 Java 语言数组的 base。 |
return |
如果 base 不是 Java 语言数组,则返回 null ;否则返回 Integer.class 。 |
getCommonPropertyType
public Class<?> getCommonPropertyType(ELContext context, Object base)
- If the base object is a Java language array, returns the most general
type that this resolver accepts for the
property
argument. Otherwise, returnsnull
.Assuming the base is an array, this method will always return
Integer.class
. This is because arrays accept integers for their index. - Specified by:
getCommonPropertyType
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The array to analyze. Only bases that are a Java language array are handled by this resolver.- Returns:
null
if base is not a Java language array; otherwiseInteger.class
.
|
|||||||||
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 : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!