org.zkoss.zul
Class ListModelArray

java.lang.Object
  extended by org.zkoss.zul.AbstractListModel
      extended by org.zkoss.zul.ListModelArray
All Implemented Interfaces:
java.io.Serializable, Selectable, ListModel, ListModelExt
Direct Known Subclasses:
BindingListModelArray

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

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.

Author:
Henri Chen
See Also:
ListModel, ListModelList, ListModelMap, Serialized Form

Field Summary
protected  java.lang.Object[] _array
           
 
Constructor Summary
ListModelArray(int size)
          Constructor.
ListModelArray(java.util.List list)
          Constructor.
ListModelArray(java.lang.Object[] src)
          Constructor.
ListModelArray(java.lang.Object[] array, boolean live)
          Constructor
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.Object get(int index)
          Get the value of this ListModelArray at specified index.
 java.lang.Object getElementAt(int j)
          Returns the value at the specified index.
 java.lang.Object[] getInnerArray()
          Get the inner real Object[].
 int getSize()
          Returns the length of the list.
 int hashCode()
           
 int indexOf(java.lang.Object elm)
          Returns the index of the specified element.
 void set(int index, java.lang.Object value)
          Change content of the Array at specified index.
 void sort(java.util.Comparator cmpr, boolean ascending)
          Sorts the data.
 java.lang.String toString()
           
 
Methods inherited from class org.zkoss.zul.AbstractListModel
addListDataListener, addSelection, clearSelection, fireEvent, getSelection, removeAllSelection, removeListDataListener, removeSelection, retainAllSelection
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_array

protected final java.lang.Object[] _array
Constructor Detail

ListModelArray

public ListModelArray(java.lang.Object[] array,
                      boolean live)
Constructor

Parameters:
array - the array to represent
live - whether to have a 'live' ListModel on 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 this ListModelArray, the inner "live" array would be changed accordingly. However, it is not a good idea to modify array if it is passed to this method with live is true, since Listbox is not smart enough to hanle it. Instead, modify it thru this object.
Since:
2.4.0

ListModelArray

public ListModelArray(java.lang.Object[] src)
Constructor. It mades a copy of the specified array (i.e., not live).

Parameters:
src - the source array used to initialize this ListModelArray.

ListModelArray

public ListModelArray(int size)
Constructor.

Parameters:
size - the array size.

ListModelArray

public ListModelArray(java.util.List list)
Constructor. It mades a copy of the specified list (i.e., not live).

Since:
2.4.1
Method Detail

get

public java.lang.Object get(int index)
Get the value of this ListModelArray at specified index.

Parameters:
index - the array index to be get value.

set

public void set(int index,
                java.lang.Object value)
Change content of the Array at specified index.

Parameters:
index - the array index to be set the new value.

getInnerArray

public java.lang.Object[] getInnerArray()
Get the inner real Object[].

Since:
2.4.0

indexOf

public int indexOf(java.lang.Object elm)
Returns the index of the specified element.


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.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

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


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo