com.sun.slamd.parameter
Class MultiValuedParameter

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

public class MultiValuedParameter
extends Parameter

This class defines a parameter that may have multiple concurrent values. The HTML input form will be a list box that allows multiple values to be selected at the same time. The internal representation of the value of this parameter will be an integer, with the individual values each associated with an increasing power of 2 (the first item will be associated with a value of 1, the second with a value of 2, the third with 4, the fourth with 8, etc.). Anything that uses this parameter type must maintain that mapping externally because the value strings are not included in the encoded version of this parameter that is sent between the client and server.


Field Summary
 
Fields inherited from class com.sun.slamd.parameter.Parameter
description, displayName, isRequired, name, value
 
Constructor Summary
MultiValuedParameter()
          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.
MultiValuedParameter(java.lang.String name, java.lang.String[] valueStrings)
          Creates a new multivalued parameter with the specified name and set of potential values.
MultiValuedParameter(java.lang.String name, java.lang.String[] valueStrings, boolean isRequired)
          Creates a new multivalued parameter with the specified name, set of potential values, and required/optional indicator.
MultiValuedParameter(java.lang.String name, java.lang.String displayName, java.lang.String[] valueStrings)
          Creates a new multivalued parameter with the specified name, display name, and set of potential values.
MultiValuedParameter(java.lang.String name, java.lang.String displayName, java.lang.String[] valueStrings, boolean isRequired)
          Creates a new multivalued parameter with the specified name, display name, set of potential values, and required/optional indicator.
MultiValuedParameter(java.lang.String name, java.lang.String displayName, java.lang.String description, java.lang.String[] valueStrings)
          Creates a new multivalued parameter with the specified name, display name, description, and set of potential values.
MultiValuedParameter(java.lang.String name, java.lang.String displayName, java.lang.String description, java.lang.String[] valueStrings, boolean isRequired)
          Creates a new multivalued parameter with the specified name, display name, description, set of potential values, and required/optional indicator.
MultiValuedParameter(java.lang.String name, java.lang.String displayName, java.lang.String description, java.lang.String[] valueStrings, int intValue)
          Creates a new multivalued parameter with the specified name, display name, description, set of potential values, and set of selected values.
MultiValuedParameter(java.lang.String name, java.lang.String displayName, java.lang.String description, java.lang.String[] valueStrings, int intValue, boolean isRequired)
          Creates a new multivalued parameter with the specified name, display name, description, set of potential values, set of selected values, and required/optional indicator.
 
Method Summary
 java.lang.Object clone()
          Creates a new multivalued parameter that is a duplicate of this parameter.
 java.lang.String getDisplayValue()
          Retrieves a string representation of the value of this parameter.
 java.lang.String getHTMLDisplayValue()
          Retrieves the value of this parameter in a form that can be displayed in an HTML document.
 java.lang.String getHTMLInputForm(java.lang.String prefix)
          Retrieves an HTML string that can be used to specify the value(s) for this parameter.
 int getIntValue()
          Retrieves the integer value that specifies which of the potential values are actually selected.
 java.lang.String getInvalidReason(java.lang.Object value)
          Retrieves a string that indicates why the provided value is invalid.
 int getMaxValue()
          Retrieves the maximum allowed value for this parameter based on the number of items in the set of potential values.
 java.lang.String getValueString()
          Retrieves a string representation of the value of this parameter.
 java.lang.String[] getValueStrings()
          Retrieves the set of value strings that may be used with this parameter (i.e., the potential values).
 int getVisibleRows()
          Retrieves the maximum number of rows that will be visible when displaying the HTML input form.
 boolean hasValue()
          Indicates whether this parameter has one or more values.
 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.
 int indexToIntValue(int valueIndex)
          Provides a mapping between the position of an element in the set of value strings to the numeric value associated with the element in that position.
 boolean isSelected(int optionValue)
          Indicates whether the option associated with the specified value is selected.
 void setValue(int intValue)
          Specifies the integer value 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.
 void setVisibleRows(int visibleRows)
          Specifies the maximum number of rows that will be visible when displaying the HTML input form.
 
Methods inherited from class com.sun.slamd.parameter.Parameter
decode, encode, getDescription, getDisplayName, getHTMLPostValue, getInvalidReason, getName, getValue, 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

MultiValuedParameter

public MultiValuedParameter()
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.


MultiValuedParameter

public MultiValuedParameter(java.lang.String name,
                            java.lang.String[] valueStrings)
Creates a new multivalued parameter with the specified name and set of potential values. The display name will be the same as the name, it will not have a description, no values will be selected, and it will not be required.

Parameters:
name - The name to use for this parameter.
valueStrings - The text associated with the potential values of this parameter.

MultiValuedParameter

public MultiValuedParameter(java.lang.String name,
                            java.lang.String[] valueStrings,
                            boolean isRequired)
Creates a new multivalued parameter with the specified name, set of potential values, and required/optional indicator. The display name will be the same as the name, it will not have a description, and there will not be any values selected.

Parameters:
name - The name to use for this parameter.
valueStrings - The text associated with the potential values of this parameter.
isRequired - Indicates whether this parameter is required to have a value.

MultiValuedParameter

public MultiValuedParameter(java.lang.String name,
                            java.lang.String displayName,
                            java.lang.String[] valueStrings)
Creates a new multivalued parameter with the specified name, display name, and set of potential values. It will not have a description, there will not be any values selected, and it will not be required.

Parameters:
name - The name to use for this parameter.
displayName - The display name to use for this parameter.
valueStrings - The text associated with the potential values of this parameter.

MultiValuedParameter

