Class ListModelList<E>
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,List<E>,Pageable,Selectable<E>,Sortable<E>,ListModel<E>,PageableModel
This is the ListModel as a List to be used with Listbox.
Add or remove the contents of this model as a List would cause the associated Listbox to change accordingly.
For more information, please refer to ZK Developer's Reference: List Model
- 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.ListModelList(int initialCapacity) Constructor.ListModelList(E[] array) Constructor.ListModelList(Collection<? extends E> c) Constructor.ListModelList(List<E> list, boolean live) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection<? extends E> c) booleanaddAll(Collection<? extends E> c) voidclear()clone()booleanbooleancontainsAll(Collection<?> c) booleanprotected voidSelectable's implementor use only.get(int index) getElementAt(int j) Returns the value at the specified index.Get the inner real List.intgetSize()Returns the length of the list.getSortDirection(Comparator<E> cmpr) Returns the sort direction of this model for the given comparator.inthashCode()intbooleanisEmpty()iterator()intlastIndexOf(Object elem) listIterator(int index) booleannotifyChange(E element) Notifies a change of the same element to trigger an event ofListDataEvent.CONTENTS_CHANGED.remove(int index) booleanbooleanremoveAll(Collection<?> c) voidremoveRange(int fromIndex, int toIndex) Remove from fromIndex(inclusive) to toIndex(exclusive).booleanretainAll(Collection<?> c) intsize()voidsort()Sort the data model by default or assigned comparator.voidsort(Comparator<E> cmpr, boolean ascending) Sorts the data.subList(int fromIndex, int toIndex) Object[]toArray()<T> T[]toArray(T[] a) toString()Methods inherited from class org.zkoss.zul.AbstractListModel
addListDataListener, addPagingEventListener, addToSelection, clearSelection, fireEvent, getActivePage, getListDataListeners, getPageCount, getPageSize, getSelection, getSelectionControl, getTotalSize, isMultiple, isSelected, isSelectionEmpty, newEmptySelection, readSelection, removeAllSelection, removeFromSelection, removeListDataListener, removePagingEventListener, retainAllSelection, setActivePage, setMultiple, setPageSize, setSelection, setSelectionControl, writeSelectionMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
replaceAll, sort, spliterator
-
Field Details
-
_list
-
-
Constructor Details
-
ListModelList
Constructor- Parameters:
list- the list to representlive- whether to have a 'live'ListModelon top of the specified list. If false, the content of the specified list is copied. If true, this object is a 'facade' of the specified list, i.e., when you add or remove items from this ListModelList, the inner "live" list would be changed accordingly. However, it is not a good idea to modifylistif 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
-
ListModelList
public ListModelList()Constructor. -
ListModelList
Constructor. It makes a copy of the specified collection (i.e., not live).Notice that if the data is static or not shared, it is better to use
ListModelList(c, true)instead, since making a copy is slower. -
ListModelList
Constructor. It makes a copy of the specified array (i.e., not live).- Since:
- 2.4.1
-
ListModelList
public ListModelList(int initialCapacity) Constructor.- Parameters:
initialCapacity- the initial capacity for this ListModelList.
-
-
Method Details
-
removeRange
public void removeRange(int fromIndex, int toIndex) Remove from fromIndex(inclusive) to toIndex(exclusive). If fromIndex equals toIndex, this methods do nothing.- Parameters:
fromIndex- the begin index (inclusive) to be removed.toIndex- the end index (exclusive) to be removed.
-
getInnerList
Get the inner real List. -
getSize
public int getSize()Description copied from interface:ListModelReturns the length of the list. -
getElementAt
Description copied from interface:ListModelReturns the value at the specified index.- Specified by:
getElementAtin interfaceListModel<E>
-
add
-
add
-
notifyChange
Notifies a change of the same element to trigger an event ofListDataEvent.CONTENTS_CHANGED.- Parameters:
element-- Returns:
- true if the element exists
- Since:
- 8.0.0
-
addAll
-
addAll
-
clear
public void clear() -
contains
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>
-
equals
-
get
-
hashCode
public int hashCode() -
toString
-
indexOf
-
isEmpty
public boolean isEmpty() -
iterator
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<E>
-
listIterator
- Specified by:
listIteratorin interfaceList<E>
-
listIterator
- Specified by:
listIteratorin interfaceList<E>
-
remove
-
remove
-
removeAll
-
retainAll
-
set
-
size
public int size() -
subList
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
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<E>
-
clone
- Overrides:
clonein classAbstractListModel<E>
-
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<E>- Parameters:
e- selected object.
-