org.progeeks.util
Class DefaultObservableList

java.lang.Object
  extended by org.progeeks.util.DefaultObservableList
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, ObservableList
Direct Known Subclasses:
ActionList, ObservableAdjacencyList

public class DefaultObservableList
extends java.lang.Object
implements ObservableList, java.io.Serializable, java.lang.Cloneable

A java.util.List wrapper that will deliver the appropriate ListPropertyChangeEvents when the list is modified.

Version:
$Revision: 1.5 $
Author:
Paul Speed
See Also:
Serialized Form

Constructor Summary
DefaultObservableList()
          Creates an ObservableList that delegates to an ArrayList and will fire PropertyChangeEvents for the "list" property.
DefaultObservableList(java.util.List list)
          Creates an ObservableList that delegates to the specified list and will fire PropertyChangeEvents for the "list" property.
DefaultObservableList(java.lang.String propertyName, java.util.List list)
          Creates an ObservableList that delegates to the specified list and will fire PropertyChangeEvents for the specified property name.
 
Method Summary
 void add(int index, java.lang.Object element)
           
 boolean add(java.lang.Object o)
           
 boolean addAll(java.util.Collection c)
           
 boolean addAll(int index, java.util.Collection c)
           
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a listener that will be notified when items are added, updated, or removed from the list.
 void clear()
           
 java.lang.Object clone()
          Creates a shallow copy of this observable list minus the current set of listeners.
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection c)
           
 boolean equals(java.lang.Object o)
           
protected  void fireElementsInserted(int first, int last, java.util.List original)
          Sends an event to interested listeners that this property has had elements inserted.
protected  void fireElementsModified(int first, int last, java.util.List original)
          Sends an event to interested listeners that this property has had elements modified.
protected  void fireElementsRemoved(int first, int last, java.util.List original)
          Sends an event to interested listeners that this property has had elements removed.
protected  void firePropertyChangeEvent(java.beans.PropertyChangeEvent event)
          Implemented by subclasses to deliver a change event to the appropriately registered listeners.
 java.lang.Object get(int index)
           
protected  java.lang.String getPropertyName()
           
 int hashCode()
           
 int indexOf(java.lang.Object o)
           
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 int lastIndexOf(java.lang.Object o)
           
 java.util.ListIterator listIterator()
           
 java.util.ListIterator listIterator(int index)
           
 java.lang.Object remove(int index)
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection c)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a previously registered listener.
 boolean retainAll(java.util.Collection c)
           
 java.lang.Object set(int index, java.lang.Object element)
           
protected  void setList(java.util.List list)
           
 int size()
           
 java.util.List subList(int from, int to)
           
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultObservableList

public DefaultObservableList()
Creates an ObservableList that delegates to an ArrayList and will fire PropertyChangeEvents for the "list" property.


DefaultObservableList

public DefaultObservableList(java.util.List list)
Creates an ObservableList that delegates to the specified list and will fire PropertyChangeEvents for the "list" property.


DefaultObservableList

public DefaultObservableList(java.lang.String propertyName,
                             java.util.List list)
Creates an ObservableList that delegates to the specified list and will fire PropertyChangeEvents for the specified property name.

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a shallow copy of this observable list minus the current set of listeners.

Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

setList

protected void setList(java.util.List list)

size

public int size()
Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.List

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection
Specified by:
isEmpty in interface java.util.List

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.List

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.List

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.List

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.List

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.List

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.List

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface java.util.Collection
Specified by:
containsAll in interface java.util.List

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.List

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Specified by:
addAll in interface java.util.List

removeAll

public boolean removeAll(java.util.Collection c)
Specified by:
removeAll in interface java.util.Collection
Specified by:
removeAll in interface java.util.List

retainAll

public boolean retainAll(java.util.Collection c)
Specified by:
retainAll in interface java.util.Collection
Specified by:
retainAll in interface java.util.List

clear

public void clear()
Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.List

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Collection
Specified by:
equals in interface java.util.List
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection
Specified by:
hashCode in interface java.util.List
Overrides:
hashCode in class java.lang.Object

get

public java.lang.Object get(int index)
Specified by:
get in interface java.util.List

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Specified by:
set in interface java.util.List

add

public void add(int index,
                java.lang.Object element)
Specified by:
add in interface java.util.List

remove

public java.lang.Object remove(int index)
Specified by:
remove in interface java.util.List

indexOf

public int indexOf(java.lang.Object o)
Specified by:
indexOf in interface java.util.List

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Specified by:
lastIndexOf in interface java.util.List

listIterator

public java.util.ListIterator listIterator()
Specified by:
listIterator in interface java.util.List

listIterator

public java.util.ListIterator listIterator(int index)
Specified by:
listIterator in interface java.util.List

subList

public java.util.List subList(int from,
                              int to)
Specified by:
subList in interface java.util.List

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: ObservableList
Adds a listener that will be notified when items are added, updated, or removed from the list.

Specified by:
addPropertyChangeListener in interface ObservableList

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: ObservableList
Removes a previously registered listener.

Specified by:
removePropertyChangeListener in interface ObservableList

getPropertyName

protected java.lang.String getPropertyName()

firePropertyChangeEvent

protected void firePropertyChangeEvent(java.beans.PropertyChangeEvent event)
Implemented by subclasses to deliver a change event to the appropriately registered listeners.


fireElementsInserted

protected void fireElementsInserted(int first,
                                    int last,
                                    java.util.List original)
Sends an event to interested listeners that this property has had elements inserted.


fireElementsModified

protected void fireElementsModified(int first,
                                    int last,
                                    java.util.List original)
Sends an event to interested listeners that this property has had elements modified.


fireElementsRemoved

protected void fireElementsRemoved(int first,
                                   int last,
                                   java.util.List original)
Sends an event to interested listeners that this property has had elements removed.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2003 Paul Speed. All Rights Reserved.