com.sun.slamd.parameter
Class MultiChoiceParameter

java.lang.Object
  extended bycom.sun.slamd.parameter.Parameter
      extended bycom.sun.slamd.parameter.MultiChoiceParameter
All Implemented Interfaces:
java.lang.Cloneable

public class MultiChoiceParameter
extends Parameter

This class defines a parameter that provides the user with a list of options from which the value should be chosen. Parameters of this type will always be required to have a value.


Field Summary
 
Fields inherited from class com.sun.slamd.parameter.Parameter
description, displayName, isRequired, name, value
 
Constructor Summary
MultiChoiceParameter()
          Creates a new instance of the Parameter to be used when decoding values transported over the network, and should not be used by jobs to create parameters.
MultiChoiceParameter(java.lang.String name, java.lang.String[] choices)
          Creates a new multichoice parameter with the specified name and set of choices.
MultiChoiceParameter(java.lang.String name, java.lang.String[] choices, java.lang.String value)
          Creates a new multichoice parameter with the specified name, value, and set of choices.
MultiChoiceParameter(java.lang.String name, java.lang.String displayName, java.lang.String[] choices, java.lang.String value)
          Creates a new multichoice parameter with the specified name, display name, value, and set of choices.
MultiChoiceParameter(java.lang.String name, java.lang.String displayName, java.lang.String description, java.lang.String[] choices, java.lang.String value)
          Creates a new multichoice parameter with the specified name, display name, description, value, and set of choices.
MultiChoiceParameter(java.lang.String name, java.lang.String displayName, java.lang.String description, java.lang.String[] choices, java.lang.String[] displayValues, java.lang.String value)
          Creates a new multichoice parameter with the specified name, display name, description, value, and set of choices.
 
Method Summary
 void addChoice(java.lang.String choice)
          Adds the specified choice to the list of options.
 void addChoice(java.lang.String choice, java.lang.String displayValue)
          Adds the specified choice to the list of options.
 java.lang.Object clone()
          Creates a clone of this parameter.
 java.lang.String[] getChoices()
          Retrieves the set of acceptable values for this parameter.
 java.lang.String getDisplayValue()
          Retrieves the value of this parameter in a form that can be displayed to the end user.
 java.lang.String[] getDisplayValues()
          Retrieves the set of display values to use for this parameter.
 java.lang.String getHTMLInputForm(java.lang.String prefix)
          Retrieves the text necessary to request the value of this Boolean parameter from an HTML form.
 java.lang.String getInvalidReason(java.lang.Object value)
          Retrieves the reason that the specified value is not valid.
 java.lang.String getStringValue()
          Retrieves the value of this parameter as a Java string.
 java.lang.String getValueString()
          Retrieves a string representation of the value of this parameter.
 void htmlInputFormToValue(java.lang.String[] values)
          Specifies the value of this parameter based on the provided text that would be returned from posting an HTML form.
 void removeChoice(java.lang.String choice)
          Removes the specified choice from the list of options.
 void setChoices(java.lang.String[] choices)
          Specify the set of acceptable values for this parameter.
 void setDisplayValues(java.lang.String[] displayValues)
          Specifies the set of display values to use for this parameter.
 void setValue(java.lang.Object value)
          Specifies the value to use for this parameter.
 void setValueFrom(Parameter parameter)
          Sets the value for this parameter from the information in the provided parameter.
 void setValueFromString(java.lang.String valueString)
          Specifies the value to use for this parameter from the provided String.
 
Methods inherited from class com.sun.slamd.parameter.Parameter
decode, encode, getDescription, getDisplayName, getHTMLDisplayValue, getHTMLPostValue, getInvalidReason, getName, getValue, hasValue, isRequired, isValid, isValid, setDescription, setDisplayName, setName, setRequired, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiChoiceParameter

public MultiChoiceParameter()
Creates a new instance of the Parameter to be used when decoding values transported over the network, and should not be used by jobs to create parameters. If any initialization is needed that will not be covered by calls to the setName, setDisplayName, setDescription, or setValueFromString, then it should be done here.


MultiChoiceParameter

public MultiChoiceParameter(java.lang.String name,
                            java.lang.String[] choices)
Creates a new multichoice parameter with the specified name and set of choices. The display name will be the same as the name, there will be no description, and the value will default to the first item in the list of choices (unless choices is null or empty).

Parameters:
name - The name to use for this parameter.
choices - The set of values that may be used for this parameter.

MultiChoiceParameter

public MultiChoiceParameter(java.lang.String name,
                            java.lang.String[] choices,
                            java.lang.String value)
Creates a new multichoice parameter with the specified name, value, and set of choices. The display name will be the same as the name, and there will be no description.

Parameters:
name - The name to use for this parameter.
choices - The set of values that may be used for this parameter.
value - The value to use for this parameter.

MultiChoiceParameter

public MultiChoiceParameter(java.lang.String name,
                            java.lang.String displayName,
                            java.lang.String[] choices,
                            java.lang.String value)
Creates a new multichoice parameter with the specified name, display name, value, and set of choices. There will be no description.

Parameters:
name - The name to use for this parameter.
displayName - The name to use for this parameter if it to be displayed to the end user.
choices - The set of values that may be used for this parameter.
value - The value to use for this parameter.

MultiChoiceParameter

public MultiChoiceParameter(java.lang.String name,
                            java.lang.String displayName,
                            java.lang.String description,
                            java.lang.String[] choices,
                            java.lang.String value)