public MultiValuedParameter(java.lang.String name,
                            java.lang.String displayName,
                            java.lang.String[] valueStrings,
                            boolean isRequired)
Creates a new multivalued parameter with the specified name, display name, set of potential values, and required/optional indicator. It will not have a description and there will not be any values selected.

Parameters:
name - The name to use for this parameter.
displayName - The display name to use for this parameter.
valueStrings - The text associated with the potential values of this parameter.
isRequired - Indicates whether this parameter is required to have a value.

MultiValuedParameter

public MultiValuedParameter(java.lang.String name,
                            java.lang.String displayName,
                            java.lang.String description,
                            java.lang.String[] valueStrings)
Creates a new multivalued parameter with the specified name, display name, description, and set of potential values. There will not be any values selected and it will not be required.

Parameters:
name - The name to use for this parameter.
displayName - The display name to use for this parameter.
description - The description to use for this parameter.
valueStrings - The text associated with the potential values of this parameter.

MultiValuedParameter

public MultiValuedParameter(java.lang.String name,
                            java.lang.String displayName,
                            java.lang.String description,
                            java.lang.String[] valueStrings,
                            boolean isRequired)
Creates a new multivalued parameter with the specified name, display name, description, set of potential values, and required/optional indicator. There will not be any values selected.

Parameters:
name - The name to use for this parameter.
displayName - The display name to use for this parameter.
description - The description to use for this parameter.
valueStrings - The text associated with the potential values of this parameter.
isRequired - Indicates whether this parameter is required to have a value.

MultiValuedParameter

public MultiValuedParameter(java.lang.String name,
                            java.lang.String displayName,
                            java.lang.String description,
                            java.lang.String[] valueStrings,
                            int intValue)
Creates a new multivalued parameter with the specified name, display name, description, set of potential values, and set of selected values. It will not be required.

Parameters:
name - The name to use for this parameter.
displayName - The display name to use for this parameter.
description - The description to use for this parameter.
valueStrings - The text associated with the potential values of this parameter.
intValue - The numeric representation that indicates which of the values are selected.

MultiValuedParameter

public MultiValuedParameter(java.lang.String name,
                            java.lang.String displayName,
                            java.lang.String description,
                            java.lang.String[] valueStrings,
                            int intValue,
                            boolean isRequired)
Creates a new multivalued parameter with the specified name, display name, description, set of potential values, set of selected values, and required/optional indicator.

Parameters:
name - The name to use for this parameter.
displayName - The display name to use for this parameter.
description - The description to use for this parameter.
valueStrings - The text associated with the potential values of this parameter.
intValue - The numeric representation that indicates which of the values are selected.
isRequired - Indicates whether this parameter is required to have a value.
Method Detail

getValueStrings

public java.lang.String[] getValueStrings()
Retrieves the set of value strings that may be used with this parameter (i.e., the potential values).

Returns:
The set of value strings that may be used with this parameter.

getIntValue

public int getIntValue()
Retrieves the integer value that specifies which of the potential values are actually selected.

Returns:
The integer value that specifies which of the potential values are actually selected.

isSelected

public boolean isSelected(int optionValue)
Indicates whether the option associated with the specified value is selected.

Parameters:
optionValue - The numeric value of the option for which to make the determination.
Returns:
true if the specified value is selected, or false if it is not.

setValue

public void setValue(int intValue)
              throws InvalidValueException
Specifies the integer value to use for this parameter.

Parameters:
intValue - The integer value to use for this parameter.
Throws:
InvalidValueException - If there is a problem with the value information provided.

setValue

public void setValue(java.lang.Object value)
              throws InvalidValueException
Specifies the value to use for this parameter. The value should be a Java Integer.

Overrides:
setValue in class Parameter
Parameters:
value - The value to use for this parameter.
Throws:
InvalidValueException - If the value provided is not valid.

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.

getVisibleRows

public int getVisibleRows()
Retrieves the maximum number of rows that will be visible when displaying the HTML input form.

Returns:
The maximum number of rows that will be visible when displaying the HTML input form.

setVisibleRows

public void setVisibleRows(int visibleRows)
Specifies the maximum number of rows that will be visible when displaying the HTML input form.

Parameters:
visibleRows - The maximum number of rows that will be visible when displaying the HTML input form.

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 a string that indicates why the provided value is invalid.

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

hasValue

public boolean hasValue()
Indicates whether this parameter has one or more values.

Overrides:
hasValue in class Parameter
Returns:
true if this parameter has one or more values, or false if not.

getDisplayValue

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

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

getHTMLDisplayValue

public java.lang.String getHTMLDisplayValue()
Retrieves the value of this parameter in a form that can be displayed in an HTML document.

Overrides:
getHTMLDisplayValue in class Parameter
Returns:
The value of this parameter in a form that can be displayed in an HTML document.

getHTMLInputForm

public java.lang.String getHTMLInputForm(java.lang.String prefix)
Retrieves an HTML string that can be used to specify the value(s) for this parameter.

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:
An HTML string that can be used to specify the value(s) for this parameter.

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 new multivalued parameter that is a duplicate of this parameter.

Specified by:
clone in class Parameter
Returns:
A new multivalued parameter that is a duplicate of this parameter.

indexToIntValue

public int indexToIntValue(int valueIndex)
Provides a mapping between the position of an element in the set of value strings to the numeric value associated with the element in that position.

Parameters:
valueIndex - The position of the item in the set of value strings.
Returns:
The integer value associated with the item in the specified position.

getMaxValue

public int getMaxValue()
Retrieves the maximum allowed value for this parameter based on the number of items in the set of potential values.

Returns:
The maximum allowed value for this parameter.