com.arsdigita.toolbox.ui
Class IteratorListModel

java.lang.Object
  extended bycom.arsdigita.toolbox.ui.IteratorListModel
All Implemented Interfaces:
ListModel

public class IteratorListModel
extends Object
implements ListModel

Simple adapter to build a Bebop ListModel from a Java Iterator.


Nested Class Summary
static interface IteratorListModel.KeyFunction
          An instance of this interface may be passed to IteratorListModel's constructor for those situations where element.toString() does not produce an appropriate key for a ListModel.
 
Field Summary
 
Fields inherited from interface com.arsdigita.bebop.list.ListModel
versionId
 
Constructor Summary
IteratorListModel(Iterator iterator)
           
IteratorListModel(Iterator iterator, IteratorListModel.KeyFunction keyFunction)
           
 
Method Summary
 Object getElement()
          Get the element for the current list item.
 String getKey()
          Get the key that uniquely identifies the current list item.
 boolean next()
          Move to the next list item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratorListModel

public IteratorListModel(Iterator iterator,
                         IteratorListModel.KeyFunction keyFunction)

IteratorListModel

public IteratorListModel(Iterator iterator)
Method Detail

getElement

public Object getElement()
Description copied from interface: ListModel
Get the element for the current list item. The concrete type of the object returned is specific to each implementation of ListModel and should be documented there.

This method can only be called successfully if the previous cal to ListModel.next() returned true.

Specified by:
getElement in interface ListModel
Returns:
the element for the current list item
See Also:
ListModel.next()

getKey

public String getKey()
Description copied from interface: ListModel
Get the key that uniquely identifies the current list item. The key should be a string that uniquely identifies the list item, at least amongst all items in the list model. If the key needs to be communicated to other components, for example to display details about the list item, all components need to agree how the key identifies the underlying object. For objects stored in a database, this will usually be a suitable string representation for the primary key of the object.

This method can only be called successfully if the previous cal to ListModel.next() returned true.

Specified by:
getKey in interface ListModel
Returns:
identifies the object underlying the list item uniquely
See Also:
ListModel.next()

next

public boolean next()
Description copied from interface: ListModel
Move to the next list item. If there is no next list item, return false. The item's key and element can be accessed with calls to ListModel.getKey() and ListModel.getElement(). Initially, the list model is positioned before the first item, so that next() has to be called once before it is possible to access the item.

Specified by:
next in interface ListModel
Returns:
true if the model is positioned on a valid item after the call returns.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC