Class ContainerWidgetAsMap

  extended byjava.util.AbstractMap
      extended byorg.apache.cocoon.forms.util.ContainerWidgetAsMap
All Implemented Interfaces:

public class ContainerWidgetAsMap
extends AbstractMap

A Map view of a container widget, keys being children names and values either maps (for container children), objects (for terminal children) or lists (for repeaters).

The returned map is non-modifiable, except using the put() method, which much refer to an existing child widget, and putAll(Map) that will silently ignore keys that don't refer to existing child widgets.

Also, this map accepts getting and setting values for keys that correspond to value-less widgets such as Action. The result in that case is always null. This is to allow global retrieving or filling of the map values.

$Id: ContainerWidgetAsMap.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Nested Class Summary
Nested classes inherited from class java.util.Map
Field Summary
protected  AbstractContainerWidget container
Constructor Summary
ContainerWidgetAsMap(AbstractContainerWidget container)
          Same as ContainerWidgetAsMap(container, false)
ContainerWidgetAsMap(AbstractContainerWidget container, boolean keysToLowerCase)
          Wraps a container widget in a Map.
Method Summary
 Set entrySet()
 Object get(Object key)
 ContainerWidget getWidget()
          Get the container widget that is wrapped by this Map.
 Widget getWidget(String path)
          Get a widget relative to the container wrapped by this Map
 Object put(Object key, Object value)
          Put a value in a child widget.
 void putAll(Map map)
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, remove, size, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait

Field Detail


protected AbstractContainerWidget container
Constructor Detail


public ContainerWidgetAsMap(AbstractContainerWidget container,
                            boolean keysToLowerCase)
Wraps a container widget in a Map.

The keysToLowerCase argument specifies if input keys given in get(), put() and putAll() should be converted to lower case before searching for the corresponding widget. This feature allows to directly feed widgets with Maps coming from JDBC resultset rows where keys are uppercase (see JDBI).

container - the container to wrap
keysToLowerCase - should we convert keys to lower case?


public ContainerWidgetAsMap(AbstractContainerWidget container)
Same as ContainerWidgetAsMap(container, false)

Method Detail


public ContainerWidget getWidget()
Get the container widget that is wrapped by this Map.

the wrapped ContainerWidget


public Widget getWidget(String path)
Get a widget relative to the container wrapped by this Map

path - a widget lookup path
the widget pointed to by path or null if it doesn't exist.
See Also:


public Object put(Object key,
                  Object value)
Put a value in a child widget. The value must be compatible with the datatype expected by the child widget. In the case of repeaters and containers, this datatype is Collection and Map respectively, which will be used to fill the rows and child widgets.

Note also that the contract of put requires the previous value to be returned. In the case of repeaters and containers, the value is a live wrapper around the actual widget, meaning that it's not different from the current value.


public void putAll(Map map)


public Object get(Object key)


public Set entrySet()

Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.