nl.knowledgeplaza.util.collection
Class ObservableListWrapper<T>

java.lang.Object
  extended by nl.knowledgeplaza.util.collection.ObservableListWrapper<T>
All Implemented Interfaces:
Iterable<T>, Collection<T>, List<T>, ObservableCollection<T>

public class ObservableListWrapper<T>
extends Object
implements List<T>, ObservableCollection<T>

Version:
$Revision: 1.3 $

Field Summary
protected  ArrayList<CollectionListener<T>> listeners
          the observers of this collection
 
Constructor Summary
ObservableListWrapper(List<T> list)
           
 
Method Summary
 void add(int index, T element)
           
 boolean add(T o)
           
 boolean addAll(Collection c)
           
 boolean addAll(int index, Collection c)
           
 void addCollectionListener(CollectionListener<T> l)
          Adds a CollectionListener to the collection
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 boolean equals(Object obj)
           
protected  void fireCollectionEvent(CollectionEvent<T> e)
          Fires a CollectionEvent to all listeners.
 T get(int index)
           
 Object getObservedCollection()
          To access the collection that is being observed.
 int hashCode()
           
 int indexOf(Object o)
           
 boolean isEmpty()
           
 Iterator iterator()
           
 int lastIndexOf(Object o)
           
 ListIterator listIterator()
           
 ListIterator listIterator(int index)
           
static void main(String[] args)
           
 T remove(int index)
           
 boolean remove(Object o)
           
 boolean removeAll(Collection c)
           
 void removeCollectionListener(CollectionListener<T> l)
          Removes a CollectionListener to the collection
 boolean retainAll(Collection c)
           
 T set(int index, T element)
           
 int size()
           
 List subList(int fromIndex, int toIndex)
           
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

listeners

protected ArrayList<CollectionListener<T>> listeners
the observers of this collection

Constructor Detail

ObservableListWrapper

public ObservableListWrapper(List<T> list)
Method Detail

addCollectionListener

public void addCollectionListener(CollectionListener<T> l)
Description copied from interface: ObservableCollection
Adds a CollectionListener to the collection

Specified by:
addCollectionListener in interface ObservableCollection<T>
Parameters:
l -

removeCollectionListener

public void removeCollectionListener(CollectionListener<T> l)
Description copied from interface: ObservableCollection
Removes a CollectionListener to the collection

Specified by:
removeCollectionListener in interface ObservableCollection<T>
Parameters:
l -

fireCollectionEvent

protected void fireCollectionEvent(CollectionEvent<T> e)
Fires a CollectionEvent to all listeners.

Parameters:
e - the CollectionEvent

getObservedCollection

public Object getObservedCollection()
To access the collection that is being observed.

Specified by:
getObservedCollection in interface ObservableCollection<T>
Returns:
Unfortunately not all collections implement one interface, so the return type depends on the observed collection.

add

public void add(int index,
                T element)
Specified by:
add in interface List<T>
Parameters:
index -
element -

add

public boolean add(T o)
Specified by:
add in interface Collection<T>
Specified by:
add in interface List<T>
Parameters:
o -
Returns:

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List<T>
Parameters:
index -
c -
Returns:

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Collection<T>
Specified by:
addAll in interface List<T>
Parameters:
c -
Returns:

clear

public void clear()
Specified by:
clear in interface Collection<T>
Specified by:
clear in interface List<T>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<T>
Specified by:
contains in interface List<T>
Parameters:
o -
Returns:

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<T>
Specified by:
containsAll in interface List<T>
Parameters:
c -
Returns:

equals

public boolean equals(Object obj)
Specified by:
equals in interface Collection<T>
Specified by:
equals in interface List<T>
Overrides:
equals in class Object

get

public T get(int index)
Specified by:
get in interface List<T>
Parameters:
index -
Returns:

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<T>
Specified by:
hashCode in interface List<T>
Overrides:
hashCode in class Object

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List<T>
Parameters:
o -
Returns:

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<T>
Specified by:
isEmpty in interface List<T>
Returns:

iterator

public Iterator iterator()
Specified by:
iterator in interface Iterable<T>
Specified by:
iterator in interface Collection<T>
Specified by:
iterator in interface List<T>
Returns:

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List<T>
Parameters:
o -
Returns:

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List<T>
Returns:

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List<T>
Parameters:
index -
Returns:

remove

public T remove(int index)
Specified by:
remove in interface List<T>
Parameters:
index -
Returns:

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<T>
Specified by:
remove in interface List<T>
Parameters:
o -
Returns:

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface Collection<T>
Specified by:
removeAll in interface List<T>
Parameters:
c -
Returns:

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface Collection<T>
Specified by:
retainAll in interface List<T>
Parameters:
c -
Returns:

set

public T set(int index,
             T element)
Specified by:
set in interface List<T>
Parameters:
index -
element -
Returns:

size

public int size()
Specified by:
size in interface Collection<T>
Specified by:
size in interface List<T>
Returns:

subList

public List subList(int fromIndex,
                    int toIndex)
Specified by:
subList in interface List<T>
Parameters:
fromIndex -
toIndex -
Returns:

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<T>
Specified by:
toArray in interface List<T>
Returns:

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface Collection<T>
Specified by:
toArray in interface List<T>
Parameters:
a -
Returns:

toString

public String toString()
Overrides:
toString in class Object

main

public static void main(String[] args)


Copyright © 2011 KnowledgePlaza. All Rights Reserved.