|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.faces.component._ComponentAttributesMap
A custom implementation of the Map interface, where get and put calls try to access getter/setter methods of an associated UIComponent before falling back to accessing a real Map object.
Some of the behaviours of this class don't really comply with the definitions of the Map class; for example the key parameter to all methods is required to be of type String only, and after clear(), calls to get can return non-null values. However the JSF spec requires that this class behave in the way implemented below. See UIComponent.getAttributes for more details.
The term "property" is used here to refer to real javabean properties on the underlying UIComponent, while "attribute" refers to an entry in the associated Map.
Nested Class Summary |
Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
Constructor Summary | |
(package private) |
_ComponentAttributesMap(UIComponent component)
Create a map backed by the specified component. |
(package private) |
_ComponentAttributesMap(UIComponent component,
java.util.Map attributes)
Create a map backed by the specified component. |
Method Summary | |
void |
clear()
Clear all the attributes in this map. |
boolean |
containsKey(java.lang.Object key)
Return true if there is an attribute with the specified name, but false if there is a javabean property of that name on the associated UIComponent. |
boolean |
containsValue(java.lang.Object value)
Returns true if there is an attribute with the specified value. |
java.util.Set |
entrySet()
Return a set of all attributes. |
boolean |
equals(java.lang.Object obj)
TODO: Document why this method is necessary, and why it doesn't try to compare the _component field. |
java.lang.Object |
get(java.lang.Object key)
In order: get the value of a property of the underlying UIComponent, read an attribute from this map, or evaluate the component's value-binding of the specified name. |
(package private) java.util.Map |
getUnderlyingMap()
Return the map containing the attributes. |
int |
hashCode()
|
boolean |
isEmpty()
Return true if there are no attributes in this map. |
java.util.Set |
keySet()
Return a set of the keys for all attributes. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Store the provided value as a property on the underlying UIComponent, or as an attribute in a Map if no such property exists. |
void |
putAll(java.util.Map t)
Call put(key, value) for each entry in the provided map. |
java.lang.Object |
remove(java.lang.Object key)
Remove the attribute with the specified name. |
int |
size()
Return the number of attributes in this map. |
java.util.Collection |
values()
Return a collection of the values of all attributes. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
_ComponentAttributesMap(UIComponent component)
This method is expected to be called when a component is first created.
_ComponentAttributesMap(UIComponent component, java.util.Map attributes)
This method is expected to be called during the "restore view" phase.
Method Detail |
public int size()
Note that because the get method can read properties of the UIComponent and evaluate value-bindings, it is possible to have size return zero while calls to the get method return non-null values.
size
in interface java.util.Map
public void clear()
Note that because the get method can read properties of the UIComponent and evaluate value-bindings, it is possible to have calls to the get method return non-null values immediately after a call to clear.
clear
in interface java.util.Map
public boolean isEmpty()
Note that because the get method can read properties of the UIComponent and evaluate value-bindings, it is possible to have isEmpty return true, while calls to the get method return non-null values.
isEmpty
in interface java.util.Map
public boolean containsKey(java.lang.Object key)
Note that it should be impossible for the attributes map to contain an entry with the same name as a javabean property on the associated UIComponent.
containsKey
in interface java.util.Map
key
- must be a String. Anything else will cause a
ClassCastException to be thrown.public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map
value
- null is allowedpublic java.util.Collection values()
values
in interface java.util.Map
public void putAll(java.util.Map t)
putAll
in interface java.util.Map
public java.util.Set entrySet()
entrySet
in interface java.util.Map
public java.util.Set keySet()
keySet
in interface java.util.Map
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
key
- must be a String. Any other type will cause ClassCastException.public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
key
- must be a String. Any other type will cause ClassCastException.public java.lang.Object put(java.lang.Object key, java.lang.Object value)
Note that this method is different from the get method, which does read from a value-binding if one exists. When a value-binding exists for a non-property, putting a value here essentially "masks" the value-binding until that attribute is removed.
The put method is expected to return the previous value of the property/attribute (if any). Because UIComponent property getter methods typically try to evaluate any value-binding expression of the same name this can cause an EL expression to be evaluated, thus invoking a getter method on the user's model. This is fine when the returned value will be used; Unfortunately this is quite pointless when initialising a freshly created component with whatever attributes were specified in the view definition (eg JSP tag attributes). Because the UIComponent.getAttributes method only returns a Map class and this class must be package-private, there is no way of exposing a "putNoReturn" type method.
put
in interface java.util.Map
key
- String, null is not allowedvalue
- null is allowedjava.util.Map getUnderlyingMap()
This method is package-scope so that the UIComponentBase class can access it directly when serializing the component.
public boolean equals(java.lang.Object obj)
equals
in interface java.util.Map
public int hashCode()
hashCode
in interface java.util.Map
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |