|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.AbstractListModel
javax.swing.DefaultComboBoxModel
org.ceryle.util.SetModel
public class SetModel
Extends the DefaultComboBoxModel modified to treat its store
as a Set (ie., checking uniqueness of entries upon adding) insuring that items
in the list are unique. While logically this is a Set and is located in the
Utilities package, functionally it is also a List, and is generally used to build
ComboBoxes and in other GUI applications. This eliminates all of the fussy
checking over values typical of Lists and JComboBoxes, and can be used in most
places where a DefaultListModel is used as well, since it
implements almost everything in List except the two
ListIterator-related and the subList() methods, which
will here throw UnsupportedOperationExceptions.
Prior to May 2007 this class extended DefaultComboBoxModel
by maintaining its own internal Vector, but this had some serious problems. We've
instead dropped support for the more subList feature since we weren't using it
anyway, but there may be a few remaining issues lurking due to that change that
haven't yet surfaced, most likely as regards listeners and event firings.
DefaultComboBoxModel,
DefaultListModel,
Serialized Form| Field Summary | |
|---|---|
static org.ceryle.util.SetModel.EmptySetModel |
EMPTY_SET
The empty set (immutable). |
protected int |
modCount
The number of times this list has been structurally modified. |
| Fields inherited from class javax.swing.AbstractListModel |
|---|
listenerList |
| Constructor Summary | |
|---|---|
SetModel()
Constructs an empty SetModel object. |
|
SetModel(Collection collection)
Constructs a SetModel object initialized with a Collection. |
|
SetModel(Iterator iterator)
Constructs a SetModel object initialized with an Iterator. |
|
SetModel(ListModel items)
Constructs a SetModel object initialized with a ListModel. |
|
SetModel(Object[] items)
Constructs a SetModel object initialized with an array of Objects. |
|
SetModel(Vector vector)
Constructs a SetModel object initialized with a Vector. |
|
| Method Summary | |
|---|---|
void |
add(int index,
Object o)
A synonym for DefaultComboBoxModel.insertElementAt(Object,int). |
boolean |
add(Object o)
Adds the Object o to the end of this SetModel, returning true if the addition was successful. |
boolean |
addAll(Collection collection)
Adds all unique elements of the Collection collection to this SetModel, returning true if any were successfully added. |
boolean |
addAll(int index,
Collection collection)
Adds all unique elements of the Collection collection to this SetModel starting at position index, returning true if all were successfully added. |
boolean |
addAll(Object[] array)
Adds all unique elements of the Object array array to this SetModel, returning true if any were successfully added. |
void |
addElement(Object o)
Implements javax.swing.MutableComboBoxModel. |
void |
addElements(Collection collection)
Adds all unique elements of the Collection collection to this SetModel. |
void |
changedElementAt(int index)
Notifies any listeners that the element at index has changed. |
void |
clear()
Removes all the elements of this SetModel. |
boolean |
contains(Object o)
Returns true if this SetModel contains the specified element. |
boolean |
containsAll(Collection c)
Returns true if this SetModel contains all of the elements of the provided Collection. |
Object |
get(int index)
Implements javax.swing.AbstractList. |
Object |
getFirstElement()
Returns the first Element of the model, null if empty. |
Object |
getLastElement()
Returns the last Element of the model, null if empty. |
Object |
getSelectedItem()
Implements javax.swing.ComboBoxModel. |
int |
indexOf(Object o)
Returns the index of Object o within the List. |
boolean |
isEmpty()
Returns true if the contents of this SetModel are empty. |
Iterator |
iterator()
Returns an iterator over the contents of this SetModel. |
int |
lastIndexOf(Object o)
Returns the last index of Object o within the List. |
ListIterator |
listIterator()
Returns a ListIterator over the list in proper sequence. |
ListIterator |
listIterator(int index)
Returns a ListIterator over the list in proper sequence, starting at the specified position in the List. |
boolean |
moveToBeginning(Object o)
Moves the Object o to the first element position in the model. |
Object |
remove(int index)
Implementation method of java.util.List. |
boolean |
remove(Object o)
Removes the Object from the list. |
boolean |
removeAll(Collection c)
Removes all the elements of this SetModel that are contained within the provided Collection. |
boolean |
retainAll(Collection c)
Retains only the elements in this SetModel that are contained within the provided Collection. |
Object |
set(int index,
Object o)
Replaces the element at index with Object o. |
void |
setSelectedItem(Object o)
Implements javax.swing.ComboBoxModel. |
int |
size()
Implements javax.swing.ListModel. |
void |
sort()
Sorts the values of the Set. |
List |
subList(int fromIndex,
int toIndex)
Returns a view of the portion of this List between fromIndex, inclusive, and toIndex, exclusive. |
Object[] |
toArray()
Returns an array containing all the elements in their proper sequence. |
Object[] |
toArray(Object[] a)
Returns an array containing all the elements in their proper sequence, with the runtime type of the returned array that of the provided array. |
| Methods inherited from class javax.swing.DefaultComboBoxModel |
|---|
getElementAt, getIndexOf, getSize, insertElementAt, removeAllElements, removeElement, removeElementAt |
| Methods inherited from class javax.swing.AbstractListModel |
|---|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Set |
|---|
equals, hashCode |
| Methods inherited from interface java.util.List |
|---|
equals, hashCode |
| Methods inherited from interface javax.swing.MutableComboBoxModel |
|---|
insertElementAt, removeElement, removeElementAt |
| Field Detail |
|---|
public static final org.ceryle.util.SetModel.EmptySetModel EMPTY_SET
protected transient int modCount
AbstractList.modCount| Constructor Detail |
|---|
public SetModel()
public SetModel(Object[] items)
items - an array of Objectspublic SetModel(ListModel items)
items - the ListModel containing the list of itemspublic SetModel(Vector vector)
vector - the Vector objectpublic SetModel(Collection collection)
collection - the Collection objectpublic SetModel(Iterator iterator)
iterator - the Iterator object| Method Detail |
|---|
public void setSelectedItem(Object o)
setSelectedItem in interface ComboBoxModelsetSelectedItem in class DefaultComboBoxModelpublic Object getSelectedItem()
getSelectedItem in interface ComboBoxModelgetSelectedItem in class DefaultComboBoxModelpublic int size()
size in interface Collectionsize in interface Listsize in interface Setpublic void changedElementAt(int index)
public Object getFirstElement()
public Object getLastElement()
public boolean moveToBeginning(Object o)
public Object get(int index)
get in interface Listpublic boolean add(Object o)
add in interface Collectionadd in interface Listadd in interface Setpublic void addElement(Object o)
addElement in interface MutableComboBoxModeladdElement in class DefaultComboBoxModelpublic boolean addAll(Collection collection)
addAll in interface CollectionaddAll in interface ListaddAll in interface Setpublic boolean addAll(Object[] array)
public boolean addAll(int index,
Collection collection)
Current unimplemented.
addAll in interface Listpublic void addElements(Collection collection)
public Object set(int index,
Object o)
set in interface List
public void add(int index,
Object o)
DefaultComboBoxModel.insertElementAt(Object,int).
If the SetModel already contains the Object, nothing happens.
Implements java.util.List.
add in interface Listpublic int indexOf(Object o)
indexOf in interface Listpublic int lastIndexOf(Object o)
lastIndexOf in interface Listpublic ListIterator listIterator()
listIterator in interface ListListIteratorpublic ListIterator listIterator(int index)
listIterator in interface ListListIterator
public List subList(int fromIndex,
int toIndex)
subList in interface Listpublic boolean remove(Object o)
remove in interface Collectionremove in interface Listremove in interface Setpublic Object remove(int index)
remove in interface Listpublic Iterator iterator()
iterator in interface Iterableiterator in interface Collectioniterator in interface Listiterator in interface Setpublic boolean isEmpty()
isEmpty in interface CollectionisEmpty in interface ListisEmpty in interface Setpublic boolean contains(Object o)
This implementation iterates over the elements in the SetModel, checking each element in turn for equality with the specified element.
contains in interface Collectioncontains in interface Listcontains in interface Seto - the Object to be checked for containment in this SetModel.
public boolean containsAll(Collection c)
containsAll in interface CollectioncontainsAll in interface ListcontainsAll in interface Setpublic boolean retainAll(Collection c)
retainAll in interface CollectionretainAll in interface ListretainAll in interface Setpublic boolean removeAll(Collection c)
removeAll in interface CollectionremoveAll in interface ListremoveAll in interface Setpublic void clear()
DefaultComboBoxModel.removeAllElements().
clear in interface Collectionclear in interface Listclear in interface Setpublic void sort()
public Object[] toArray()
toArray in interface CollectiontoArray in interface ListtoArray in interface Setpublic Object[] toArray(Object[] a)
toArray in interface CollectiontoArray in interface ListtoArray in interface Set
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||