SPT Core API

com.sptci.echo.list
Class JDOListModel<D extends JDOObject>

java.lang.Object
  extended by nextapp.echo.app.list.AbstractListModel
      extended by com.sptci.echo.list.ListModel<D>
          extended by com.sptci.echo.list.JDOListModel<D>
Type Parameters:
D - The class name of the model object backing this list model.
All Implemented Interfaces:
Serializable, ListModel

public class JDOListModel<D extends JDOObject>
extends ListModel<D>

A list model for holding model objects are are persisted using JDO.

© Copyright 2008 Sans Pareil Technologies, Inc.

Version:
$Id: JDOListModel.java 4641 2009-02-15 01:36:09Z rakesh $
Author:
Rakesh Vidyadharan 2008-04-15
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.sptci.echo.list.ListModel
data, field, nameMap
 
Constructor Summary
protected JDOListModel()
          Default constructor.
  JDOListModel(Collection<D> data, String field)
          Create a new instance of the list model for the specified collection of persistent model objects.
  JDOListModel(D model, String field)
          Create a new instance of the list model using the specified values.
 
Method Summary
 void add(D model)
          Add the specified value object to the list model.
 void addAll(Collection<D> data)
          Add the specified collection of objects to the model.
protected  Object getObjectId(D model)
          Return the persistent object id for the persistent object specified.
protected  Object getObjectId(int index)
          Return the persistent object id for the object at the specified index in ListModel.data.
 int indexById(Object oid)
          Return the index of the specified persistent object id.
protected  void init(D model)
          Initialise the list model using the dummy instance.
 void remove(D model)
          Remove the specified model object from the list model.
 
Methods inherited from class com.sptci.echo.list.ListModel
get, getData, getObject, getValue, getValue, indexByName, setData, size
 
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

JDOListModel

protected JDOListModel()
Default constructor. Cannot be directly instantiated.


JDOListModel

public JDOListModel(D model,
                    String field)
Create a new instance of the list model using the specified values.

Parameters:
model - An empty model object used to automatically initialise the list model through standard queries to the data store. This is necessiated by poor generics implementation in java.
field - The name of the field in the model object used to display in the list component.

JDOListModel

public JDOListModel(Collection<D> data,
                    String field)
Create a new instance of the list model for the specified collection of persistent model objects.

Parameters:
data - The collection of objects to represent.
field - The field in the model object whose value is to be displayed in the list component.
Method Detail

init

protected void init(D model)
Initialise the list model using the dummy instance.

Parameters:
model - The model object used for introspection.

getObjectId

protected Object getObjectId(int index)
Return the persistent object id for the object at the specified index in ListModel.data.

Parameters:
index - The index of the model object.
Returns:
The persistent object id instance.
See Also:
getObjectId( JDOObject )

getObjectId

protected Object getObjectId(D model)
Return the persistent object id for the persistent object specified.

Parameters:
model - The model object whose persistent object id is to be retrieved.
Returns:
The persistent object id instance.

indexById

public int indexById(Object oid)
Return the index of the specified persistent object id.

Parameters:
oid - The persistent object id for the model object.
Returns:
The corresponding model object.

addAll

public void addAll(Collection<D> data)
Add the specified collection of objects to the model. Over-ridden to update idMap.

Overrides:
addAll in class ListModel<D extends JDOObject>
Parameters:
data - The collection of objects to add to ListModel.data.
See Also:
ListModel.addAll(java.util.Collection), getObjectId(int)

add

public void add(D model)
Add the specified value object to the list model. Over-ridden to add the mapping to idMap.

Overrides:
add in class ListModel<D extends JDOObject>
Parameters:
model - The model object that is to be added to this list model.
See Also:
ListModel.add(D)

remove

public void remove(D model)
Remove the specified model object from the list model. Over-ridden to remove the mapping from idMap.

Overrides:
remove in class ListModel<D extends JDOObject>
Parameters:
model - The object to be removed.
See Also:
ListModel.remove(D)

SPT Core API