com.ibm.commons.iloader.node.lookups
Class ListLookup

java.lang.Object
  extended by com.ibm.commons.iloader.node.lookups.api.AbstractLookup
      extended by com.ibm.commons.iloader.node.lookups.ListLookup
All Implemented Interfaces:
ILookup

public class ListLookup
extends com.ibm.commons.iloader.node.lookups.api.AbstractLookup

A lookup that can be used in conjunction with a list of objects. getCode(int) and getLabel(int) call helper methods which are given the object from the list and asked to return a code and a label for the object.


Constructor Summary
ListLookup(java.util.List list)
          Creates a new instance of this class.
 
Method Summary
 java.lang.String getCode(int index)
          Return the code or model value for this index.
protected  java.lang.String getCode(java.util.List list, int index, java.lang.Object o)
          Returns a code based on an object at a certain index in the list.
 java.lang.String getLabel(int index)
          Return the label displayed to the user for this index.
protected  java.lang.String getLabel(java.util.List list, int index, java.lang.Object o)
          Returns a label based on an object at a certain index in the list.
 int size()
          Return the number of items in this lookup.
 
Methods inherited from class com.ibm.commons.iloader.node.lookups.api.AbstractLookup
addLookupListener, addNotify, getImage, getLabelFromCode, getLabelFromCodeIgnoreCase, notifyLookupChanged, removeLookupListener, removeNotify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListLookup

public ListLookup(java.util.List list)
Creates a new instance of this class.

Parameters:
list - the list of objects we wish to display in the lookup
Method Detail

size

public int size()
Description copied from interface: ILookup
Return the number of items in this lookup.


getCode

public java.lang.String getCode(int index)
Description copied from interface: ILookup
Return the code or model value for this index.


getCode

protected java.lang.String getCode(java.util.List list,
                                   int index,
                                   java.lang.Object o)
Returns a code based on an object at a certain index in the list. Default implementation is to return o.toString()

Parameters:
list - the list that the lookup is based on
index - the index of the item in the list that is being looked up
o - the object that was returned for the index provided
Returns:
a code corresponding to the parameters provided

getLabel

public java.lang.String getLabel(int index)
Description copied from interface: ILookup
Return the label displayed to the user for this index.


getLabel

protected java.lang.String getLabel(java.util.List list,
                                    int index,
                                    java.lang.Object o)
Returns a label based on an object at a certain index in the list. Default implementation is to return o.toString()

Parameters:
list - the list that the lookup is based on
index - the index of the item in the list that is being looked up
o - the object that was returned for the index provided
Returns:
a label corresponding to the parameters provided