LimeWire Collection Component API

org.limewire.collection.glazedlists
Class PluggableList<E>

java.lang.Object
  extended by ca.odell.glazedlists.AbstractEventList<E>
      extended by ca.odell.glazedlists.TransformedList<E,E>
          extended by org.limewire.collection.glazedlists.PluggableList<E>
All Implemented Interfaces:
ca.odell.glazedlists.event.ListEventListener<E>, ca.odell.glazedlists.EventList<E>, Iterable<E>, Collection<E>, EventListener, List<E>

public class PluggableList<E>
extends ca.odell.glazedlists.TransformedList<E,E>

An EventList which delegates all List methods to a given source EventList that may be replaced at runtime using setSource(EventList).

Note that the source EventList must use the same ListEventPublisher and ReadWriteLock, particularly if this EventList is to be used my multiple threads concurrently. To construct an EventList that shares the ListEventPublisher and ReadWriteLock with this PluggableList, use createSourceList().

Warning: This class is thread ready but not thread safe. See EventList for an example of thread safe code.

EventList Overview
Writable:yes
Concurrency:only setSource(EventList)
Performance:delegates to source EventList
Memory:N/A
Unit Tests:N/A
Issues:

Author:
James Lemieux

Field Summary
 
Fields inherited from class ca.odell.glazedlists.TransformedList
source
 
Fields inherited from class ca.odell.glazedlists.AbstractEventList
publisher, readWriteLock, updates
 
Constructor Summary
PluggableList(ca.odell.glazedlists.EventList<E> source)
          Constructs a PluggableList which delegates all List methods to the given source.
PluggableList(ca.odell.glazedlists.event.ListEventPublisher publisher, ca.odell.glazedlists.util.concurrent.ReadWriteLock lock)
          Constructs a PluggableList which delegates all List methods to a given source.
 
Method Summary
 ca.odell.glazedlists.EventList<E> createSourceList()
          Creates a new EventList that shares its ReadWriteLock and ListEventPublisher with this PluggableList.
 void dispose()
           
protected  boolean isWritable()
           
 void listChanged(ca.odell.glazedlists.event.ListEvent<E> listChanges)
           
 void setSource(ca.odell.glazedlists.EventList<E> source)
          Sets the source EventList to which this PluggableList will delegate all calls.
 
Methods inherited from class ca.odell.glazedlists.TransformedList
add, addAll, clear, get, getSourceIndex, remove, removeAll, retainAll, set, size
 
Methods inherited from class ca.odell.glazedlists.AbstractEventList
add, addAll, addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeListEventListener, subList, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PluggableList

public PluggableList(ca.odell.glazedlists.event.ListEventPublisher publisher,
                     ca.odell.glazedlists.util.concurrent.ReadWriteLock lock)
Constructs a PluggableList which delegates all List methods to a given source. The source EventList may be replaced using setSource(EventList) and this PluggableList will produce a ListEvent describing the change in data.


PluggableList

public PluggableList(ca.odell.glazedlists.EventList<E> source)
Constructs a PluggableList which delegates all List methods to the given source. At some future time, the source EventList may be replaced using setSource(EventList) and this PluggableList will produce a ListEvent describing the change in data.

Parameters:
source - the source of data to this PluggableList
Method Detail

createSourceList

public ca.odell.glazedlists.EventList<E> createSourceList()
Creates a new EventList that shares its ReadWriteLock and ListEventPublisher with this PluggableList. This is necessary when this PluggableList will be used by multiple threads.

Note that the created EventList must be explicitly set as the source of this PluggableList using setSource(EventList).

Returns:
a new EventList appropriate for use as the source of this PluggableList

setSource

public void setSource(ca.odell.glazedlists.EventList<E> source)
Sets the source EventList to which this PluggableList will delegate all calls. This method is the entire reason that PluggableList exists. It allows the data source of the remaining pipeline to be altered.

To ensure correct behaviour when this PluggableList is used by multiple threads, the given source must share the same ReadWriteLock and ListEventPublisher with this PluggableList.

Parameters:
source - the new source of data for this PluggableList, and all downstream EventLists

isWritable

protected boolean isWritable()
Overrides:
isWritable in class ca.odell.glazedlists.TransformedList<E,E>

listChanged

public void listChanged(ca.odell.glazedlists.event.ListEvent<E> listChanges)
Specified by:
listChanged in interface ca.odell.glazedlists.event.ListEventListener<E>
Specified by:
listChanged in class ca.odell.glazedlists.TransformedList<E,E>

dispose

public void dispose()
Overrides:
dispose in class ca.odell.glazedlists.TransformedList<E,E>

LimeWire Collection Component API

Copyright © 2009 Lime Wire LLC. All Rights Reserved.