Package org.zkoss.zul

Class ListModelList<E>

    • 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 represent
        live - whether to have a 'live' ListModel on 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 modify list if it is passed to this method with live is true, since Listbox is 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: ListModel
        Returns the length of the list.
        Specified by:
        getSize in interface ListModel<E>
      • getElementAt

        public E getElementAt​(int j)
        Description copied from interface: ListModel
        Returns the value at the specified index.
        Specified by:
        getElementAt in interface ListModel<E>
      • add

        public void add​(int index,
                        E element)
        Specified by:
        add in interface java.util.List<E>
      • add

        public boolean add​(E o)
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.List<E>
      • notifyChange

        public boolean notifyChange​(E element)
        Notifies a change of the same element to trigger an event of ListDataEvent.CONTENTS_CHANGED.
        Parameters:
        element -
        Returns:
        true if the element exists
        Since:
        8.0.0
      • addAll

        public boolean addAll​(java.util.Collection<? extends E> c)
        Specified by:
        addAll in interface java.util.Collection<E>
        Specified by:
        addAll in interface java.util.List<E>
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends E> c)
        Specified by:
        addAll in interface java.util.List<E>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.List<E>
      • contains

        public boolean contains​(java.lang.Object elem)
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.List<E>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<E>
        Specified by:
        containsAll in interface java.util.List<E>
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<E>
        Specified by:
        equals in interface java.util.List<E>
        Overrides:
        equals in class java.lang.Object
      • get

        public E get​(int index)
        Specified by:
        get in interface java.util.List<E>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<E>
        Specified by:
        hashCode in interface java.util.List<E>
        Overrides:
        hashCode in class java.lang.Object
      • toString

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

        public int indexOf​(java.lang.Object elem)
        Specified by:
        indexOf in interface java.util.List<E>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<E>
        Specified by:
        isEmpty in interface java.util.List<E>
      • iterator

        public java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.List<E>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object elem)
        Specified by:
        lastIndexOf in interface java.util.List<E>
      • listIterator

        public java.util.ListIterator<E> listIterator()
        Specified by:
        listIterator in interface java.util.List<E>
      • listIterator

        public java.util.ListIterator<E> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<E>
      • remove

        public E remove​(int index)
        Specified by:
        remove in interface java.util.List<E>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface java.util.List<E>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<E>
        Specified by:
        removeAll in interface java.util.List<E>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<E>
        Specified by:
        retainAll in interface java.util.List<E>
      • set

        public E set​(int index,
                     E element)
        Specified by:
        set in interface java.util.List<E>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface java.util.List<E>
      • subList

        public java.util.List<E> subList​(int fromIndex,
                                         int toIndex)
        Specified by:
        subList in interface java.util.List<E>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.List<E>
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.List<E>
      • sort

        public void sort​(java.util.Comparator<E> cmpr,
                         boolean ascending)
        Sorts the data.
        Specified by:
        sort in interface Sortable<E>
        Parameters:
        cmpr - the comparator.
        ascending - whether to sort in the ascending order. It is ignored since this implementation uses cmprt to compare.
      • sort

        public void sort()
        Description copied from interface: Sortable
        Sort 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:
        sort in interface Sortable<E>
        See Also:
        Sortable.sort(Comparator, boolean)
      • getSortDirection

        public java.lang.String getSortDirection​(java.util.Comparator<E> cmpr)
        Description copied from interface: Sortable
        Returns the sort direction of this model for the given comparator. It must be one of "ascending", "descending" and "natural".

        Default: "natural".

        Specified by:
        getSortDirection in interface Sortable<E>