org.zkoss.zul
Class ListModelMap

java.lang.Object
  extended by org.zkoss.zul.AbstractListModel
      extended by org.zkoss.zul.ListModelMap
All Implemented Interfaces:
java.io.Serializable, java.util.Map, Selectable, ListModel, ListModelExt
Direct Known Subclasses:
BindingListModelMap

public class ListModelMap
extends AbstractListModel
implements ListModelExt, java.util.Map, 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.

Author:
Henri Chen
See Also:
ListModel, ListModelList, ListModelMap, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry
 
Field Summary
protected  java.util.Map _map
           
 
Constructor Summary
ListModelMap()
          Constructor.
ListModelMap(int initialCapacity)
          Constructor.
ListModelMap(int initialCapacity, float loadFactor)
          Constructor.
ListModelMap(java.util.Map map)
          Constructor.
ListModelMap(java.util.Map map, boolean live)
          Constructor.
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set entrySet()
           
 boolean equals(java.lang.Object o)
           
 java.lang.Object get(java.lang.Object key)
           
 java.lang.Object getElementAt(int j)
          Returns the entry (Map.Entry) at the specified index.
 java.util.Map getInnerMap()
          Get the inner real Map.
 int getSize()
          Returns the length of the list.
 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 keySet()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object o)
           
 void putAll(java.util.Map c)
           
 java.lang.Object remove(java.lang.Object key)
           
 int size()
           
 void sort(java.util.Comparator cmpr, boolean ascending)
          Sorts the data.
 java.lang.String toString()
           
 java.util.Collection values()
           
 
Methods inherited from class org.zkoss.zul.AbstractListModel
addListDataListener, addSelection, clearSelection, fireEvent, getSelection, removeAllSelection, removeListDataListener, removeSelection, retainAllSelection
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_map

protected java.util.Map _map
Constructor Detail

ListModelMap

public ListModelMap(java.util.Map map,
                    boolean live)
Constructor.

Parameters:
map - the map to represent
live - 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 hanle it. Instead, modify it thru this object.
Since:
2.4.0

ListModelMap

public ListModelMap()
Constructor.


ListModelMap

public ListModelMap(java.util.Map map)
Constructor. It mades a copy of the specified map (i.e., not live).


ListModelMap

public ListModelMap(int initialCapacity)
Constructor.

Parameters:
initialCapacity - the initial capacity for this ListModelMap.

ListModelMap

public ListModelMap(int initialCapacity,
                    float loadFactor)
Constructor.

Parameters:
initialCapacity - the initial capacity for this ListModelMap.
loadFactor - the loadFactor to increase capacity of this ListModelMap.
Method Detail

getInnerMap

public java.util.Map getInnerMap()
Get the inner real Map.


getSize

public int getSize()
Description copied from interface: ListModel
Returns the length of the list.

Specified by:
getSize in interface ListModel

getElementAt

public java.lang.Object getElementAt(int j)
Returns the entry (Map.Entry) at the specified index.

Specified by:
getElementAt in interface ListModel

clear

public void clear()
Specified by:
clear in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Map
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map
Overrides:
hashCode in class java.lang.Object

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object o)
Specified by:
put in interface java.util.Map

indexOfKey

public int indexOfKey(java.lang.Object o)
Returns the index of the specified object based on the key.

Parameters:
o - the key to look for

indexOf

public int indexOf(java.lang.Object o)
Returns the index of the specified object based on the entry (Map.Entry).

Parameters:
o - the object to look for. It must be an instance of Map.Entry.

putAll

public void putAll(java.util.Map c)
Specified by:
putAll in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map

size

public int size()
Specified by:
size in interface java.util.Map

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map

sort

public void sort(java.util.Comparator cmpr,
                 boolean ascending)
Sorts the data.

Specified by:
sort in interface ListModelExt
Parameters:
cmpr - the comparator.
ascending - whether to sort in the ascending order. It is ignored since this implementation uses cmprt to compare.


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo