org.zkoss.zul
Class ListModelSet

java.lang.Object
  extended by org.zkoss.zul.AbstractListModel
      extended by org.zkoss.zul.ListModelSet
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable, java.util.Collection, java.util.Set, Selectable, ListModel, ListModelExt
Direct Known Subclasses:
BindingListModelSet

public class ListModelSet
extends AbstractListModel
implements ListModelExt, java.util.Set, java.io.Serializable

This is the ListModel as a Set to be used with Listbox. Add or remove the contents of this model as a Set would cause the associated Listbox to change accordingly.

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

Field Summary
protected  java.util.Set _set
           
 
Constructor Summary
ListModelSet()
          Constructor.
ListModelSet(java.util.Collection c)
          Constructor.
ListModelSet(int initialCapacity)
          Constructor.
ListModelSet(int initialCapacity, float loadFactor)
          Constructor.
ListModelSet(java.lang.Object[] array)
          Constructor.
ListModelSet(java.util.Set set, boolean live)
          Constructor
 
Method Summary
 boolean add(java.lang.Object o)
          This implementation optimized on the LinkedHashSet(which guaratee the sequence of the added item).
 boolean addAll(java.util.Collection c)
          This implementation optimized on the LinkedHashSet(which guaratee the sequence of the added item).
 void clear()
           
 boolean contains(java.lang.Object elem)
           
 boolean containsAll(java.util.Collection c)
           
 boolean equals(java.lang.Object o)
           
 java.lang.Object getElementAt(int j)
          Returns the value at the specified index.
 java.util.Set getInnerSet()
          Get the inner real set.
 int getSize()
          Returns the length of the list.
 int hashCode()
           
 int indexOf(java.lang.Object o)
          Returns the index of the specified object, or -1 if not found.
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection c)
           
 boolean retainAll(java.util.Collection c)
           
 int size()
           
 void sort(java.util.Comparator cmpr, boolean ascending)
          Sorts the data.
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 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

_set

protected java.util.Set _set
Constructor Detail

ListModelSet

public ListModelSet(java.util.Set set,
                    boolean live)
Constructor

Parameters:
set - the set to represent
live - whether to have a 'live' ListModel on top of the specified set. If false, the content of the specified set is copied. If true, this object is a 'facade' of the specified set, i.e., when you add or remove items from this ListModelSet, the inner "live" set would be changed accordingly. However, it is not a good idea to modify set 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

ListModelSet

public ListModelSet()
Constructor.


ListModelSet

public ListModelSet(java.util.Collection c)
Constructor. It mades a copy of the specified collection (i.e., not live).


ListModelSet

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

Since:
2.4.1

ListModelSet

public ListModelSet(int initialCapacity)
Constructor.

Parameters:
initialCapacity - the initial capacity for this ListModelSet.

ListModelSet

public ListModelSet(int initialCapacity,
                    float loadFactor)
Constructor.

Parameters:
initialCapacity - the initial capacity for this ListModelMap.
loadFactor - the loadFactor to increase capacity of this ListModelMap.
Method Detail

getInnerSet

public java.util.Set getInnerSet()
Get the inner real set.


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

add

public boolean add(java.lang.Object o)
This implementation optimized on the LinkedHashSet(which guaratee the sequence of the added item). Other implementation needs one more linier search.

Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.Set

addAll

public boolean addAll(java.util.Collection c)
This implementation optimized on the LinkedHashSet(which guaratee the sequence of the added item). Other implementation needs one more linier search.

Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.Set

clear

public void clear()
Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.Set

contains

public boolean contains(java.lang.Object elem)
Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.Set

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface java.util.Collection
Specified by:
containsAll in interface java.util.Set

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Collection
Specified by:
equals in interface java.util.Set
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection
Specified by:
hashCode in interface java.util.Set
Overrides:
hashCode in class java.lang.Object

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection
Specified by:
isEmpty in interface java.util.Set

toString

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

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.Set

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.Set

indexOf

public int indexOf(java.lang.Object o)
Returns the index of the specified object, or -1 if not found.


removeAll

public boolean removeAll(java.util.Collection c)
Specified by:
removeAll in interface java.util.Collection
Specified by:
removeAll in interface java.util.Set

retainAll

public boolean retainAll(java.util.Collection c)
Specified by:
retainAll in interface java.util.Collection
Specified by:
retainAll in interface java.util.Set

size

public int size()
Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.Set

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.Set

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.Set

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-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo