Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cocoon.forms.util
Class ContainerWidgetAsMap

    java.lang.Object
      java.util.AbstractMap
          org.apache.cocoon.forms.util.ContainerWidgetAsMap

All Implemented Interfaces:
  Map

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.

Since:
  2.1.8
Version:
  $Id: ContainerWidgetAsMap.java 587759 2007-10-24 03:00:37Z vgritsenko $

Nested Class Summary

Nested classes inherited from class java.util.Map
`Map.Entry`

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

### container

    protected AbstractContainerWidget container

Constructor Detail

### ContainerWidgetAsMap

    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 `Map`s coming from JDBC resultset rows where keys are uppercase (see JDBI).

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

### ContainerWidgetAsMap

    public ContainerWidgetAsMap(AbstractContainerWidget container)

  Same as `ContainerWidgetAsMap(container, false)`

Method Detail

### getWidget

    public ContainerWidget getWidget()

  Get the container widget that is wrapped by this `Map`.

  Returns:
    the wrapped `ContainerWidget`

### getWidget

    public Widget getWidget(String path)

  Get a widget relative to the container wrapped by this `Map`

  Parameters:
    `path` - a widget lookup path
  Returns:
    the widget pointed to by `path` or `null` if it doesn't exist.
  See Also:
    `Widget.lookupWidget(String)`

### put

    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.

### putAll

    public void putAll(Map map)

### get

    public Object get(Object key)

### entrySet

    public Set entrySet()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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