public class ListModelMap<K,V> extends AbstractListModel<java.util.Map.Entry<K,V>> implements Sortable<java.util.Map.Entry<K,V>>, java.util.Map<K,V>, java.io.Serializable
This is the ListModel
as a Map
to be used with Listbox
.
Add or remove the contents of this model as a List would cause the associated Listbox to change accordingly.
ListModel
,
ListModelList
,
ListModelMap
,
Serialized FormAbstractListModel.DefaultSelectionControl<E>
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<K,V> |
_map |
_selection
INTERNAL_EVENT
Constructor and Description |
---|
ListModelMap()
Constructor.
|
ListModelMap(int initialCapacity)
Constructor.
|
ListModelMap(int initialCapacity,
float loadFactor)
Constructor.
|
ListModelMap(java.util.Map<? extends K,? extends V> map)
Constructor.
|
ListModelMap(java.util.Map<K,V> map,
boolean live)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addSelection(java.util.Map.Entry<K,V> obj)
Deprecated.
As of release 6.0.0, replaced with
AbstractListModel.addToSelection(E) . |
void |
clear() |
java.lang.Object |
clone() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
boolean |
equals(java.lang.Object o) |
protected void |
fireSelectionEvent(java.util.Map.Entry<K,V> e)
Selectable's implementor use only.
|
V |
get(java.lang.Object key) |
java.util.Map.Entry<K,V> |
getElementAt(int j)
Returns the entry (Map.Entry) at the specified index.
|
java.util.Map<K,V> |
getInnerMap()
Get the inner real Map.
|
int |
getSize()
Returns the length of the list.
|
java.lang.String |
getSortDirection(java.util.Comparator<java.util.Map.Entry<K,V>> cmpr)
Returns the sort direction of this model for the given comparator.
|
int |
hashCode() |
int |
indexOf(java.lang.Object o)
Returns the index of the specified object based on the entry
(Map.Entry).
|
int |
indexOfKey(java.lang.Object o)
Returns the index of the specified object based on the key.
|
boolean |
isEmpty() |
java.util.Set<K> |
keySet() |
V |
put(K key,
V o) |
void |
putAll(java.util.Map<? extends K,? extends V> c) |
protected void |
readSelection(java.io.ObjectInputStream s)
Reads back
AbstractListModel._selection . |
V |
remove(java.lang.Object key) |
void |
removeSelection(java.lang.Object obj)
Deprecated.
As of release 6.0.0, replaced with
AbstractListModel.removeFromSelection(java.lang.Object) . |
int |
size() |
void |
sort(java.util.Comparator<java.util.Map.Entry<K,V>> cmpr,
boolean ascending)
Sorts the data.
|
java.lang.String |
toString() |
java.util.Collection<V> |
values() |
protected void |
writeSelection(java.io.ObjectOutputStream s)
Writes
AbstractListModel._selection . |
addListDataListener, addPagingEventListener, addToSelection, clearSelection, fireEvent, getActivePage, getPageCount, getPageSize, getSelection, getSelectionControl, isMultiple, isSelected, isSelectionEmpty, newEmptySelection, removeAllSelection, removeFromSelection, removeListDataListener, removePagingEventListener, retainAllSelection, setActivePage, setMultiple, setPageSize, setSelection, setSelectionControl
public ListModelMap(java.util.Map<K,V> map, boolean live)
map
- the map to representlive
- whether to have a 'live' ListModel
on top of
the specified map.
If false, the content of the specified map is copied.
If true, this object is a 'facade' of the specified map,
i.e., when you add or remove items from this ListModelMap
,
the inner "live" map would be changed accordingly.
However, it is not a good idea to modify map
if it is passed to this method with live is true,
since Listbox
is not smart enough to handle it.
Instead, modify it thru this object.public ListModelMap()
public ListModelMap(java.util.Map<? extends K,? extends V> map)
Notice that if the data is static or not shared, it is better to
use ListModelMap(map, true)
instead, since
making a copy is slower.
public ListModelMap(int initialCapacity)
initialCapacity
- the initial capacity for this ListModelMap.public ListModelMap(int initialCapacity, float loadFactor)
initialCapacity
- the initial capacity for this ListModelMap.loadFactor
- the loadFactor to increase capacity of this ListModelMap.public int getSize()
ListModel
public java.util.Map.Entry<K,V> getElementAt(int j)
getElementAt
in interface ListModel<java.util.Map.Entry<K,V>>
public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public boolean equals(java.lang.Object o)
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
public int indexOfKey(java.lang.Object o)
o
- the key to look forpublic int indexOf(java.lang.Object o)
o
- the object to look for. It must be an instance of Map.Entry.public void sort(java.util.Comparator<java.util.Map.Entry<K,V>> cmpr, boolean ascending)
public java.lang.String getSortDirection(java.util.Comparator<java.util.Map.Entry<K,V>> cmpr)
Sortable
Default: "natural".
getSortDirection
in interface Sortable<java.util.Map.Entry<K,V>>
public java.lang.Object clone()
clone
in class AbstractListModel<java.util.Map.Entry<K,V>>
protected void fireSelectionEvent(java.util.Map.Entry<K,V> e)
AbstractListModel
Fires a selection event for component to scroll into view. The override
subclass must put the index0 of AbstractListModel.fireEvent(int, int, int)
as
the view index to scroll. By default, the value -1 is assumed which means
no scroll into view.
The method is invoked when both methods are invoked. AbstractListModel.addToSelection(Object)
and AbstractListModel.setSelection(Collection)
.
fireSelectionEvent
in class AbstractListModel<java.util.Map.Entry<K,V>>
e
- selected object.public void addSelection(java.util.Map.Entry<K,V> obj)
AbstractListModel.addToSelection(E)
.public void removeSelection(java.lang.Object obj)
AbstractListModel.removeFromSelection(java.lang.Object)
.protected void writeSelection(java.io.ObjectOutputStream s) throws java.io.IOException
AbstractListModel
AbstractListModel._selection
.
Default: write it directly. Override it if E is not serializable.
writeSelection
in class AbstractListModel<java.util.Map.Entry<K,V>>
java.io.IOException
protected void readSelection(java.io.ObjectInputStream s) throws java.io.IOException, java.lang.ClassNotFoundException
AbstractListModel
AbstractListModel._selection
.
Default: write it directly. Override it if E is not serializable.
readSelection
in class AbstractListModel<java.util.Map.Entry<K,V>>
java.io.IOException
java.lang.ClassNotFoundException
Copyright © 2005-2011 Potix Corporation. All Rights Reserved.