ResourceBundleELResolver (Java EE 5)

Java EE API


javax.el Class ResourceBundleELResolver

java.lang.Object
  extended by javax.el.ELResolver
      extended by javax.el.ResourceBundleELResolver

public class ResourceBundleELResolver
extends ELResolver

Extends: ELResolver

定义 java.util.ResourceBundle 实例上的属性解析行为。

此解析器处理类型为 java.util.ResourceBundle 的 base 对象。它接受任何对象作为属性,并将其强制匹配为 java.lang.String 以便调用 getObject(java.lang.String)

此解析器是只读的,如果调用 setValue,则抛出 PropertyNotWritableException

ELResolver 使用 CompositeELResolver 连接到一起,以定义丰富语义来计算表达式。有关 ELResolver 的详细信息,请参阅 javadoc。

英文文档:

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.

ELResolvers are combined together using CompositeELResolvers, 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
 
Constructor Summary
 
Method Summary
 Class<?>
 Iterator
 Class<?>
 Object
 boolean
 void
 
Methods inherited from class java.lang.Object
 

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,则调用者应该忽略返回值。

英文文档:

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 a String. The Object returned by getObject on the base ResourceBundle will be returned.

If the base is 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 class ELResolver
Parameters:
context - The context of this evaluation.
base - The ResourceBundle to analyze.
property - The name of the property to analyze. Will be coerced to a String.
Returns:
If the propertyResolved property of ELContext was set to true, then null if property is null; otherwise the Object for the given key (property coerced to String) from the ResourceBundle. If no object for the given key can be found, then the String "???" + key + "???".
Throws:
NullPointerException - if context is null
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 如果 ELContextpropertyResolved 属性设置为 true,则返回 null;其他情况未定义。
ThrowsNullPointerException: 如果 context 为 null
英文文档:

getType

public 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.

If the base is 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:
getType in class ELResolver
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 of ELContext was set to true, then null; otherwise undefined.
Throws:
NullPointerException - if context is null

public void setValue(ELContext context, Object base, Object property, Object value)
如果 base 对象为 ResourceBundle,则抛出 PropertyNotWritableException
context 此计算的上下文。
base 要修改的 ResourceBundle。仅处理属于 ResourceBundle 类型的 base。
property 要使用的 String 属性。
value 要设置的值。
ThrowsNullPointerException: 如果 context 为 null
ThrowsPropertyNotWritableException: 如果 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 class ELResolver
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 is null.
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 如果 ELContextpropertyResolved 属性设置为 true,则返回 true;其他情况未定义。
ThrowsNullPointerException: 如果 context 为 null
英文文档:

isReadOnly

public boolean isReadOnly(ELContext context,
                          Object base,
                          Object property)
If the base object is not null and an instanceof ResourceBundle, return true.

Specified by:
isReadOnly in class ELResolver
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 of ELContext was set to true, then true; otherwise undefined.
Throws:
NullPointerException - if context is null

public java.util.Iterator<E> getFeatureDescriptors(ELContext context, Object base)
如果 base 对象为 ResourceBundle,则返回一个 Iterator,它包含 ResourceBundle 中可用的一组键。否则返回 null

返回的 Iterator 必须包含 0 个或多个 java.beans.FeatureDescriptor 实例。每个 info 对象包含有关 ResourceBundle 中一个键的信息,并且初始化如下:

  • displayName - String
  • name – 与 displayName 属性相同。
  • shortDescription – 空字符串
  • expert - false
  • hidden - false
  • preferred - 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 the ResourceBundle. Otherwise, returns null.

    The Iterator returned must contain zero or more instances of FeatureDescriptor. 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
  • In addition, the following named attributes must be set in the returned FeatureDescriptors:
  • ELResolver.TYPE - String.class
  • ELResolver.RESOLVABLE_AT_DESIGN_TIME - true
  • Specified by:
    getFeatureDescriptors in class ELResolver
    Parameters:
    context - The context of this evaluation.
    base - The bundle whose keys are to be iterated over. Only bases of type ResourceBundle are handled by this resolver.
    Returns:
    An Iterator containing zero or more (possibly infinitely more) FeatureDescriptor objects, each representing a key in this bundle, or null 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, returns null.

    Assuming the base is a ResourceBundle, this method will always return String.class.

    Specified by:
    getCommonPropertyType in class ELResolver
    Parameters:
    context - The context of this evaluation.
    base - The bundle to analyze. Only bases of type ResourceBundle are handled by this resolver.
    Returns:
    null if base is not a ResourceBundle; otherwise String.class.


    Submit a bug or feature

    Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

    一看就知道只有菜鸟才干这么无知的事啦。

    PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!