ca.odell.glazedlists

Class GroupingList<E>

Implemented Interfaces:
EventListener, EventList<E>, List, ListEventListener<E>

public final class GroupingList<E>
extends TransformedList<S,E>

A grouping list contains elements which are themselves Lists. Those Lists are infact elements of the source list which have been grouped together into a List. The logic of how to group the source elements into groups is specified via a Comparator. Elements for which the Comparator returns 0 are guaranteed to be contained within the same group within this GroupingList. This implies that source elements may only participate in a single group within this GroupingList.

Further transformations may be layered on top of this GroupingList to transform the group lists into any other desirable form.

EventList Overview
Writable:yes
Concurrency:thread ready, not thread safe
Performance:reads: O(log N), writes O(log N)
Memory:
Unit Tests:GroupingListTest
Issues: 281
Author:
James Lemieux

Field Summary

Fields inherited from class ca.odell.glazedlists.TransformedList<S,E>

source

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

publisher, readWriteLock, updates

Constructor Summary

GroupingList(EventList source)
Creates a GroupingList that determines groupings via the Comparable interface which all elements of the source are assumed to implement.
GroupingList(EventList source, Comparator comparator)
Creates a GroupingList that determines groups using the specified Comparator.

Method Summary

void
add(int index, List value)
This version of add will distribute all elements within the given value List into groups.
void
dispose()
List
get(int index)
protected int
getSourceIndex(int index)
protected boolean
isWritable()
void
listChanged(ListEvent listChanges)
List
remove(int index)
List
set(int index, List value)
int
size()

Methods inherited from class ca.odell.glazedlists.TransformedList<S,E>

add, addAll, clear, dispose, get, getSourceIndex, isWritable, listChanged, remove, removeAll, retainAll, set, size

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

GroupingList

public GroupingList(EventList source)
Creates a GroupingList that determines groupings via the Comparable interface which all elements of the source are assumed to implement.

GroupingList

public GroupingList(EventList source,
                    Comparator comparator)
Creates a GroupingList that determines groups using the specified Comparator.
Parameters:
source - the EventList containing elements to be grouped
comparator - the Comparator used to determine groupings

Method Details

add

public void add(int index,
                List value)
This version of add will distribute all elements within the given value List into groups. Existing groups will be reused and new groups will be created as needed. As such, the index argument is meaningless.

Warning: This method breaks the contract required by List.add(int, Object).


dispose

public void dispose()
Overrides:
dispose in interface TransformedList<S,E>

get

public List get(int index)
Overrides:
get in interface TransformedList<S,E>

getSourceIndex

protected int getSourceIndex(int index)
Overrides:
getSourceIndex in interface TransformedList<S,E>

isWritable

protected boolean isWritable()
Overrides:
isWritable in interface TransformedList<S,E>

listChanged

public void listChanged(ListEvent listChanges)
Specified by:
listChanged in interface ListEventListener<E>

remove

public List remove(int index)
Overrides:
remove in interface TransformedList<S,E>

set

public List set(int index,
                   List value)

size

public int size()
Overrides:
size in interface TransformedList<S,E>

Glazed Lists, Copyright © 2003-2006 publicobject.com, O'Dell Engineering.
Documentation build by buildd at 2008-01-04 14:38