com.iplanet.jato.view.html
Class OptionList

java.lang.Object
  |
  +--com.iplanet.jato.view.html.OptionList

public class OptionList
extends java.lang.Object

The OptionList encapsulates a collection of Option items for use by SelectableGroup sub-types.

See the documentation for SelectableGroup for details on the SelectableGroup/OptionsList design pattern.

Version:
JATO/1.2.2 $Id: OptionList.java,v 1.9 2002/03/16 03:26:44 todd Exp $
See Also:
Option, SelectableGroup, RadioButtonGroup, ListBox, ComboBox

Constructor Summary
OptionList()
          Default constructor
OptionList(Option[] options)
           
OptionList(java.lang.String[] labels, java.lang.String[] values)
           
 
Method Summary
 void add(int index, Option option)
           
 void add(int index, java.lang.String label, java.lang.String value)
          Adds an Option with a corresponding label and value
 void add(Option option)
           
 void add(java.lang.String label, java.lang.String value)
          Adds an Option with a corresponding label and value
 void clear()
          Clears the list of all previously stored Options
 Option get(int index)
          Returns the object at the specified index
protected  java.util.List getOptions()
          Returns the List of Options
 java.lang.String getValue(int index)
          Retreives the value of the option at the specified index label
 int getValueIndex(java.lang.String value)
          Searches for the specified value and, if found, returns its index
 java.lang.String getValueLabel(java.lang.String value)
          Searches for the specified value and, if found, returns the associated label
 boolean hasValue(java.lang.String value)
          Determines if the specified value exists in the option list
 void populate(RequestContext requestContext)
          Directs this object to replace its current collection of Options with a new collection.
 void set(int index, Option option)
          Sets the Options object at the specified index
protected  void setOptions(java.util.List value)
          Sets the list of Options.
 void setOptions(Option[] options)
          Sets the list of Options.
 void setOptions(java.lang.String[] labels, java.lang.String[] values)
          Sets the internal list of Options to the reflect the paired arrays of labels and values.
 int size()
          Returns the number of Option objects currently in the list
 java.lang.Object[] toArray()
          Returns the collection of Options as an Option array
 java.lang.Object[] toArray(java.lang.Object[] arrayType)
          Returns the collection of Options as an Option array
 Option[] toOptionArray()
          Returns the collection of Options as an Option array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptionList

public OptionList()
Default constructor

OptionList

public OptionList(Option[] options)

OptionList

public OptionList(java.lang.String[] labels,
                  java.lang.String[] values)
Method Detail

getOptions

protected java.util.List getOptions()
Returns the List of Options
Returns:
the collection of Options in a List

setOptions

protected void setOptions(java.util.List value)
Sets the list of Options. Each item in the list must be a valid Option instance.
Returns:
The collection of Options in a List

setOptions

public void setOptions(Option[] options)
Sets the list of Options. Each item in the list must be a valid Option instance.
Returns:
The collection of Options in a List

setOptions

public void setOptions(java.lang.String[] labels,
                       java.lang.String[] values)
Sets the internal list of Options to the reflect the paired arrays of labels and values.
Parameters:
labels - Array of option labels
valuex - Array of value labels

add

public void add(Option option)

add

public void add(java.lang.String label,
                java.lang.String value)
Adds an Option with a corresponding label and value
Parameters:
label - Label for option
value - Value for option

add

public void add(int index,
                java.lang.String label,
                java.lang.String value)
Adds an Option with a corresponding label and value
Parameters:
label - Label for option
value - Value for option

add

public void add(int index,
                Option option)

clear

public void clear()
Clears the list of all previously stored Options

get

public Option get(int index)
Returns the object at the specified index
Returns:
The specified Option object, or null

set

public void set(int index,
                Option option)
Sets the Options object at the specified index
Parameters:
index - The index at thich to set the Option object
option - The Option object to set

size

public int size()
Returns the number of Option objects currently in the list
Returns:
the number of Option objects currently in the list

toArray

public java.lang.Object[] toArray()
Returns the collection of Options as an Option array
Returns:
the collection of Options as an Option array

toArray

public java.lang.Object[] toArray(java.lang.Object[] arrayType)
Returns the collection of Options as an Option array
Returns:
the collection of Options as an Option array

toOptionArray

public Option[] toOptionArray()
Returns the collection of Options as an Option array
Returns:
the collection of Options as an Option array

populate

public void populate(RequestContext requestContext)
Directs this object to replace its current collection of Options with a new collection. The current implementation does nothing. The useful implementation of this method is left to derived classes.
Parameters:
requestContext - The RequestContext is made available to the OptionList so that it can draw on all of the RequestContext's run time resources (if necessary) in order to fetch a new set of options. Note, implementations of this method are not required to make use of the RequestContext. It is merely provided as a helpful resource.

getValueIndex

public int getValueIndex(java.lang.String value)
Searches for the specified value and, if found, returns its index
Parameters:
value - The value to search for in the option list
Returns:
The index at which the value is located. If the value is not found in the option list, then -1 is returned
See Also:
hasValue(String)

hasValue

public boolean hasValue(java.lang.String value)
Determines if the specified value exists in the option list
Parameters:
value - The value to search for in the option list
Returns:
Returns true if value was found in the option list, false if the value was not found
See Also:
getValueIndex(String)

getValueLabel

public java.lang.String getValueLabel(java.lang.String value)
Searches for the specified value and, if found, returns the associated label
Parameters:
value - The value to search for in the option list
Returns:
The label associated with the value that was passed in. If the value is not found in the option list, then null is returned
See Also:
getValueIndex(String)

getValue

public java.lang.String getValue(int index)
Retreives the value of the option at the specified index label
Parameters:
index - The index of the option
Returns:
The value associated with the option that is found at the index location. If the index exceeds the size of the option list then null is returned.
See Also:
getValueLabel(String), getValueIndex(String)