Class BasicEventList<E>
- java.lang.Object
-
- ca.odell.glazedlists.AbstractEventList<E>
-
- ca.odell.glazedlists.BasicEventList<E>
-
- All Implemented Interfaces:
EventList<E>
,java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.List<E>
,java.util.RandomAccess
public final class BasicEventList<E> extends AbstractEventList<E> implements java.io.Serializable, java.util.RandomAccess
AnEventList
that wraps any simpleList
, such asArrayList
orLinkedList
.Unlike most
EventList
s, this class isSerializable
. WhenBasicEventList
is serialized, all of its elements are serialized and all of its listeners that implementSerializable
. Upon deserialization, the new copy uses a differentlock
than its sourceBasicEventList
.EventList Overview Writable: yes Concurrency: thread ready, not thread safe Performance: reads: O(1), writes O(1) amortized Memory: O(N) Unit Tests: N/A Issues: N/A - Author:
- Jesse Wilson
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class ca.odell.glazedlists.AbstractEventList
publisher, readWriteLock, updates
-
-
Constructor Summary
Constructors Constructor Description BasicEventList()
Creates aBasicEventList
.BasicEventList(int initalCapacity)
Creates an emptyBasicEventList
with the giveninitialCapacity
.BasicEventList(int initialCapacity, ListEventPublisher publisher, ReadWriteLock readWriteLock)
Creates aBasicEventList
using the specified initial capacity,ListEventPublisher
andReadWriteLock
.BasicEventList(ListEventPublisher publisher, ReadWriteLock readWriteLock)
BasicEventList(ReadWriteLock readWriteLock)
Creates aBasicEventList
that uses the specifiedReadWriteLock
for concurrent access.BasicEventList(java.util.List<E> list)
Deprecated.As of 2005/03/06, this constructor has been declared unsafe because the source list is exposed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, E element)
Inserts the specified element at the specified position in this list (optional operation).boolean
add(E element)
Appends the specified element to the end of this list (optional operation).boolean
addAll(int index, java.util.Collection<? extends E> collection)
Inserts all of the elements in the specified collection into this list at the specified position (optional operation).boolean
addAll(java.util.Collection<? extends E> collection)
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).void
clear()
Removes all of the elements from this list (optional operation).void
dispose()
This method does nothing.E
get(int index)
Returns the element at the specified position in this list.E
remove(int index)
Removes the element at the specified position in this list (optional operation).boolean
remove(java.lang.Object element)
Removes the first occurrence in this list of the specified element (optional operation).boolean
removeAll(java.util.Collection<?> collection)
Removes from this list all the elements that are contained in the specified collection (optional operation).boolean
retainAll(java.util.Collection<?> collection)
Retains only the elements in this list that are contained in the specified collection (optional operation).E
set(int index, E element)
Replaces the element at the specified position in this list with the specified element (optional operation).int
size()
Returns the number of elements in this list.-
Methods inherited from class ca.odell.glazedlists.AbstractEventList
addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, removeListEventListener, subList, toArray, toArray, toString
-
-
-
-
Constructor Detail
-
BasicEventList
public BasicEventList()
Creates aBasicEventList
.
-
BasicEventList
public BasicEventList(ReadWriteLock readWriteLock)
Creates aBasicEventList
that uses the specifiedReadWriteLock
for concurrent access.
-
BasicEventList
public BasicEventList(int initalCapacity)
Creates an emptyBasicEventList
with the giveninitialCapacity
.
-
BasicEventList
public BasicEventList(ListEventPublisher publisher, ReadWriteLock readWriteLock)
- Since:
- 2006-June-12
-
BasicEventList
public BasicEventList(int initialCapacity, ListEventPublisher publisher, ReadWriteLock readWriteLock)
Creates aBasicEventList
using the specified initial capacity,ListEventPublisher
andReadWriteLock
.- Since:
- 2007-April-19
-
BasicEventList
public BasicEventList(java.util.List<E> list)
Deprecated.As of 2005/03/06, this constructor has been declared unsafe because the source list is exposed. This allows it to be modified without the required events being fired. This constructor has been replaced by the factory methodGlazedLists.eventList(Collection)
.Creates aBasicEventList
that uses the specifiedList
as the underlying implementation.Warning: all editing to the specified
List
must be done through via thisBasicEventList
interface. Otherwise thisBasicEventList
will become out of sync and operations will fail.
-
-
Method Detail
-
add
public void add(int index, E element)
Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).- Specified by:
add
in interfacejava.util.List<E>
- Overrides:
add
in classAbstractEventList<E>
- Parameters:
index
- index at which the specified element is to be inserted.element
- element to be inserted.
-
add
public boolean add(E element)
Appends the specified element to the end of this list (optional operation).Lists that support this operation may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. List classes should clearly specify in their documentation any restrictions on what elements may be added.
- Specified by:
add
in interfacejava.util.Collection<E>
- Specified by:
add
in interfacejava.util.List<E>
- Overrides:
add
in classAbstractEventList<E>
- Parameters:
element
- element to be appended to this list.- Returns:
- true (as per the general contract of the Collection.add method).
-
addAll
public boolean addAll(java.util.Collection<? extends E> collection)
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation). The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)- Specified by:
addAll
in interfacejava.util.Collection<E>
- Specified by:
addAll
in interfacejava.util.List<E>
- Overrides:
addAll
in classAbstractEventList<E>
- Parameters:
collection
- collection whose elements are to be added to this list.- Returns:
- true if this list changed as a result of the call.
- See Also:
AbstractEventList.add(Object)
-
addAll
public boolean addAll(int index, java.util.Collection<? extends E> collection)
Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)- Specified by:
addAll
in interfacejava.util.List<E>
- Overrides:
addAll
in classAbstractEventList<E>
- Parameters:
index
- index at which to insert first element from the specified collection.collection
- elements to be inserted into this list.- Returns:
- true if this list changed as a result of the call.
-
remove
public E remove(int index)
Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.- Specified by:
remove
in interfacejava.util.List<E>
- Overrides:
remove
in classAbstractEventList<E>
- Parameters:
index
- the index of the element to removed.- Returns:
- the element previously at the specified position.
-
remove
public boolean remove(java.lang.Object element)
Removes the first occurrence in this list of the specified element (optional operation). If this list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists).- Specified by:
remove
in interfacejava.util.Collection<E>
- Specified by:
remove
in interfacejava.util.List<E>
- Overrides:
remove
in classAbstractEventList<E>
- Parameters:
element
- element to be removed from this list, if present.- Returns:
- true if this list contained the specified element.
-
clear
public void clear()
Removes all of the elements from this list (optional operation). This list will be empty after this call returns (unless it throws an exception).- Specified by:
clear
in interfacejava.util.Collection<E>
- Specified by:
clear
in interfacejava.util.List<E>
- Overrides:
clear
in classAbstractEventList<E>
-
set
public E set(int index, E element)
Replaces the element at the specified position in this list with the specified element (optional operation).- Specified by:
set
in interfacejava.util.List<E>
- Overrides:
set
in classAbstractEventList<E>
- Parameters:
index
- index of element to replace.element
- element to be stored at the specified position.- Returns:
- the element previously at the specified position.
-
get
public E get(int index)
Returns the element at the specified position in this list.- Specified by:
get
in interfacejava.util.List<E>
- Specified by:
get
in classAbstractEventList<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.- Specified by:
size
in interfacejava.util.Collection<E>
- Specified by:
size
in interfacejava.util.List<E>
- Specified by:
size
in classAbstractEventList<E>
- Returns:
- the number of elements in this list.
-
removeAll
public boolean removeAll(java.util.Collection<?> collection)
Removes from this list all the elements that are contained in the specified collection (optional operation).- Specified by:
removeAll
in interfacejava.util.Collection<E>
- Specified by:
removeAll
in interfacejava.util.List<E>
- Overrides:
removeAll
in classAbstractEventList<E>
- Parameters:
collection
- collection that defines which elements will be removed from this list.- Returns:
- true if this list changed as a result of the call.
- See Also:
AbstractEventList.remove(Object)
,AbstractEventList.contains(Object)
-
retainAll
public boolean retainAll(java.util.Collection<?> collection)
Retains only the elements in this list that are contained in the specified collection (optional operation). In other words, removes from this list all the elements that are not contained in the specified collection.- Specified by:
retainAll
in interfacejava.util.Collection<E>
- Specified by:
retainAll
in interfacejava.util.List<E>
- Overrides:
retainAll
in classAbstractEventList<E>
- Parameters:
collection
- collection that defines which elements this set will retain.- Returns:
- true if this list changed as a result of the call.
- See Also:
AbstractEventList.remove(Object)
,AbstractEventList.contains(Object)
-
-