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
AnEventListthat wraps any simpleList, such asArrayListorLinkedList.Unlike most
EventLists, this class isSerializable. WhenBasicEventListis serialized, all of its elements are serialized and all of its listeners that implementSerializable. Upon deserialization, the new copy uses a differentlockthan 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 emptyBasicEventListwith the giveninitialCapacity.BasicEventList(int initialCapacity, ListEventPublisher publisher, ReadWriteLock readWriteLock)Creates aBasicEventListusing the specified initial capacity,ListEventPublisherandReadWriteLock.BasicEventList(ListEventPublisher publisher, ReadWriteLock readWriteLock)BasicEventList(ReadWriteLock readWriteLock)Creates aBasicEventListthat uses the specifiedReadWriteLockfor 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 voidadd(int index, E element)Inserts the specified element at the specified position in this list (optional operation).booleanadd(E element)Appends the specified element to the end of this list (optional operation).booleanaddAll(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).booleanaddAll(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).voidclear()Removes all of the elements from this list (optional operation).voiddispose()This method does nothing.Eget(int index)Returns the element at the specified position in this list.Eremove(int index)Removes the element at the specified position in this list (optional operation).booleanremove(java.lang.Object element)Removes the first occurrence in this list of the specified element (optional operation).booleanremoveAll(java.util.Collection<?> collection)Removes from this list all the elements that are contained in the specified collection (optional operation).booleanretainAll(java.util.Collection<?> collection)Retains only the elements in this list that are contained in the specified collection (optional operation).Eset(int index, E element)Replaces the element at the specified position in this list with the specified element (optional operation).intsize()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 aBasicEventListthat uses the specifiedReadWriteLockfor concurrent access.
-
BasicEventList
public BasicEventList(int initalCapacity)
Creates an emptyBasicEventListwith the giveninitialCapacity.
-
BasicEventList
public BasicEventList(ListEventPublisher publisher, ReadWriteLock readWriteLock)
- Since:
- 2006-June-12
-
BasicEventList
public BasicEventList(int initialCapacity, ListEventPublisher publisher, ReadWriteLock readWriteLock)Creates aBasicEventListusing the specified initial capacity,ListEventPublisherandReadWriteLock.- 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 aBasicEventListthat uses the specifiedListas the underlying implementation.Warning: all editing to the specified
Listmust be done through via thisBasicEventListinterface. Otherwise thisBasicEventListwill 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:
addin interfacejava.util.List<E>- Overrides:
addin 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:
addin interfacejava.util.Collection<E>- Specified by:
addin interfacejava.util.List<E>- Overrides:
addin 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:
addAllin interfacejava.util.Collection<E>- Specified by:
addAllin interfacejava.util.List<E>- Overrides:
addAllin 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:
addAllin interfacejava.util.List<E>- Overrides:
addAllin 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:
removein interfacejava.util.List<E>- Overrides:
removein 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:
removein interfacejava.util.Collection<E>- Specified by:
removein interfacejava.util.List<E>- Overrides:
removein 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:
clearin interfacejava.util.Collection<E>- Specified by:
clearin interfacejava.util.List<E>- Overrides:
clearin 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:
setin interfacejava.util.List<E>- Overrides:
setin 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:
getin interfacejava.util.List<E>- Specified by:
getin 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:
sizein interfacejava.util.Collection<E>- Specified by:
sizein interfacejava.util.List<E>- Specified by:
sizein 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:
removeAllin interfacejava.util.Collection<E>- Specified by:
removeAllin interfacejava.util.List<E>- Overrides:
removeAllin 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:
retainAllin interfacejava.util.Collection<E>- Specified by:
retainAllin interfacejava.util.List<E>- Overrides:
retainAllin 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)
-
-