Class ListModelMap<K,V>
- All Implemented Interfaces:
Serializable,Map<K,,V> Pageable,Selectable<Map.Entry<K,,V>> Sortable<Map.Entry<K,,V>> ListModel<Map.Entry<K,,V>> PageableModel
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.zkoss.zul.AbstractListModel
AbstractListModel.DefaultSelectionControl<E> -
Field Summary
FieldsFields inherited from class org.zkoss.zul.AbstractListModel
_selectionFields inherited from interface org.zkoss.zul.PageableModel
INTERNAL_EVENT -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.ListModelMap(int initialCapacity) Constructor.ListModelMap(int initialCapacity, float loadFactor) Constructor.ListModelMap(Map<? extends K, ? extends V> map) Constructor.ListModelMap(Map<K, V> map, boolean live) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()clone()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanprotected voidSelectable's implementor use only.getElementAt(int j) Returns the entry (Map.Entry) at the specified index.Get the inner real Map.intgetSize()Returns the length of the list.getSortDirection(Comparator<Map.Entry<K, V>> cmpr) Returns the sort direction of this model for the given comparator.inthashCode()intReturns the index of the specified object based on the entry (Map.Entry).intindexOfKey(Object o) Returns the index of the specified object based on the key.booleanisEmpty()keySet()voidprotected voidReads backAbstractListModel._selection.intsize()voidsort()Sort the data model by default or assigned comparator.voidsort(Comparator<Map.Entry<K, V>> cmpr, boolean ascending) Sorts the data.toString()values()protected voidWritesAbstractListModel._selection.Methods inherited from class org.zkoss.zul.AbstractListModel
addListDataListener, addPagingEventListener, addToSelection, clearSelection, fireEvent, getActivePage, getListDataListeners, getPageCount, getPageSize, getSelection, getSelectionControl, getTotalSize, isMultiple, isSelected, isSelectionEmpty, newEmptySelection, removeAllSelection, removeFromSelection, removeListDataListener, removePagingEventListener, retainAllSelection, setActivePage, setMultiple, setPageSize, setSelection, setSelectionControlMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
_map
-
-
Constructor Details
-
ListModelMap
Constructor.- Parameters:
map- the map to representlive- whether to have a 'live'ListModelon 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 thisListModelMap, the inner "live" map would be changed accordingly. However, it is not a good idea to modifymapif it is passed to this method with live is true, sinceListboxis not smart enough to handle it. Instead, modify it thru this object.- Since:
- 2.4.0
-
ListModelMap
public ListModelMap()Constructor. -
ListModelMap
Constructor. It makes a copy of the specified map (i.e., not live).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. -
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 Details
-
getInnerMap
Get the inner real Map. -
getSize
public int getSize()Description copied from interface:ListModelReturns the length of the list. -
getElementAt
Returns the entry (Map.Entry) at the specified index.- Specified by:
getElementAtin interfaceListModel<K>
-
clear
public void clear() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
entrySet
-
equals
-
toString
-
get
-
hashCode
public int hashCode() -
isEmpty
public boolean isEmpty() -
keySet
-
put
-
indexOfKey
Returns the index of the specified object based on the key.- Parameters:
o- the key to look for
-
indexOf
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
-
remove
-
size
public int size() -
values
-
sort
Sorts the data. -
sort
public void sort()Description copied from interface:SortableSort the data model by default or assigned comparator. Notice that the default implementation does nothing, the model which implements Sortable need to implement this method. -
getSortDirection
Description copied from interface:SortableReturns the sort direction of this model for the given comparator. It must be one of "ascending", "descending" and "natural".Default: "natural".
- Specified by:
getSortDirectionin interfaceSortable<K>
-
clone
- Overrides:
clonein classAbstractListModel<Map.Entry<K,V>>
-
fireSelectionEvent
Description copied from class:AbstractListModelSelectable's implementor use only.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)andAbstractListModel.setSelection(Collection).- Overrides:
fireSelectionEventin classAbstractListModel<Map.Entry<K,V>> - Parameters:
e- selected object.
-
writeSelection
Description copied from class:AbstractListModelWritesAbstractListModel._selection.Default: write it directly. Override it if E is not serializable.
- Overrides:
writeSelectionin classAbstractListModel<Map.Entry<K,V>> - Throws:
IOException
-
readSelection
Description copied from class:AbstractListModelReads backAbstractListModel._selection.Default: write it directly. Override it if E is not serializable.
- Overrides:
readSelectionin classAbstractListModel<Map.Entry<K,V>> - Throws:
IOExceptionClassNotFoundException
-