ca.odell.glazedlists

Class DebugList<E>

Implemented Interfaces:
EventList<E>, List

public class DebugList<E>
extends AbstractEventList<E>

DebugList is meant to be used as a drop-in replacement for 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 java.util.ConcurrentModificationExceptions.

Some of the assertions that are controlled by this DebugList include:

This class is left non-final to allow subclassing but since it is a debugging tool, we make no guarantees about backward compatibility between releases. It is meant to evolve as users discover new assertions to be added.
Author:
James Lemieux

Field Summary

Fields inherited from class ca.odell.glazedlists.AbstractEventList<E>

publisher, readWriteLock, updates

Constructor Summary

DebugList()
Constructs a DebugList which, by default, performs no debugging.

Method Summary

DebugList createNewDebugList()
Returns a new empty DebugList which shares the same ListEventListener and ReadWriteLock with this DebugList.
T[] toArray(T[] array)
boolean
add(E value)
void
add(int index, E value)
boolean
addAll(E> values)
boolean
addAll(int index, E> values)
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()
boolean
contains(Object object)
boolean
containsAll(Collection collection)
void
dispose()
boolean
equals(Object object)
E
get(int index)
ListEventPublisher
getPublisher()
ReadWriteLock
getReadWriteLock()
Set
getSanctionedReaderThreads()
Returns the Set of Threads that are allowed to perform reads on this DebugList.
Set
getSanctionedWriterThreads()
Returns the Set of Threads that are allowed to perform writes on this DebugList.
int
hashCode()
int
indexOf(Object object)
boolean
isEmpty()
boolean
isLockCheckingEnabled()
Returns true if DebugList is currently checking the calling Thread for lock ownership before each read and write operation.
int
lastIndexOf(Object object)
boolean
remove(Object toRemove)
E
remove(int index)
boolean
removeAll(Collection values)
boolean
retainAll(Collection values)
E
set(int index, E value)
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()
Object[]
toArray()
String
toString()

Methods inherited from class ca.odell.glazedlists.AbstractEventList<E>

T[] toArray, add, add, addAll, addAll, addListEventListener, clear, contains, containsAll, equals, get, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeListEventListener, retainAll, set, size, subList, toArray, toString

Constructor Details

DebugList

public DebugList()
Constructs a DebugList which, by default, performs no debugging. It must be customized after construction to turn on the assertions which make sense for the list pipeline.

Method Details

DebugList createNewDebugList

public  DebugList createNewDebugList()
Returns a new empty 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.

T[] toArray

public  T[] toArray(T[] array)
Overrides:
T[] toArray in interface AbstractEventList<E>

add

public boolean add(E value)
Overrides:
add in interface AbstractEventList<E>

add

public void add(int index,
                E value)
Overrides:
add in interface AbstractEventList<E>

addAll

public boolean addAll(E> values)
Overrides:
addAll in interface AbstractEventList<E>

addAll

public boolean addAll(int index,
                      E> values)
Overrides:
addAll in interface AbstractEventList<E>

afterReadOperation

protected void afterReadOperation()
This method is currently a no-op and exists for parity. Subclasses may choose to insert extract assertion logic here.

afterWriteOperation

protected void afterWriteOperation()
This method is currently a no-op and exists for parity. Subclasses may choose to insert extract assertion logic here.

beforeReadOperation

protected void beforeReadOperation()
This generic method is called immediately before any read operation is invoked. All generic read assertions should take place here.

beforeWriteOperation

protected void beforeWriteOperation()
This generic method is called immediately before any write operation is invoked. All generic write assertions should take place here.

clear

public void clear()
Overrides:
clear in interface AbstractEventList<E>

contains

public boolean contains(Object object)
Overrides:
contains in interface AbstractEventList<E>

containsAll

public boolean containsAll(Collection collection)
Overrides:
containsAll in interface AbstractEventList<E>

dispose

public void dispose()
Specified by:
dispose in interface EventList<E>

equals

public boolean equals(Object object)
Overrides:
equals in interface AbstractEventList<E>

get

public E get(int index)
Overrides:
get in interface AbstractEventList<E>

getPublisher

public ListEventPublisher getPublisher()
Specified by:
getPublisher in interface EventList<E>
Overrides:
getPublisher in interface AbstractEventList<E>

getReadWriteLock

public ReadWriteLock getReadWriteLock()
Specified by:
getReadWriteLock in interface EventList<E>
Overrides:
getReadWriteLock in interface AbstractEventList<E>

getSanctionedReaderThreads

public Set getSanctionedReaderThreads()
Returns the 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.

getSanctionedWriterThreads

public Set getSanctionedWriterThreads()
Returns the 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.

hashCode

public int hashCode()
Overrides:
hashCode in interface AbstractEventList<E>

indexOf

public int indexOf(Object object)
Overrides:
indexOf in interface AbstractEventList<E>

isEmpty

public boolean isEmpty()
Overrides:
isEmpty in interface AbstractEventList<E>

isLockCheckingEnabled

public boolean isLockCheckingEnabled()
Returns true if DebugList is currently checking the calling Thread for lock ownership before each read and write operation.

lastIndexOf

public int lastIndexOf(Object object)
Overrides:
lastIndexOf in interface AbstractEventList<E>

remove

public boolean remove(Object toRemove)
Overrides:
remove in interface AbstractEventList<E>

remove

public E remove(int index)
Overrides:
remove in interface AbstractEventList<E>

removeAll

public boolean removeAll(Collection values)
Overrides:
removeAll in interface AbstractEventList<E>

retainAll

public boolean retainAll(Collection values)
Overrides:
retainAll in interface AbstractEventList<E>

set

public E set(int index,
             E value)
Overrides:
set in interface AbstractEventList<E>

setLockCheckingEnabled

public 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.

size

public int size()
Overrides:
size in interface AbstractEventList<E>

toArray

public Object[] toArray()
Overrides:
toArray in interface AbstractEventList<E>

toString

public String toString()
Overrides:
toString in interface AbstractEventList<E>

Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by pbuilder at 2009-07-14 22:05