|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.collection.util.UnsortedReadableList
net.rim.device.api.collection.util.SortedReadableList
public class SortedReadableList
Maintains a collection of elements in a sorted order.
This collection uses a comparator object (specified at creation time) to sort the items in the list. Every item you add to the list must be recognized as valid by this comparator.
Constructor Summary | ||
---|---|---|
SortedReadableList(Comparator comparator)
Constructs a new SortedReadableList instance. |
||
SortedReadableList(CollectionEventSource sourceCollection,
Comparator comparator)
Constructs a new SortedReadableList from another list. |
Method Summary | ||
---|---|---|
protected void |
doAdd(Object element)
Adds an element to this list without firing an event. |
|
protected boolean |
doUpdate(Object oldElement,
Object newElement)
Update an element in this list without firing an event. |
|
Comparator |
getComparator()
Retreives this collection's comparator. |
|
protected void |
reload(Object collection)
Reload from the given collection and resort. |
|
void |
setComparator(Comparator comparator)
Sets this collection's comparator, and resorts this collection. |
|
void |
sort()
The list is about to be sorted. |
Methods inherited from class net.rim.device.api.collection.util.UnsortedReadableList |
---|
addCollectionListener, doRemove, elementAdded, elementRemoved, elementUpdated, getAt, getAt, getElements, getIndex, getListenerManager, insertAt, loadFrom, removeCollectionListener, reset, setElements, size |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.rim.device.api.collection.SortableCollection |
---|
setComparator |
Methods inherited from interface net.rim.device.api.collection.CollectionListener |
---|
elementAdded, elementRemoved, elementUpdated, reset |
Constructor Detail |
---|
public SortedReadableList(Comparator comparator)
comparator
- Comparator this list will use to sort its elements; must
not be null
. Any item added to this list must be recognized as valid by
this comaprator.public SortedReadableList(CollectionEventSource sourceCollection, Comparator comparator)
sourceCollection
- The CollectionEventSource used to populate this list.comparator
- Comparator that this list will use to sort its elements; must be
non-null. Any item added to this list must be recognized as valid by
this comparator.Method Detail |
---|
public Comparator getComparator()
getComparator
in interface SortableCollection
public void setComparator(Comparator comparator)
This method also sends a reset event to any collection monitoring this collection's events.
comparator
- New comparator to use for sorting this collection.public void sort()
Subclasses can override this method to know when the complete list is getting sorted.
protected void reload(Object collection)
reload
in class UnsortedReadableList
collection
- The source collection from which to reload.protected void doAdd(Object element)
This method adds the new element in the appropriate (sorted) place in the list.
doAdd
in class UnsortedReadableList
element
- Element to add: the list's comparator must recognize the
new element as valid.protected boolean doUpdate(Object oldElement, Object newElement)
This method replaces an existing element with a new element. If the old element does not exist in this collection, this method does nothing.
If the old element does exist, this method replaces it with the new element, and manages the list so that it's sorted after the replacement.
doUpdate
in class UnsortedReadableList
oldElement
- Element to replace.newElement
- New element to replace the old one: the list's
comaprator must recognize the new element as valid.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.