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

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

public class ObservableListWrapper<T>
extends java.lang.Object
implements java.util.List<T>, ObservableCollection<T>

Version:
$Revision: 1.3 $

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

Field Detail

listeners

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

Constructor Detail

ObservableListWrapper

public ObservableListWrapper(java.util.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 java.lang.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 java.util.List<T>
Parameters:
index -
element -

add

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

addAll

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

addAll

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

clear

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

contains

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

containsAll

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

equals

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

get

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

hashCode

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

indexOf

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

isEmpty

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

iterator

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

lastIndexOf

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

listIterator

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

listIterator

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

remove

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

remove

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

removeAll

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

retainAll

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

set

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

size

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

subList

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

toArray

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

toArray

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

toString

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

main

public static void main(java.lang.String[] args)


Copyright © 2010 KnowledgePlaza. All Rights Reserved.