Overview | Package | Class | Deprecated | Index | Help
| Groovy 1.7.10
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## groovy.util
[Java] Class ObservableMap

    java.lang.Object
      groovy.util.ObservableMap

All Implemented Interfaces:
  Map

    public class ObservableMap
    extends Object

Map decorator that will trigger PropertyChangeEvents when a value changes.
An optional Closure may be specified and will work as a filter, if it returns true the property will trigger an event (if the value indeed changed), otherwise it won't. The Closure may receive 1 or 2 parameters, the single one being the value, the other one both the key and value, for example:

     // skip all properties whose value is a closure
     def map = new ObservableMap( {!(it instanceof Closure)} )

     // skip all properties whose name matches a regex
     def map = new ObservableMap( { name, value -> !(name =~ /[A-Z+]/) } )

The current implementation will trigger specialized events in the following scenarios, you need not register a different listener as those events extend from PropertyChangeEvent

- ObservableMap.PropertyAddedEvent - a new property is added to the map
- ObservableMap.PropertyRemovedEvent - a property is removed from the map
- ObservableMap.PropertyUpdatedEvent - a property changes value (same as regular PropertyChangeEvent)
- ObservableMap.PropertyClearedEvent - all properties have been removed from the map
- ObservableMap.MultiPropertyEvent - triggered by calling map.putAll(), contains Added|Updated events

Authors:
  Andres Almiray

Nested Class Summary
`static class` | `ObservableMap.MultiPropertyEvent`
`static class` | `ObservableMap.PropertyAddedEvent`
`static class` | `ObservableMap.PropertyClearedEvent`
`static class` | `ObservableMap.PropertyEvent`
`static class` | `ObservableMap.PropertyRemovedEvent`
`static class` | `ObservableMap.PropertyUpdatedEvent`

Constructor Summary
`ObservableMap()`
`ObservableMap(Closure test)`
`ObservableMap(Map delegate)`
`ObservableMap(Map delegate, Closure test)`

Method Summary
`void` | `addPropertyChangeListener(PropertyChangeListener listener)`
`void` | `addPropertyChangeListener(String propertyName, PropertyChangeListener listener)`
`void` | `clear()`
`boolean` | `containsKey(Object key)`
`boolean` | `containsValue(Object value)`
`Set` | `entrySet()`
`boolean` | `equals(Object o)`
`Object` | `get(Object key)`
`PropertyChangeListener[]` | `getPropertyChangeListeners()`
`PropertyChangeListener[]` | `getPropertyChangeListeners(String propertyName)`
`boolean` | `hasListeners(String propertyName)`
`int` | `hashCode()`
`boolean` | `isEmpty()`
`Set` | `keySet()`
`Object` | `put(Object key, Object value)`
`void` | `putAll(Map map)`
`Object` | `remove(Object key)`
`void` | `removePropertyChangeListener(PropertyChangeListener listener)`
`void` | `removePropertyChangeListener(String propertyName, PropertyChangeListener listener)`
`int` | `size()`
`Collection` | `values()`

Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Constructor Detail

### ObservableMap

    public ObservableMap()

### ObservableMap

    public ObservableMap(Closure test)

### ObservableMap

    public ObservableMap(Map delegate)

### ObservableMap

    public ObservableMap(Map delegate, Closure test)

Method Detail

### addPropertyChangeListener

    public void addPropertyChangeListener(PropertyChangeListener listener)

### addPropertyChangeListener

    public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)

### clear

    public void clear()

### containsKey

    public boolean containsKey(Object key)

### containsValue

    public boolean containsValue(Object value)

### entrySet

    public Set entrySet()

### equals

    public boolean equals(Object o)

### get

    public Object get(Object key)

### getPropertyChangeListeners

    public PropertyChangeListener[] getPropertyChangeListeners()

### getPropertyChangeListeners

    public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)

### hasListeners

    public boolean hasListeners(String propertyName)

### hashCode

    public int hashCode()

### isEmpty

    public boolean isEmpty()

### keySet

    public Set keySet()

### put

    public Object put(Object key, Object value)

### putAll

    public void putAll(Map map)

### remove

    public Object remove(Object key)

### removePropertyChangeListener

    public void removePropertyChangeListener(PropertyChangeListener listener)

### removePropertyChangeListener

    public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)

### size

    public int size()

### values

    public Collection values()

Copyright © 2003-2010 The Codehaus. All rights reserved.