|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.el Class ResourceBundleELResolver
java.lang.Object javax.el.ELResolver javax.el.ResourceBundleELResolver
public class ResourceBundleELResolver
- extends ELResolver
定义
java.util.ResourceBundle
实例上的属性解析行为。
此解析器处理类型为 java.util.ResourceBundle
的 base 对象。它接受任何对象作为属性,并将其强制匹配为 java.lang.String
以便调用 getObject(java.lang.String)
。
此解析器是只读的,如果调用 setValue
,则抛出 PropertyNotWritableException
。
ELResolver
使用 CompositeELResolver
连接到一起,以定义丰富语义来计算表达式。有关 ELResolver
的详细信息,请参阅 javadoc。
since | JSP 2.1 |
See also | javax.el.CompositeELResolver, javax.el.ELResolver, java.util.ResourceBundle |
Defines property resolution behavior on instances of
ResourceBundle
.
This resolver handles base objects of type
java.util.ResourceBundle
. It accepts any object as a property
and coerces it to a java.lang.String
for invoking
ResourceBundle.getObject(java.lang.String)
.
This resolver is read only and will throw a
PropertyNotWritableException
if setValue
is called.
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
,ResourceBundle
Field Summary |
---|
Fields inherited from class javax.el.ELResolver |
---|
RESOLVABLE_AT_DESIGN_TIME, TYPE |
Constructor Summary | |
---|---|
ResourceBundleELResolver()
|
Method Summary | |
---|---|
Class<?> |
getCommonPropertyType(ELContext context,
Object base)
If the base object is a ResourceBundle, returns the most general type that this resolver accepts for the property argument. |
Iterator |
getFeatureDescriptors(ELContext context,
Object base)
If the base object is a ResourceBundle, returns an Iterator
containing the set of keys available in the ResourceBundle . |
Class<?> |
getType(ELContext context,
Object base,
Object property)
If the base object is an instance of ResourceBundle ,
return null , since the resolver is read only. |
Object |
getValue(ELContext context,
Object base,
Object property)
If the base object is an instance of ResourceBundle ,
the provided property will first be coerced to a String . |
boolean |
isReadOnly(ELContext context,
Object base,
Object property)
If the base object is not null and an instanceof ResourceBundle ,
return true . |
void |
setValue(ELContext context,
Object base,
Object property,
Object value)
If the base object is a ResourceBundle, throw a PropertyNotWritableException . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public
ResourceBundleELResolver()
英文文档:
ResourceBundleELResolver
public ResourceBundleELResolver()
Method Detail |
---|
public Object
getValue(ELContext context, Object base, Object property)
如果 base 对象是 ResourceBundle
的一个实例,则提供的属性将首先被强制匹配为 String
。将返回对 base ResourceBundle
调用 getObject
时所返回的 Object
。
如果 base 为 ResourceBundle
,则在返回前,此解析器必须将 ELContext
对象的 propertyResolved
属性设置为 true
。如果调用此方法后此属性不为 true
,则调用者应该忽略返回值。
context | 此计算的上下文。 |
base | 要分析的 ResourceBundle。 |
property |
要分析的属性名称将强制匹配为 String 。 |
return |
如果 ELContext 的 propertyResolved 属性设置为 true ,则在属性为 null 时返回 null ;否则返回 ResourceBundle 中对应给定键(属性强制匹配为 String )的 Object 。如果没有找到对应给定键的对象,则返回 String "?"+ key + "?"。 |
Throws | NullPointerException:
如果 context 为 null |
Throws | ELException: 如果执行属性或变量解析时抛出异常。抛出的异常必须作为此异常的 cause 属性包含(如果可用)。 |
getValue
public Object getValue(ELContext context, Object base, Object property)
- If the base object is an instance of
ResourceBundle
, the provided property will first be coerced to aString
. TheObject
returned bygetObject
on the baseResourceBundle
will be returned.
ResourceBundle
, 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.
- Specified by:
getValue
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The ResourceBundle to analyze.property
- The name of the property to analyze. Will be coerced to aString
.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, thennull
if property isnull
; otherwise theObject
for the given key (property coerced toString
) from theResourceBundle
. If no object for the given key can be found, then theString
"???" + key + "???". - Throws:
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 Class<T>
getType(ELContext context, Object base, Object property)
如果 base 对象是 ResourceBundle
的一个实例,则返回 null
,因为该解析器是只读的。
如果 base 为 ResourceBundle
,则在返回前,此解析器必须将 ELContext
对象的 propertyResolved
属性设置为 true
。如果调用此方法后此属性不为 true
,则调用者应该忽略返回值。
context | 此计算的上下文。 |
base | 要分析的 ResourceBundle。 |
property | 要分析的属性名称 |
return |
如果 ELContext 的 propertyResolved 属性设置为 true ,则返回 null ;其他情况未定义。 |
Throws | NullPointerException:
如果 context 为 null |
getType
public Class<?> getType(ELContext context, Object base, Object property)
- If the base object is an instance of
ResourceBundle
, returnnull
, since the resolver is read only.If the base is
ResourceBundle
, 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. - Specified by:
getType
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The ResourceBundle to analyze.property
- The name of the property to analyze.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, thennull
; otherwise undefined. - Throws:
NullPointerException
- if context isnull
public void
setValue(ELContext context, Object base, Object property, Object value)
如果 base 对象为 ResourceBundle,则抛出 PropertyNotWritableException
。
context | 此计算的上下文。 |
base | 要修改的 ResourceBundle。仅处理属于 ResourceBundle 类型的 base。 |
property | 要使用的 String 属性。 |
value | 要设置的值。 |
Throws | NullPointerException:
如果 context 为 null 。 |
Throws | PropertyNotWritableException: 如果 base 为 ReasourceBundle 的一个实例,则总是抛出该异常。 |
setValue
public void setValue(ELContext context, Object base, Object property, Object value)
- If the base object is a ResourceBundle, throw a
PropertyNotWritableException
. - Specified by:
setValue
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The ResourceBundle to be modified. Only bases that are of type ResourceBundle are handled.property
- The String property to use.value
- The value to be set.- Throws:
NullPointerException
- if context isnull
.PropertyNotWritableException
- Always thrown if base is an instance of ReasourceBundle.
public boolean
isReadOnly(ELContext context, Object base, Object property)
如果 base 对象不为 null,也不为 ResourceBundle
的实例,则返回 true
。
context | 此计算的上下文。 |
base | 要修改的 ResourceBundle。仅处理属于 ResourceBundle 类型的 base。 |
property | 要使用的 String 属性。 |
return |
如果 ELContext 的 propertyResolved 属性设置为 true ,则返回 true ;其他情况未定义。 |
Throws | NullPointerException:
如果 context 为 null |
isReadOnly
public boolean isReadOnly(ELContext context, Object base, Object property)
- If the base object is not null and an instanceof
ResourceBundle
, returntrue
. - Specified by:
isReadOnly
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The ResourceBundle to be modified. Only bases that are of type ResourceBundle are handled.property
- The String property to use.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, thentrue
; otherwise undefined. - Throws:
NullPointerException
- if context isnull
public java.util.Iterator<E>
getFeatureDescriptors(ELContext context, Object base)
如果 base 对象为 ResourceBundle,则返回一个 Iterator
,它包含 ResourceBundle
中可用的一组键。否则返回 null
。
返回的 Iterator
必须包含 0 个或多个 java.beans.FeatureDescriptor
实例。每个 info 对象包含有关 ResourceBundle 中一个键的信息,并且初始化如下:
String
键
false
false
true
FeatureDescriptor
中设置以下指定的属性:
ELResolver#TYPE
- String.class
ELResolver#RESOLVABLE_AT_DESIGN_TIME
- true
context | 此计算的上下文。 |
base |
要迭代其键的包。此解析器仅处理属于 ResourceBundle 类型的 base。 |
return |
包含 0 个或多个(可能无限多个)FeatureDescriptor 对象的 Iterator ,每个对象代表此包中的一个键;如果 base 对象不是 ResourceBundle,则返回 null 。 |
getFeatureDescriptors
public Iterator getFeatureDescriptors(ELContext context, Object base)
- If the base object is a ResourceBundle, returns an
Iterator
containing the set of keys available in theResourceBundle
. Otherwise, returnsnull
.The
Iterator
returned must contain zero or more instances ofFeatureDescriptor
. Each info object contains information about a key in the ResourceBundle, and is initialized as follows:- displayName - The
String
key- name - Same as displayName property.
- shortDescription - Empty string
- expert -
false
- hidden -
false
- preferred -
true
- displayName - The
FeatureDescriptor
s:
ELResolver.TYPE
- String.class
ELResolver.RESOLVABLE_AT_DESIGN_TIME
- true
- Specified by:
getFeatureDescriptors
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The bundle whose keys are to be iterated over. Only bases of typeResourceBundle
are handled by this resolver.- Returns:
- An
Iterator
containing zero or more (possibly infinitely more)FeatureDescriptor
objects, each representing a key in this bundle, ornull
if the base object is not a ResourceBundle. - See Also:
FeatureDescriptor
public Class<T>
getCommonPropertyType(ELContext context, Object base)
如果 base 对象是 ResourceBundle,则返回对于 property
参数此解析器可接受的最一般类型。否则返回 null
。
假定 base 为 ResourceBundle
,则此方法将总是返回 String.class
。
context | 此计算的上下文。 |
base |
要分析的包。此解析器仅处理属于 ResourceBundle 类型的 base。 |
return |
如果 base 不为 ResourceBundle ,则返回 null ;否则返回 String.class 。 |
getCommonPropertyType
public Class<?> getCommonPropertyType(ELContext context, Object base)
- If the base object is a ResourceBundle, returns the most general type
that this resolver accepts for the
property
argument. Otherwise, returnsnull
.Assuming the base is a
ResourceBundle
, this method will always returnString.class
. - Specified by:
getCommonPropertyType
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The bundle to analyze. Only bases of typeResourceBundle
are handled by this resolver.- Returns:
null
if base is not aResourceBundle
; otherwiseString.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 : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!