Class ListModelList<E>
- java.lang.Object
-
- org.zkoss.zul.AbstractListModel<E>
-
- org.zkoss.zul.ListModelList<E>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<E>,java.util.Collection<E>,java.util.List<E>,Pageable,Selectable<E>,Sortable<E>,ListModel<E>,PageableModel
public class ListModelList<E> extends AbstractListModel<E> implements Sortable<E>, java.util.List<E>, java.io.Serializable
This is the
ListModelas aListto be used withListbox. 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:
ListModel,ListModelList,ListModelMap, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.zkoss.zul.AbstractListModel
AbstractListModel.DefaultSelectionControl<E>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<E>_list-
Fields inherited from class org.zkoss.zul.AbstractListModel
_selection
-
Fields inherited from interface org.zkoss.zul.PageableModel
INTERNAL_EVENT
-
-
Constructor Summary
Constructors Constructor Description ListModelList()Constructor.ListModelList(int initialCapacity)Constructor.ListModelList(E[] array)Constructor.ListModelList(java.util.Collection<? extends E> c)Constructor.ListModelList(java.util.List<E> list, boolean live)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, E element)booleanadd(E o)booleanaddAll(int index, java.util.Collection<? extends E> c)booleanaddAll(java.util.Collection<? extends E> c)voidclear()java.lang.Objectclone()booleancontains(java.lang.Object elem)booleancontainsAll(java.util.Collection<?> c)booleanequals(java.lang.Object o)protected voidfireSelectionEvent(E e)Selectable's implementor use only.Eget(int index)EgetElementAt(int j)Returns the value at the specified index.java.util.List<E>getInnerList()Get the inner real List.intgetSize()Returns the length of the list.java.lang.StringgetSortDirection(java.util.Comparator<E> cmpr)Returns the sort direction of this model for the given comparator.inthashCode()intindexOf(java.lang.Object elem)booleanisEmpty()java.util.Iterator<E>iterator()intlastIndexOf(java.lang.Object elem)java.util.ListIterator<E>listIterator()java.util.ListIterator<E>listIterator(int index)booleannotifyChange(E element)Notifies a change of the same element to trigger an event ofListDataEvent.CONTENTS_CHANGED.Eremove(int index)booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)voidremoveRange(int fromIndex, int toIndex)Remove from fromIndex(inclusive) to toIndex(exclusive).booleanretainAll(java.util.Collection<?> c)Eset(int index, E element)intsize()voidsort()Sort the data model by default or assigned comparator.voidsort(java.util.Comparator<E> cmpr, boolean ascending)Sorts the data.java.util.List<E>subList(int fromIndex, int toIndex)java.lang.Object[]toArray()<T> T[]toArray(T[] a)java.lang.StringtoString()-
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, writeSelection
-
-
-
-
Field Detail
-
_list
protected java.util.List<E> _list
-
-
Constructor Detail
-
ListModelList
public ListModelList(java.util.List<E> list, boolean live)
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
public ListModelList(java.util.Collection<? extends E> c)
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
public ListModelList(E[] array)
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 Detail
-
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
public java.util.List<E> getInnerList()
Get the inner real List.
-
getSize
public int getSize()
Description copied from interface:ListModelReturns the length of the list.
-
getElementAt
public E getElementAt(int j)
Description copied from interface:ListModelReturns the value at the specified index.- Specified by:
getElementAtin interfaceListModel<E>
-
add
public boolean add(E o)
-
notifyChange
public boolean notifyChange(E element)
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
public boolean addAll(java.util.Collection<? extends E> c)
-
addAll
public boolean addAll(int index, java.util.Collection<? extends E> c)- Specified by:
addAllin interfacejava.util.List<E>
-
clear
public void clear()
-
contains
public boolean contains(java.lang.Object elem)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
equals
public boolean equals(java.lang.Object o)
-
hashCode
public int hashCode()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
indexOf
public int indexOf(java.lang.Object elem)
- Specified by:
indexOfin interfacejava.util.List<E>
-
isEmpty
public boolean isEmpty()
-
iterator
public java.util.Iterator<E> iterator()
-
lastIndexOf
public int lastIndexOf(java.lang.Object elem)
- Specified by:
lastIndexOfin interfacejava.util.List<E>
-
listIterator
public java.util.ListIterator<E> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<E>
-
listIterator
public java.util.ListIterator<E> listIterator(int index)
- Specified by:
listIteratorin interfacejava.util.List<E>
-
remove
public boolean remove(java.lang.Object o)
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
size
public int size()
-
subList
public java.util.List<E> subList(int fromIndex, int toIndex)
- Specified by:
subListin interfacejava.util.List<E>
-
toArray
public java.lang.Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
sort
public void sort(java.util.Comparator<E> cmpr, boolean ascending)
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.- Specified by:
sortin interfaceSortable<E>- See Also:
Sortable.sort(Comparator, boolean)
-
getSortDirection
public java.lang.String getSortDirection(java.util.Comparator<E> cmpr)
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
public java.lang.Object clone()
- Overrides:
clonein classAbstractListModel<E>
-
fireSelectionEvent
protected void fireSelectionEvent(E e)
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.
-
-