|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pivot.collections.MapList<K,V>
public class MapList<K,V>
Decorates a Map
to look like a List
of key/value pairs. This
facilitates the use of a Map as table data in a
TableView
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.pivot.collections.List |
---|
List.ItemIterator<T>, List.ListListenerList<T> |
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Sequence |
---|
Sequence.Tree<T> |
Constructor Summary | |
---|---|
MapList()
Creates a new map list with no source map. |
|
MapList(Map<K,V> source)
Creates a new map list that decorates the specified source map. |
Method Summary | |
---|---|
int |
add(Dictionary.Pair<K,V> pair)
Adds an item to the list. |
void |
clear()
Removes all elements from the collection. |
Dictionary.Pair<K,V> |
get(int index)
Retrieves the item at the given index. |
Comparator<Dictionary.Pair<K,V>> |
getComparator()
Returns the collection's sort order. |
int |
getLength()
Returns the length of the list. |
ListenerList<ListListener<Dictionary.Pair<K,V>>> |
getListListeners()
Returns the list listener list. |
ListenerList<MapListListener<K,V>> |
getMapListListeners()
Gets the map list listeners. |
Map<K,V> |
getSource()
Gets the source map. |
int |
indexOf(Dictionary.Pair<K,V> pair)
Returns the index of an item in the sequence. |
void |
insert(Dictionary.Pair<K,V> pair,
int index)
Inserts an item into the list. |
boolean |
isEmpty()
Tests the emptiness of the collection. |
Iterator<Dictionary.Pair<K,V>> |
iterator()
|
int |
remove(Dictionary.Pair<K,V> pair)
Removes the first occurrence of the given item from the sequence. |
Sequence<Dictionary.Pair<K,V>> |
remove(int index,
int count)
Removes one or more items from the sequence. |
void |
setComparator(Comparator<Dictionary.Pair<K,V>> comparator)
Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order. |
void |
setSource(Map<K,V> source)
Sets the source map. |
Dictionary.Pair<K,V> |
update(int index,
Dictionary.Pair<K,V> pair)
Updates the item at the given index. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MapList()
public MapList(Map<K,V> source)
source
- The map to present as a listMethod Detail |
---|
public Map<K,V> getSource()
public void setSource(Map<K,V> source)
source
- The source map, or null to clear the sourcepublic int add(Dictionary.Pair<K,V> pair)
add
in interface List<Dictionary.Pair<K,V>>
add
in interface Sequence<Dictionary.Pair<K,V>>
pair
- The item to be added to the sequence.
ListListener.itemInserted(List, int)
public void insert(Dictionary.Pair<K,V> pair, int index)
insert
in interface List<Dictionary.Pair<K,V>>
insert
in interface Sequence<Dictionary.Pair<K,V>>
pair
- The item to be added to the list.index
- The index at which the item should be inserted. Must be a value between
0 and getLength().ListListener.itemInserted(List, int)
public Dictionary.Pair<K,V> update(int index, Dictionary.Pair<K,V> pair)
update
in interface List<Dictionary.Pair<K,V>>
update
in interface Sequence<Dictionary.Pair<K,V>>
index
- The index of the item to update.pair
- The item that will replace any existing value at the given index.
ListListener.itemUpdated(List, int, Object)
public int remove(Dictionary.Pair<K,V> pair)
remove
in interface Sequence<Dictionary.Pair<K,V>>
pair
- The item to remove.
Sequence.remove(int, int)
public Sequence<Dictionary.Pair<K,V>> remove(int index, int count)
remove
in interface List<Dictionary.Pair<K,V>>
remove
in interface Sequence<Dictionary.Pair<K,V>>
index
- The starting index to remove.count
- The number of items to remove, beginning with index.
ListListener.itemsRemoved(List, int, Sequence)
public Dictionary.Pair<K,V> get(int index)
get
in interface Sequence<Dictionary.Pair<K,V>>
index
- The index of the item to retrieve.public int indexOf(Dictionary.Pair<K,V> pair)
indexOf
in interface Sequence<Dictionary.Pair<K,V>>
pair
- The item to locate.
public void clear()
clear
in interface Collection<Dictionary.Pair<K,V>>
clear
in interface List<Dictionary.Pair<K,V>>
ListListener.itemsRemoved(List, int, Sequence)
public boolean isEmpty()
isEmpty
in interface Collection<Dictionary.Pair<K,V>>
public int getLength()
getLength
in interface List<Dictionary.Pair<K,V>>
getLength
in interface Sequence<Dictionary.Pair<K,V>>
public Comparator<Dictionary.Pair<K,V>> getComparator()
getComparator
in interface Collection<Dictionary.Pair<K,V>>
Collection.setComparator(Comparator)
public void setComparator(Comparator<Dictionary.Pair<K,V>> comparator)
Calling this method more than once with the same comparator will re-sort the collection.
setComparator
in interface Collection<Dictionary.Pair<K,V>>
setComparator
in interface List<Dictionary.Pair<K,V>>
comparator
- The comparator used to order elements in the collection, or null if the
collection is unsorted.ListListener.comparatorChanged(List, Comparator)
public Iterator<Dictionary.Pair<K,V>> iterator()
iterator
in interface Iterable<Dictionary.Pair<K,V>>
public ListenerList<ListListener<Dictionary.Pair<K,V>>> getListListeners()
getListListeners
in interface List<Dictionary.Pair<K,V>>
public ListenerList<MapListListener<K,V>> getMapListListeners()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |