Groovy 2.2.0

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

Bound properties

Authors:
Andres Almiray


Nested Class Summary
enum ObservableMap.ChangeType

static class ObservableMap.MultiPropertyEvent

static class ObservableMap.PropertyAddedEvent

static class ObservableMap.PropertyClearedEvent

static class ObservableMap.PropertyEvent

static class ObservableMap.PropertyRemovedEvent

static class ObservableMap.PropertyUpdatedEvent

 
Field Summary
static String CLEARED_PROPERTY

static String CONTENT_PROPERTY

static String SIZE_PROPERTY

 
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)

protected void fireMultiPropertyEvent(List events)

protected void fireMultiPropertyEvent(ObservableMap.PropertyEvent[] events)

protected void firePropertyAddedEvent(Object key, Object value)

protected void firePropertyClearedEvent(Map values)

protected void firePropertyEvent(ObservableMap.PropertyEvent event)

protected void firePropertyRemovedEvent(Object key, Object value)

protected void firePropertyUpdatedEvent(Object key, Object oldValue, Object newValue)

protected void fireSizeChangedEvent(int oldValue, int newValue)

Object get(Object key)

Map getContent()

protected Map getMapDelegate()

PropertyChangeListener[] getPropertyChangeListeners()

PropertyChangeListener[] getPropertyChangeListeners(String propertyName)

int getSize()

protected Closure getTest()

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
 

Field Detail

CLEARED_PROPERTY

public static final String CLEARED_PROPERTY


CONTENT_PROPERTY

public static final String CONTENT_PROPERTY


SIZE_PROPERTY

public static final String SIZE_PROPERTY


 
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)


fireMultiPropertyEvent

protected void fireMultiPropertyEvent(List events)


fireMultiPropertyEvent

protected void fireMultiPropertyEvent(ObservableMap.PropertyEvent[] events)


firePropertyAddedEvent

protected void firePropertyAddedEvent(Object key, Object value)


firePropertyClearedEvent

protected void firePropertyClearedEvent(Map values)


firePropertyEvent

protected void firePropertyEvent(ObservableMap.PropertyEvent event)


firePropertyRemovedEvent

protected void firePropertyRemovedEvent(Object key, Object value)


firePropertyUpdatedEvent

protected void firePropertyUpdatedEvent(Object key, Object oldValue, Object newValue)


fireSizeChangedEvent

protected void fireSizeChangedEvent(int oldValue, int newValue)


get

public Object get(Object key)


getContent

public Map getContent()


getMapDelegate

protected Map getMapDelegate()


getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners()


getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)


getSize

public int getSize()


getTest

protected Closure getTest()


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-2013 The Codehaus. All rights reserved.