Class ListModelArray<E>
- All Implemented Interfaces:
Serializable,Pageable,Selectable<E>,Sortable<E>,ListModel<E>,PageableModel
This is the ListModel as an Object array to be used with Listbox.
Change the contents of this model as an Object array would cause the associated Listbox to
change accordingly.
The class implements the Selectable interface, updating
the selection status after sorted. (since 6.0.0)
- 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
ConstructorsConstructorDescriptionListModelArray(int size) Constructor.ListModelArray(E[] array) Constructor.ListModelArray(E[] array, boolean live) ConstructorListModelArray(List<? extends E> list) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionclone()booleanprotected voidSelectable's implementor use only.get(int index) Get the value of this ListModelArray at specified index.getElementAt(int j) Returns the value at the specified index.Object[]Get the inner real Object[].intgetSize()Returns the length of the list.getSortDirection(Comparator<E> cmpr) Returns the sort direction of this model for the given comparator.inthashCode()intReturns the index of the specified element.booleannotifyChange(E element) Notifies a change of the same element to trigger an event ofListDataEvent.CONTENTS_CHANGED.voidChange content of the Array at specified index.voidsort()Sort the data model by default or assigned comparator.voidsort(Comparator<E> cmpr, boolean ascending) Sorts the data.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, writeSelection
-
Field Details
-
_array
-
-
Constructor Details
-
ListModelArray
Constructor- Parameters:
array- the array to representlive- whether to have a 'live'ListModelon top of the specified array. If false, the content of the specified array is copied. If true, this object is a 'facade' of the specified array, i.e., when you add or remove items from thisListModelArray, the inner "live" array would be changed accordingly. However, it is not a good idea to modifyarrayif 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
-
ListModelArray
Constructor. It makes a copy of the specified array (i.e., not live).Notice that if the data is static or not shared, it is better to use
ListModelArray(array, true)instead, since making a copy is slower. -
ListModelArray
public ListModelArray(int size) Constructor.- Parameters:
size- the array size.
-
ListModelArray
Constructor. It mades a copy of the specified list (i.e., not live).- Since:
- 2.4.1
-
-
Method Details
-
get
Get the value of this ListModelArray at specified index.- Parameters:
index- the array index to be get value.
-
set
Change content of the Array at specified index.- Parameters:
index- the array index to be set the new value.
-
getInnerArray
Get the inner real Object[].- Since:
- 2.4.0
-
indexOf
Returns the index of the specified element. -
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
-
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>
-
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>
-
equals
-
hashCode
public int hashCode() -
toString
-
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.
-