org.zkoss.zul
Class SimpleListModel

java.lang.Object
  extended by org.zkoss.zul.AbstractListModel
      extended by org.zkoss.zul.SimpleListModel
All Implemented Interfaces:
java.io.Serializable, ListModel, ListModelExt

public class SimpleListModel
extends AbstractListModel
implements ListModelExt, java.io.Serializable

A simple implementation of ListModel. Note: It assumes the content is immutable. If not, use ListModelList or ListModelArray nstead.

Author:
tomyeh
See Also:
ListModelArray, ListModelSet, ListModelList, ListModelMap, Serialized Form

Constructor Summary
SimpleListModel(java.util.List data)
          Constructor.
SimpleListModel(java.lang.Object[] data)
          Constructor.
SimpleListModel(java.lang.Object[] data, boolean live)
          Constructor.
 
Method Summary
 java.lang.Object getElementAt(int j)
          Returns the value at the specified index.
 int getSize()
          Returns the length of the list.
 void sort(java.util.Comparator cmpr, boolean ascending)
          Sorts the data.
 
Methods inherited from class org.zkoss.zul.AbstractListModel
addListDataListener, fireEvent, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleListModel

public SimpleListModel(java.lang.Object[] data,
                       boolean live)
Constructor.

Parameters:
data - the array 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 data once it is passed to this method with live is true, since Listbox is not smart enough to hanle it.
Since:
2.4.1

SimpleListModel

public SimpleListModel(java.lang.Object[] data)
Constructor. It made a copy of the specified array (data).


SimpleListModel

public SimpleListModel(java.util.List data)
Constructor.

Since:
2.4.1
Method Detail

getSize

public int getSize()
Description copied from interface: ListModel
Returns the length of the list.

Specified by:
getSize in interface ListModel

getElementAt

public java.lang.Object getElementAt(int j)
Description copied from interface: ListModel
Returns the value at the specified index.

Specified by:
getElementAt in interface ListModel

sort

public void sort(java.util.Comparator cmpr,
                 boolean ascending)
Sorts the data.

Specified by:
sort in interface ListModelExt
Parameters:
cmpr - the comparator.
ascending - whether to sort in the ascending order. It is ignored since this implementation uses cmprt to compare.


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.