public class DebugList<E> extends AbstractEventList<E>
BasicEventList at the root of pipelines of EventLists during
development. It provides methods for turning on various types of assertions
which throw RuntimeExceptions when they are violated. The goal is to
detect and fail fast on error conditions in much the same way Iterators
commonly throw ConcurrentModificationExceptions.
Some of the assertions that are controlled by this DebugList include:
setLockCheckingEnabled(boolean) toggles whether this DebugList
asserts that all read operations are guarded by read locks and all
write operations are guarded by write locks.
getSanctionedReaderThreads() is the Set of Threads which are
allowed to read from the DebugList. If the Set is empty then
ALL Threads are assumed to be sanctioned readers.
getSanctionedWriterThreads() is the Set of Threads which are
allowed to write to the DebugList. If the Set is empty then
ALL Threads are assumed to be sanctioned writers.
publisher, readWriteLock, updates| Constructor and Description |
|---|
DebugList()
Constructs a DebugList which, by default, performs no debugging.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E value)
Appends the specified element to the end of this list (optional
operation).
|
void |
add(int index,
E value)
Inserts the specified element at the specified position in this list
(optional operation).
|
boolean |
addAll(java.util.Collection<? extends E> values)
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).
|
boolean |
addAll(int index,
java.util.Collection<? extends E> values)
Inserts all of the elements in the specified collection into this
list at the specified position (optional operation).
|
protected void |
afterReadOperation()
This method is currently a no-op and exists for parity.
|
protected void |
afterWriteOperation()
This method is currently a no-op and exists for parity.
|
protected void |
beforeReadOperation()
This generic method is called immediately before any read operation is
invoked.
|
protected void |
beforeWriteOperation()
This generic method is called immediately before any write operation is
invoked.
|
void |
clear()
Removes all of the elements from this list (optional operation).
|
boolean |
contains(java.lang.Object object)
Returns true if this list contains the specified element.
|
boolean |
containsAll(java.util.Collection<?> collection)
Returns true if this list contains all of the elements of the
specified collection.
|
<E> DebugList<E> |
createNewDebugList()
Returns a new empty
DebugList which shares the same
ListEventListener and ReadWriteLock with this DebugList. |
void |
dispose()
Disposing an EventList will make it eligible for garbage collection.
|
boolean |
equals(java.lang.Object object)
Compares the specified object with this list for equality.
|
E |
get(int index)
Returns the element at the specified position in this list.
|
ListEventPublisher |
getPublisher()
Get the publisher used to distribute
ListEvents. |
ReadWriteLock |
getReadWriteLock()
Gets the lock required to share this list between multiple threads.
|
java.util.Set<java.lang.Thread> |
getSanctionedReaderThreads()
Returns the
Set of Threads that are allowed to perform reads on
this DebugList. |
java.util.Set<java.lang.Thread> |
getSanctionedWriterThreads()
Returns the
Set of Threads that are allowed to perform writes on
this DebugList. |
int |
hashCode()
Returns the hash code value for this list.
|
int |
indexOf(java.lang.Object object)
Returns the index in this list of the first occurrence of the specified
element, or -1 if this list does not contain this element.
|
boolean |
isEmpty()
Returns true if this list contains no elements.
|
boolean |
isLockCheckingEnabled()
Returns true if DebugList is currently checking the calling
Thread for lock ownership before each read and write operation.
|
int |
lastIndexOf(java.lang.Object object)
Returns the index in this list of the last occurrence of the specified
element, or -1 if this list does not contain this element.
|
E |
remove(int index)
Removes the element at the specified position in this list (optional
operation).
|
boolean |
remove(java.lang.Object toRemove)
Removes the first occurrence in this list of the specified element
(optional operation).
|
boolean |
removeAll(java.util.Collection<?> values)
Removes from this list all the elements that are contained in the
specified collection (optional operation).
|
boolean |
retainAll(java.util.Collection<?> values)
Retains only the elements in this list that are contained in the
specified collection (optional operation).
|
E |
set(int index,
E value)
Replaces the element at the specified position in this list with the
specified element (optional operation).
|
void |
setLockCheckingEnabled(boolean lockCheckingEnabled)
If
lockCheckingEnabled is true this DebugList will
check the calling Thread for lock ownership before each read and write
operation; false indicates this check shouldn't be performed. |
int |
size()
Returns the number of elements in this list.
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this list in proper
sequence.
|
<T> T[] |
toArray(T[] array)
Returns an array containing all of the elements in this list in proper
sequence; the runtime type of the returned array is that of the
specified array.
|
java.lang.String |
toString()
Returns a string representation of this collection.
|
addListEventListener, iterator, listIterator, listIterator, removeListEventListener, subListpublic DebugList()
public boolean isLockCheckingEnabled()
public void setLockCheckingEnabled(boolean lockCheckingEnabled)
lockCheckingEnabled is true this DebugList will
check the calling Thread for lock ownership before each read and write
operation; false indicates this check shouldn't be performed.public java.util.Set<java.lang.Thread> getSanctionedReaderThreads()
Set of Threads that are allowed to perform reads on
this DebugList. If the Set is empty, all Threads are allowed to
read from this DebugList. Users are expected to add and remove Threads
directly on this Set.public java.util.Set<java.lang.Thread> getSanctionedWriterThreads()
Set of Threads that are allowed to perform writes on
this DebugList. If the Set is empty, all Threads are allowed to
write to this DebugList. Users are expected to add and remove Threads
directly on this Set.public <E> DebugList<E> createNewDebugList()
DebugList which shares the same
ListEventListener and ReadWriteLock with this DebugList.
This method is particularly useful when debugging a CompositeList
where some member lists are DebugLists and thus must share an identical
publisher and locks in order to participate in the CompositeList.protected void beforeReadOperation()
protected void afterReadOperation()
protected void beforeWriteOperation()
protected void afterWriteOperation()
public ReadWriteLock getReadWriteLock()
getReadWriteLock in interface EventList<E>getReadWriteLock in class AbstractEventList<E>ReadWriteLock that guarantees thread safe
access to this list.public ListEventPublisher getPublisher()
ListEvents. It's always defined.getPublisher in interface EventList<E>getPublisher in class AbstractEventList<E>public E get(int index)
get in interface java.util.List<E>get in class AbstractEventList<E>index - index of element to return.public int size()
size in interface java.util.Collection<E>size in interface java.util.List<E>size in class AbstractEventList<E>public boolean contains(java.lang.Object object)
contains in interface java.util.Collection<E>contains in interface java.util.List<E>contains in class AbstractEventList<E>object - element whose presence in this list is to be tested.public boolean containsAll(java.util.Collection<?> collection)
containsAll in interface java.util.Collection<E>containsAll in interface java.util.List<E>containsAll in class AbstractEventList<E>collection - collection to be checked for containment in this list.AbstractEventList.contains(Object)public boolean equals(java.lang.Object object)
equals in interface java.util.Collection<E>equals in interface java.util.List<E>equals in class AbstractEventList<E>object - the object to be compared for equality with this list.public int hashCode()
hashCode = 1;
Iterator i = list.iterator();
while (i.hasNext()) {
Object obj = i.next();
hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
}
This ensures that list1.equals(list2) implies that
list1.hashCode()==list2.hashCode() for any two lists,
list1 and list2, as required by the general
contract of Object.hashCode.hashCode in interface java.util.Collection<E>hashCode in interface java.util.List<E>hashCode in class AbstractEventList<E>Object.hashCode(),
Object.equals(Object),
AbstractEventList.equals(Object)public int indexOf(java.lang.Object object)
indexOf in interface java.util.List<E>indexOf in class AbstractEventList<E>object - element to search for.public int lastIndexOf(java.lang.Object object)
lastIndexOf in interface java.util.List<E>lastIndexOf in class AbstractEventList<E>object - element to search for.public boolean isEmpty()
isEmpty in interface java.util.Collection<E>isEmpty in interface java.util.List<E>isEmpty in class AbstractEventList<E>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<E>toArray in interface java.util.List<E>toArray in class AbstractEventList<E>Arrays.asList(T...)public <T> T[] toArray(T[] array)
toArray in interface java.util.Collection<E>toArray in interface java.util.List<E>toArray in class AbstractEventList<E>array - the array into which the elements of this list are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.public java.lang.String toString()
This implementation creates an empty string buffer, appends a left square bracket, and iterates over the collection appending the string representation of each element in turn. After appending each element except the last, the string ", " is appended. Finally a right bracket is appended. A string is obtained from the string buffer, and returned.
toString in class AbstractEventList<E>public boolean add(E value)
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.
add in interface java.util.Collection<E>add in interface java.util.List<E>add in class AbstractEventList<E>value - element to be appended to this list.public boolean remove(java.lang.Object toRemove)
remove in interface java.util.Collection<E>remove in interface java.util.List<E>remove in class AbstractEventList<E>toRemove - element to be removed from this list, if present.public boolean addAll(java.util.Collection<? extends E> values)
addAll in interface java.util.Collection<E>addAll in interface java.util.List<E>addAll in class AbstractEventList<E>values - collection whose elements are to be added to this list.AbstractEventList.add(Object)public boolean addAll(int index,
java.util.Collection<? extends E> values)
addAll in interface java.util.List<E>addAll in class AbstractEventList<E>index - index at which to insert first element from the specified
collection.values - elements to be inserted into this list.public boolean removeAll(java.util.Collection<?> values)
removeAll in interface java.util.Collection<E>removeAll in interface java.util.List<E>removeAll in class AbstractEventList<E>values - collection that defines which elements will be removed from
this list.AbstractEventList.remove(Object),
AbstractEventList.contains(Object)public boolean retainAll(java.util.Collection<?> values)
retainAll in interface java.util.Collection<E>retainAll in interface java.util.List<E>retainAll in class AbstractEventList<E>values - collection that defines which elements this set will retain.AbstractEventList.remove(Object),
AbstractEventList.contains(Object)public void clear()
clear in interface java.util.Collection<E>clear in interface java.util.List<E>clear in class AbstractEventList<E>public E set(int index, E value)
set in interface java.util.List<E>set in class AbstractEventList<E>index - index of element to replace.value - element to be stored at the specified position.public void add(int index,
E value)
add in interface java.util.List<E>add in class AbstractEventList<E>index - index at which the specified element is to be inserted.value - element to be inserted.public E remove(int index)
remove in interface java.util.List<E>remove in class AbstractEventList<E>index - the index of the element to removed.public void dispose()
Warning: It is an error
to call any method on an EventList after it has been disposed.
Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by buildd at 2016-02-14 5:12