SPT Core API

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

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

public class EnumListModel<E extends Enum>
extends AbstractListModel

A list model based on an enum. Uses the oridinal index in the enum as the basis of the list values.

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

    ...
    // Type is an enum
    final EnumListModel<Type> model = new EnumListModel<Type>( Type.class );
    final SelectField<EnumListModel<Type>> select = new SelectField<EnumListModel<Type>>();
    select.setModel( model );
 

© Copyright 2009 Sans Pareil Technologies, Inc.

Version:
$Id: EnumListModel.java 4722 2009-02-28 14:29:55Z rakesh $
Author:
Rakesh Vidyadharan 2009-2-14
See Also:
Serialized Form

Field Summary
protected  Class<E> enumClass
          The enum class that is used as the backing data model.
 
Constructor Summary
EnumListModel(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.
 int size()
          Return the total number of contants in the enumeration.
 
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
 

Field Detail

enumClass

protected final Class<E extends Enum> enumClass
The enum class that is used as the backing data model.

Constructor Detail

EnumListModel

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

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

get

public E get(int index)
Returns the enumerated contant value at the specified index.

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 enumeration.

Returns:
The number of constants defined in the enumeration.
See Also:
ListModel.size()

SPT Core API