SPT Core API

com.sptci.echo.list
Class FilteredEnumListModel<E extends Enum>

java.lang.Object
  extended by nextapp.echo.app.list.AbstractListModel
      extended by com.sptci.echo.list.EnumListModel<E>
          extended by com.sptci.echo.list.FilteredEnumListModel<E>
Type Parameters:
E - The enum class that backs this list model.
All Implemented Interfaces:
Serializable, ListModel

public class FilteredEnumListModel<E extends Enum>
extends EnumListModel<E>

A list model that allows filtering out specified entries from the backing enum.

  import com.sptci.echo.list.FilteredEnumListModel;
  import com.sptci.echo.list.SelectField;

    ...
    // Type is an enum with an instance Company.
    final FilteredEnumListModel<Type> model = new FilteredEnumListModel<Type>( Type.class );
    model.setFilter( Type.Company );
    final SelectField<FilteredEnumListModel<Type>> select = new SelectField<FilteredEnumListModel<Type>>();
    select.setModel( model );
 

© Copyright 2009 Sans Pareil Technologies, Inc.

Version:
$Id: FilteredEnumListModel.java 4774 2009-04-01 23:00:45Z rakesh $
Author:
Rakesh Vidyadharan 2009-02-28
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.sptci.echo.list.EnumListModel
enumClass
 
Constructor Summary
FilteredEnumListModel(Class<E> cls)
          Create a new instance using the specified enum class.
 
Method Summary
 E get(int index)
          Returns the enumerated contant value at the specified index.
 void setFilter(E filter)
          Set the filter to the single enumerated constant specified.
 void setFilter(Set<E> filter)
          Set the value of the set used to filter out entries from the enum.
 int size()
          Return the total number of contants in the filtered enumeration backing model.
 
Methods inherited from class nextapp.echo.app.list.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getEventListenerList, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilteredEnumListModel

public FilteredEnumListModel(Class<E> cls)
Create a new instance using the specified enum class.

Parameters:
cls - The enum class to use.
Method Detail

setFilter

public void setFilter(Set<E> filter)
Set the value of the set used to filter out entries from the enum.

Parameters:
filter - The set of enum values to filter out.

setFilter

public void setFilter(E filter)
Set the filter to the single enumerated constant specified.

Parameters:
filter - The enum constant to filter out of the model.

get

public E get(int index)
Returns the enumerated contant value at the specified index. Over-ridden to return the value at the specified index in the filtered list backing store.

Specified by:
get in interface ListModel
Overrides:
get in class EnumListModel<E extends Enum>
Parameters:
index - The index for the constant value.
Returns:
The constant value for the specified index.
See Also:
ListModel.get(int)

size

public int size()
Return the total number of contants in the filtered enumeration backing model.

Specified by:
size in interface ListModel
Overrides:
size in class EnumListModel<E extends Enum>
Returns:
The number of constants defined in the enumeration.
See Also:
ListModel.size()

SPT Core API