Creates a new multichoice parameter with the specified name, display name, description, value, and set of choices.

Parameters:
name - The name to use for this parameter.
displayName - The name to use for this parameter if it to be displayed to the end user.
description - The description to use for this parameter.
choices - The set of values that may be used for this parameter.
value - The value to use for this parameter.

MultiChoiceParameter

public MultiChoiceParameter(java.lang.String name,
                            java.lang.String displayName,
                            java.lang.String description,
                            java.lang.String[] choices,
                            java.lang.String[] displayValues,
                            java.lang.String value)
Creates a new multichoice parameter with the specified name, display name, description, value, and set of choices.

Parameters:
name - The name to use for this parameter.
displayName - The name to use for this parameter if it to be displayed to the end user.
description - The description to use for this parameter.
choices - The set of values that may be used for this parameter.
displayValues - The set of values that should be displayed in the drop-down list box associated with this parameter.
value - The value to use for this parameter.
Method Detail

getChoices

public java.lang.String[] getChoices()
Retrieves the set of acceptable values for this parameter.

Returns:
The set of acceptable values for this parameter.

setChoices

public void setChoices(java.lang.String[] choices)
Specify the set of acceptable values for this parameter. Note that this will overwrite any set of values that may be currently associated with this parameter.

Parameters:
choices - The set of acceptable choices for this parameter.

getDisplayValues

public java.lang.String[] getDisplayValues()
Retrieves the set of display values to use for this parameter. These will be displayed to the end user in the drop-down list box.

Returns:
The set of display values to use for this parameter.

setDisplayValues

public void setDisplayValues(java.lang.String[] displayValues)
Specifies the set of display values to use for this parameter. Note that the elements in this list must always correspond to the order and number of elements in the list of choices.

Parameters:
displayValues - The set of display values to use for this parameter.

addChoice

public void addChoice(java.lang.String choice)
Adds the specified choice to the list of options. It will be added to the end of the current list. If the specified choice already exists in the list of options, then no action will be taken.

Parameters:
choice - The new choice to add to the list of options.

addChoice

public void addChoice(java.lang.String choice,
                      java.lang.String displayValue)
Adds the specified choice to the list of options. It will be added to the end of the current list. If the specified choice already exists in the list of options, then no action will be taken.

Parameters:
choice - The new choice to add to the list of options.
displayValue - The value to display for this choice in the drop-down list box.

removeChoice

public void removeChoice(java.lang.String choice)
Removes the specified choice from the list of options. If the specified choice is not an option, then no action will be taken.

Parameters:
choice - The choice to be removed from the list of options.

getStringValue

public java.lang.String getStringValue()
Retrieves the value of this parameter as a Java string.

Returns:
the value of this parameter as a Java string.

setValue

public void setValue(java.lang.Object value)
              throws InvalidValueException
Specifies the value to use for this parameter.

Overrides:
setValue in class Parameter
Parameters:
value - The value to use for this parameter.
Throws:
InvalidValueException - If the specified value is not in the list of choices.

setValueFrom

public void setValueFrom(Parameter parameter)
Sets the value for this parameter from the information in the provided parameter. Note that the provided parameter must be of the same type as this parameter or no action will be taken.

Specified by:
setValueFrom in class Parameter
Parameters:
parameter - The parameter from which to take the value for this parameter.

getValueString

public java.lang.String getValueString()
Retrieves a string representation of the value of this parameter.

Specified by:
getValueString in class Parameter
Returns:
A string representation of the value of this parameter.

setValueFromString

public void setValueFromString(java.lang.String valueString)
                        throws InvalidValueException
Specifies the value to use for this parameter from the provided String. Note that no validation is performed with this method.

Specified by:
setValueFromString in class Parameter
Parameters:
valueString - The string representation of the value to use for this parameter.
Throws:
InvalidValueException - If the provided value cannot be used to provide a value for this parameter.

getInvalidReason

public java.lang.String getInvalidReason(java.lang.Object value)
Retrieves the reason that the specified value is not valid.

Specified by:
getInvalidReason in class Parameter
Parameters:
value - The value for which to make the determination.
Returns:
The reason that the specified value is not valid, or null if it is valid.

getDisplayValue

public java.lang.String getDisplayValue()
Retrieves the value of this parameter in a form that can be displayed to the end user.

Specified by:
getDisplayValue in class Parameter
Returns:
The value of this parameter in a form that can be displayed to the end user.

getHTMLInputForm

public java.lang.String getHTMLInputForm(java.lang.String prefix)
Retrieves the text necessary to request the value of this Boolean parameter from an HTML form.

Specified by:
getHTMLInputForm in class Parameter
Parameters:
prefix - The prefix that should be placed in front of the parameter name as the name of the form element.
Returns:
The text necessary to request the value of this Boolean parameter from an HTML form.

htmlInputFormToValue

public void htmlInputFormToValue(java.lang.String[] values)
                          throws InvalidValueException
Specifies the value of this parameter based on the provided text that would be returned from posting an HTML form.

Specified by:
htmlInputFormToValue in class Parameter
Parameters:
values - The set of values for this parameter contained in the servlet request.
Throws:
InvalidValueException - If the specified value is not acceptable for this parameter.

clone

public java.lang.Object clone()
Creates a clone of this parameter.

Specified by:
clone in class Parameter
Returns:
A clone of this parameter.