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>
AnEventList
that shows the current contents of its sourceEventList
.When this
EventList
is frozen, changes to its sourceEventList
will not be reflected. Instead, theFreezableList
will continue to show the state of its sourceEventList
at the time it was frozen.When this
EventList
is thawed, changes to its sourceEventList
will be reflected.Warning: This class is thread ready but not thread safe. See
EventList
for 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 aFreezableList
that can freeze the view of the specified sourceEventList
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
freeze()
Locks thisFreezableList
on the current state of the sourceEventList
.E
get(int index)
Returns the element at the specified position in this list.boolean
isFrozen()
protected boolean
isWritable()
Gets whether the sourceEventList
is writable via this API.void
listChanged(ListEvent<E> listChanges)
When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary.int
size()
Returns the number of elements in this list.void
thaw()
Unlocks thisFreezableList
to 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 aFreezableList
that 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:
get
in interfacejava.util.List<E>
- Overrides:
get
in 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 sourceEventList
is writable via this API.Extending classes must override this method in order to make themselves writable.
- Specified by:
isWritable
in classTransformedList<E,E>
-
isFrozen
public boolean isFrozen()
-
freeze
public void freeze()
Locks thisFreezableList
on the current state of the sourceEventList
. While frozen, changes to the sourceEventList
will not be reflected by this list.Warning: This method is thread ready but not thread safe. See
EventList
for an example of thread safe code.
-
thaw
public void thaw()
Unlocks thisFreezableList
to show the same contents of the sourceEventList
. When thawed, changes to the sourceEventList
will be reflected by this list.Warning: This method is thread ready but not thread safe. See
EventList
for 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:
listChanged
in interfaceListEventListener<E>
- Specified by:
listChanged
in classTransformedList<E,E>
- Parameters:
listChanges
- aListEvent
describing the changes to the list
-
-