Class FreezableList<E>
- java.lang.Object
-
- ca.odell.glazedlists.AbstractEventList<E>
-
- ca.odell.glazedlists.TransformedList<E,E>
-
- ca.odell.glazedlists.FreezableList<E>
-
- All Implemented Interfaces:
ListEventListener<E>,EventList<E>,java.lang.Iterable<E>,java.util.Collection<E>,java.util.EventListener,java.util.List<E>
public final class FreezableList<E> extends TransformedList<E,E>
AnEventListthat shows the current contents of its sourceEventList.When this
EventListis frozen, changes to its sourceEventListwill not be reflected. Instead, theFreezableListwill continue to show the state of its sourceEventListat the time it was frozen.When this
EventListis thawed, changes to its sourceEventListwill be reflected.Warning: This class is thread ready but not thread safe. See
EventListfor an example of thread safe code.EventList Overview Writable: writable when thawed (default), not writable when frozen Concurrency: thread ready, not thread safe Performance: reads: O(1), writes O(1), freezes O(N) Memory: frozen: 4 bytes per element, thawed: 0 bytes per element Unit Tests: N/A Issues: N/A Issues: - Author:
- Jesse Wilson
-
-
Field Summary
-
Fields inherited from class ca.odell.glazedlists.TransformedList
source
-
Fields inherited from class ca.odell.glazedlists.AbstractEventList
publisher, readWriteLock, updates
-
-
Constructor Summary
Constructors Constructor Description FreezableList(EventList<E> source)Creates aFreezableListthat can freeze the view of the specified sourceEventList.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfreeze()Locks thisFreezableListon the current state of the sourceEventList.Eget(int index)Returns the element at the specified position in this list.booleanisFrozen()protected booleanisWritable()Gets whether the sourceEventListis writable via this API.voidlistChanged(ListEvent<E> listChanges)When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary.intsize()Returns the number of elements in this list.voidthaw()Unlocks thisFreezableListto show the same contents of the sourceEventList.-
Methods inherited from class ca.odell.glazedlists.TransformedList
add, addAll, clear, dispose, getSourceIndex, remove, removeAll, retainAll, set
-
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
-
-
-
-
Constructor Detail
-
FreezableList
public FreezableList(EventList<E> source)
Creates aFreezableListthat can freeze the view of the specified sourceEventList.
-
-
Method Detail
-
get
public E get(int index)
Returns the element at the specified position in this list.- Specified by:
getin interfacejava.util.List<E>- Overrides:
getin classTransformedList<E,E>- Parameters:
index- index of element to return.- Returns:
- the element at the specified position in this list.
-
size
public int size()
Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
-
isWritable
protected boolean isWritable()
Gets whether the sourceEventListis writable via this API.Extending classes must override this method in order to make themselves writable.
- Specified by:
isWritablein classTransformedList<E,E>
-
isFrozen
public boolean isFrozen()
-
freeze
public void freeze()
Locks thisFreezableListon the current state of the sourceEventList. While frozen, changes to the sourceEventListwill not be reflected by this list.Warning: This method is thread ready but not thread safe. See
EventListfor an example of thread safe code.
-
thaw
public void thaw()
Unlocks thisFreezableListto show the same contents of the sourceEventList. When thawed, changes to the sourceEventListwill be reflected by this list.Warning: This method is thread ready but not thread safe. See
EventListfor an example of thread safe code.
-
listChanged
public void listChanged(ListEvent<E> listChanges)
When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary.It is mandatory that the calling thread has obtained the write lock on the source list. This is because the calling thread will have written to the source list to cause this event. This condition guarantees that no writes can occur while the listener is handling this event. It is an error to write to the source list while processing an event.
- Specified by:
listChangedin interfaceListEventListener<E>- Specified by:
listChangedin classTransformedList<E,E>- Parameters:
listChanges- aListEventdescribing the changes to the list
-
-