com.sun.slamd.parameter
Class BooleanParameter

java.lang.Object
  extended by com.sun.slamd.parameter.Parameter
      extended by com.sun.slamd.parameter.BooleanParameter
All Implemented Interfaces:
java.lang.Cloneable

public class BooleanParameter
extends Parameter

This class defines a Boolean parameter that can have a value of either "true" or "false". The HTML representation of this parameter type is a checkbox.

Author:
Neil A. Wilson

Field Summary
 
Fields inherited from class com.sun.slamd.parameter.Parameter
description, displayName, isRequired, isSensitive, name, value
 
Constructor Summary
BooleanParameter()
          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.
BooleanParameter(java.lang.String name, boolean booleanValue)
          Creates a new Boolean parameter with the specified name and boolean value.
BooleanParameter(java.lang.String name, java.lang.String displayName, boolean booleanValue)
          Creates a new Boolean parameter with the specified name, display name, and boolean value.
BooleanParameter(java.lang.String name, java.lang.String displayName, java.lang.String description, boolean booleanValue)
          Creates a new Boolean parameter with the specified name, display name, description, and boolean value.
 
Method Summary
 java.lang.Object clone()
          Creates a clone of this parameter.
 java.lang.String generateHidden(java.lang.String prefix)
          Retrieves a string representation of the content that should be included in an HTML form in which this parameter should be provided as a hidden element.
 boolean getBooleanValue()
          Retrieves the value of this parameter as a Java boolean primitive.
 java.lang.String getDisplayValue()
          Retrieves the value of this parameter in a form that can be displayed to the end user.
 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 getHTMLPostValue()
          Retrieves the value of this parameter as it would be submitted by a browser posting the request.
 java.lang.String getInvalidReason(java.lang.Object value)
          Retrieves the reason that the specified value is not valid.
 java.lang.Object getValue()
          Retrieves the value of this parameter as a Java Boolean object.
 java.lang.String getValueString()
          Retrieves a string representation of the value of this parameter.
 boolean hasValue()
          Indicates whether this parameter has a value.
 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 setValue(boolean booleanValue)
          Specifies the value to use for this Boolean parameter.
 void setValue(java.lang.Object value)
          Specifies the value to use for this Boolean 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, getInvalidReason, getName, htmlInputFormToValue, isRequired, isSensitive, isValid, isValid, setDescription, setDisplayName, setName, setRequired, setSensitive, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BooleanParameter

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


BooleanParameter

public BooleanParameter(java.lang.String name,
                        boolean booleanValue)
Creates a new Boolean parameter with the specified name and boolean value. The display name will be the same as the name, and it will not have a description.

Parameters:
name - The name to use for this parameter.
booleanValue - The Java boolean to use for the value of this parameter.

BooleanParameter

public BooleanParameter(java.lang.String name,
                        java.lang.String displayName,
                        boolean booleanValue)
Creates a new Boolean parameter with the specified name, display name, and boolean value. It will not have a description.

Parameters:
name - The name to use for this parameter.
displayName - The name to use when displaying the parameter to the end user.
booleanValue - The Java boolean to use for the value of this parameter.

BooleanParameter

public BooleanParameter(java.lang.String name,
                        java.lang.String displayName,
                        java.lang.String description,
                        boolean booleanValue)
Creates a new Boolean parameter with the specified name, display name, description, and boolean value.

Parameters:
name - The name to use for this parameter.
displayName - The name to use when displaying the parameter to the end user.
description - A description of this parameter.
booleanValue - The Java boolean to use for the value of this parameter.
Method Detail

getBooleanValue

public boolean getBooleanValue()
Retrieves the value of this parameter as a Java boolean primitive.

Returns:
The value of this parameter as a Java boolean primitive.

getValue

public java.lang.Object getValue()
Retrieves the value of this parameter as a Java Boolean object.

Overrides:
getValue in class Parameter
Returns:
The value of this parameter as a Java Boolean object.

setValue

public void setValue(boolean booleanValue)
Specifies the value to use for this Boolean parameter.

Parameters:
booleanValue - The value to use for this Boolean parameter.

setValue

public void setValue(java.lang.Object value)
              throws InvalidValueException
Specifies the value to use for this Boolean parameter. Only values of type Boolean and String will be accepted, and String values will only be accepted if the value is "true" or "false" (case insensitive).

Overrides:
setValue in class Parameter
Parameters:
value - The value to use for this Boolean parameter.
Throws:
InvalidValueException - If the provided object is not a Boolean or a String, or if it is a String but the text is not "true" or "false".

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.

hasValue

public boolean hasValue()
Indicates whether this parameter has a value. In this case, it will always return true, because a Boolean parameter will always have a value.

Overrides:
hasValue in class Parameter
Returns:
true, because Boolean parameters always have a value.

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)
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.

generateHidden

public java.lang.String generateHidden(java.lang.String prefix)
Retrieves a string representation of the content that should be included in an HTML form in which this parameter should be provided as a hidden element.

Specified by:
generateHidden in class Parameter
Parameters:
prefix - The prefix to use for the parameter name.
Returns:
A string representation of this parameter as a hidden element in an HTML form.

getHTMLPostValue

public java.lang.String getHTMLPostValue()
Retrieves the value of this parameter as it would be submitted by a browser posting the request.

Overrides:
getHTMLPostValue in class Parameter
Returns:
The value of this parameter as it would be submitted by a browser posting the request, or null if this parameter should not be included in the post.

clone

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

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