Groovy 2.2.1

groovy.util
[Java] Class ObservableList

java.lang.Object
  groovy.util.ObservableList
All Implemented Interfaces:
List

public class ObservableList
extends Object

List 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 ObservableList( {!(it instanceof Closure)} )

 // skip all properties whose name matches a regex
 def map = new ObservableList( { 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 ObservableList.ChangeType

static class ObservableList.ElementAddedEvent

static class ObservableList.ElementClearedEvent

static class ObservableList.ElementEvent

static class ObservableList.ElementRemovedEvent

static class ObservableList.ElementUpdatedEvent

static class ObservableList.MultiElementAddedEvent

static class ObservableList.MultiElementRemovedEvent

protected class ObservableList.ObservableIterator

protected class ObservableList.ObservableListIterator

 
Field Summary
static String CONTENT_PROPERTY

static String SIZE_PROPERTY

 
Constructor Summary
ObservableList()

ObservableList(List delegate)

ObservableList(Closure test)

ObservableList(List delegate, Closure test)

 
Method Summary
void add(int index, Object element)

boolean add(Object o)

boolean addAll(Collection c)

boolean addAll(int index, Collection c)

void addPropertyChangeListener(PropertyChangeListener listener)

void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)

void clear()

boolean contains(Object o)

boolean containsAll(Collection c)

boolean equals(Object o)

protected void fireElementAddedEvent(int index, Object element)

protected void fireElementClearedEvent(List values)

protected void fireElementEvent(ObservableList.ElementEvent event)

protected void fireElementRemovedEvent(int index, Object element)

protected void fireElementUpdatedEvent(int index, Object oldValue, Object newValue)

protected void fireMultiElementAddedEvent(int index, List values)

protected void fireMultiElementRemovedEvent(List values)

protected void fireSizeChangedEvent(int oldValue, int newValue)

Object get(int index)

List getContent()

protected List getDelegateList()

PropertyChangeListener[] getPropertyChangeListeners()

PropertyChangeListener[] getPropertyChangeListeners(String propertyName)

int getSize()

protected Closure getTest()

boolean hasListeners(String propertyName)

int hashCode()

int indexOf(Object o)

boolean isEmpty()

Iterator iterator()

int lastIndexOf(Object o)

ListIterator listIterator()

ListIterator listIterator(int index)

Object remove(int index)

boolean remove(Object o)

boolean removeAll(Collection c)

void removePropertyChangeListener(PropertyChangeListener listener)

void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)

boolean retainAll(Collection c)

Object set(int index, Object element)

int size()

List subList(int fromIndex, int toIndex)

Object[] toArray()

Object[] toArray(Object[] a)

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

Field Detail

CONTENT_PROPERTY

public static final String CONTENT_PROPERTY


SIZE_PROPERTY

public static final String SIZE_PROPERTY


 
Constructor Detail

ObservableList

public ObservableList()


ObservableList

public ObservableList(List delegate)


ObservableList

public ObservableList(Closure test)


ObservableList

public ObservableList(List delegate, Closure test)


 
Method Detail

add

public void add(int index, Object element)


add

public boolean add(Object o)


addAll

public boolean addAll(Collection c)


addAll

public boolean addAll(int index, Collection c)


addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)


addPropertyChangeListener

public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)


clear

public void clear()


contains

public boolean contains(Object o)


containsAll

public boolean containsAll(Collection c)


equals

public boolean equals(Object o)


fireElementAddedEvent

protected void fireElementAddedEvent(int index, Object element)


fireElementClearedEvent

protected void fireElementClearedEvent(List values)


fireElementEvent

protected void fireElementEvent(ObservableList.ElementEvent event)


fireElementRemovedEvent

protected void fireElementRemovedEvent(int index, Object element)


fireElementUpdatedEvent

protected void fireElementUpdatedEvent(int index, Object oldValue, Object newValue)


fireMultiElementAddedEvent

protected void fireMultiElementAddedEvent(int index, List values)


fireMultiElementRemovedEvent

protected void fireMultiElementRemovedEvent(List values)


fireSizeChangedEvent

protected void fireSizeChangedEvent(int oldValue, int newValue)


get

public Object get(int index)


getContent

public List getContent()


getDelegateList

protected List getDelegateList()


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()


indexOf

public int indexOf(Object o)


isEmpty

public boolean isEmpty()


iterator

public Iterator iterator()


lastIndexOf

public int lastIndexOf(Object o)


listIterator

public ListIterator listIterator()


listIterator

public ListIterator listIterator(int index)


remove

public Object remove(int index)


remove

public boolean remove(Object o)


removeAll

public boolean removeAll(Collection c)


removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)


removePropertyChangeListener

public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)


retainAll

public boolean retainAll(Collection c)


set

public Object set(int index, Object element)


size

public int size()


subList

public List subList(int fromIndex, int toIndex)


toArray

public Object[] toArray()


toArray

public Object[] toArray(Object[] a)


 

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