Save This Page
Home » glassfish-v2ur2-b04-src » javax » el » [javadoc | source]
javax.el
public class: MapELResolver [javadoc | source]
java.lang.Object
   javax.el.ELResolver
      javax.el.MapELResolver
Defines property resolution behavior on instances of java.util.Map .

This resolver handles base objects of type java.util.Map. It accepts any object as a property and uses that object as a key in the map. The resulting value is the value in the map that is associated with that key.

This resolver can be constructed in read-only mode, which means that #isReadOnly will always return true and #setValue will always throw PropertyNotWritableException.

ELResolvers are combined together using CompositeELResolver s, to define rich semantics for evaluating an expression. See the javadocs for ELResolver for details.

Fields inherited from javax.el.ELResolver:
TYPE,  RESOLVABLE_AT_DESIGN_TIME
Constructor:
 public MapELResolver() 
 public MapELResolver(boolean isReadOnly) 
Method from javax.el.MapELResolver Summary:
getCommonPropertyType,   getFeatureDescriptors,   getType,   getValue,   isReadOnly,   setValue
Methods from javax.el.ELResolver:
getCommonPropertyType,   getFeatureDescriptors,   getType,   getValue,   isReadOnly,   setValue
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.el.MapELResolver Detail:
 public Class getCommonPropertyType(ELContext context,
    Object base) 
    If the base object is a map, returns the most general type that this resolver accepts for the property argument. Otherwise, returns null.

    Assuming the base is a Map, this method will always return Object.class. This is because Maps accept any object as a key.

 public Iterator getFeatureDescriptors(ELContext context,
    Object base) 
    If the base object is a map, returns an Iterator containing the set of keys available in the Map. Otherwise, returns null.

    The Iterator returned must contain zero or more instances of java.beans.FeatureDescriptor . Each info object contains information about a key in the Map, and is initialized as follows:

  • displayName - The return value of calling the toString method on this key, or "null" if the key is null.
  • 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 - The return value of calling the getClass() method on this key, or null if the key is null.
  • ELResolver#RESOLVABLE_AT_DESIGN_TIME - true
 public Class getType(ELContext context,
    Object base,
    Object property) 
    If the base object is a map, returns the most general acceptable type for a value in this map.

    If the base is a Map, 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.

    Assuming the base is a Map, this method will always return Object.class. This is because Maps accept any object as the value for a given key.

 public Object getValue(ELContext context,
    Object base,
    Object property) 
    If the base object is a map, returns the value associated with the given key, as specified by the property argument. If the key was not found, null is returned.

    If the base is a Map, 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.

    Just as in java.util.Map#get , just because null is returned doesn't mean there is no mapping for the key; it's also possible that the Map explicitly maps the key to null.

 public boolean isReadOnly(ELContext context,
    Object base,
    Object property) 
    If the base object is a map, returns whether a call to #setValue will always fail.

    If the base is a Map, 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 this resolver was constructed in read-only mode, this method will always return true.

    If a Map was created using java.util.Collections#unmodifiableMap , this method must return true. Unfortunately, there is no Collections API method to detect this. However, an implementation can create a prototype unmodifiable Map and query its runtime type to see if it matches the runtime type of the base object as a workaround.

 public  void setValue(ELContext context,
    Object base,
    Object property,
    Object val) 
    If the base object is a map, attempts to set the value associated with the given key, as specified by the property argument.

    If the base is a Map, 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 can safely assume no value was set.

    If this resolver was constructed in read-only mode, this method will always throw PropertyNotWritableException.

    If a Map was created using java.util.Collections#unmodifiableMap , this method must throw PropertyNotWritableException. Unfortunately, there is no Collections API method to detect this. However, an implementation can create a prototype unmodifiable Map and query its runtime type to see if it matches the runtime type of the base object as a workaround.