com.sun.slamd.parameter
Class IntegerParameter

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

public class IntegerParameter
extends Parameter

This class defines a parameter whose value is a mathematical integer (no decimal values). It can also support upper and lower bounds, although they are not required to be enforced.


Field Summary
 
Fields inherited from class com.sun.slamd.parameter.Parameter
description, displayName, isRequired, name, value
 
Constructor Summary
IntegerParameter()
          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.
IntegerParameter(java.lang.String name)
          Creates a new integer parameter with the specified name.
IntegerParameter(java.lang.String name, boolean isRequired, int value)
          Creates a new integer parameter with the specified name, value, and required/optional indicator.
IntegerParameter(java.lang.String name, int value)
          Creates a new integer parameter with the specified name and value.
IntegerParameter(java.lang.String name, java.lang.String displayName, boolean isRequired, int value)
          Creates a new integer parameter with the specified name, display name, value, and required/optional indicator.
IntegerParameter(java.lang.String name, java.lang.String displayName, java.lang.String description, boolean isRequired, int value)
          Creates a new integer parameter with the specified name, display name, description, value, and required/optional indicator.
IntegerParameter(java.lang.String name, java.lang.String displayName, java.lang.String description, boolean isRequired, int value, boolean hasLowerBound, int lowerBound, boolean hasUpperBound, int upperBound)
          Creates a new integer parameter with the specified name, display name, description, value, and required/optional indicator, as well as information pertaining to upper and lower bounds.
 
Method Summary
 java.lang.Object clone()
          Creates a clone of this parameter.
 java.lang.String getDisplayValue()
          Retrieves a String that can be used when displaying the value of this parameter to the end user.
 java.lang.String getHTMLDisplayValue()
          Retrieves a String that can be used when displaying the value of this parameter to the end user in the context of an HTML page.
 java.lang.String getHTMLInputForm(java.lang.String prefix)
          Retrieves a string of text that can be used to request a value for this parameter using an HTML form.
 int getIntValue()
          Retrieves the value associated with this parameter as a Java integer.
 java.lang.String getInvalidReason(java.lang.Object value)
          Retrieves the reason that the specified value is not valid.
 int getLowerBound()
          Retrieves the lower bound that will be used if a lower bound is to be enforced.
 int getUpperBound()
          Retrieves the upper bound that will be used if an upper bound is to be enforced.
 java.lang.Object getValue()
          Retrieves the value associated with this parameter.
 java.lang.String getValueString()
          Retrieves a string representation of the value of this parameter.
 int getVisibleColumns()
          Retrieves the number of columns that should be visible in the HTML input form.
 boolean hasLowerBound()
          Indicates whether a lower bound will be enforced for this parameter.
 boolean hasUpperBound()
          Indicates whether an upper bound will be enforced for 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 setLowerBound(int lowerBound)
          Specifies the value to use as the lower bound, and indicates that a lower bound is to be enforced for this parameter.
 void setUpperBound(int upperBound)
          Specifies the value to use as the upper bound, and indicates that an upper bound is to be enforced for this parameter.
 void setValue(int value)
          Specifies the 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 setVisibleColumns(int visibleColumns)
          Specifies the number of columns that should be visible in the HTML input form.
 void unsetLowerBound()
          Specifies that a lower bound should not be enforced for this parameter.
 void unsetUpperBound()
          Specifies that an upper bound should not be enforced for this parameter.
 
Methods inherited from class com.sun.slamd.parameter.Parameter
decode, encode, getDescription, getDisplayName, getHTMLPostValue, getInvalidReason, getName, 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

IntegerParameter

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


IntegerParameter

public IntegerParameter(java.lang.String name)
Creates a new integer parameter with the specified name. The display name will be the same as the name, it will not have a description or a value, and it will not be required to have a value. Upper and lower bounds will not be enforced.

Parameters:
name - The name to use for this parameter.

IntegerParameter

public IntegerParameter(java.lang.String name,
                        int value)
Creates a new integer parameter with the specified name and value. The display name will be the same as the name, and it will not have a description. It will not be required, nor will upper or lower bounds be enforced.

Parameters:
name - The name to use for this parameter.
value - The value to use for this parameter.

IntegerParameter

public IntegerParameter(java.lang.String name,
                        boolean isRequired,
                        int value)
Creates a new integer parameter with the specified name, value, and required/optional indicator. The display name will be the same as the name and it will not have a description. Upper and lower bounds will not be enforced.

Parameters:
name - The name to use for this parameter.
isRequired - Indicates whether this parameter is required to have a value.
value - The value to use for this parameter.

IntegerParameter

public IntegerParameter(java.lang.String name,
                        java.lang.String displayName,
                        boolean isRequired,
                        int value)
Creates a new integer parameter with the specified name, display name, value, and required/optional indicator. It will not have a description, and upper and lower bounds will not be enforced.

Parameters:
name - The name to use for this parameter.
displayName - The name to use for this parameter when it is displayed to the end user.
isRequired - Indicates whether this parameter is required to have a value.
value - The value to use for this parameter.

IntegerParameter

public IntegerParameter(java.lang.String name,
                        java.lang.String displayName,
                        java.lang.String description,
                        boolean isRequired,
                        int value)
Creates a new integer parameter with the specified name, display name, description, value, and required/optional indicator. Upper and lower bounds will not be enforced.

Parameters:
name - The name to use for this parameter.
displayName - The name to use for this parameter when it is displayed to the end user.
description - The description to use for this parameter.
isRequired - Indicates whether this parameter is required to have a value.
value - The value to use for this parameter.

IntegerParameter

public IntegerParameter(java.lang.String name,
                        java.lang.String displayName,
                        java.lang.String description,
                        boolean isRequired,
                        int value,
                        boolean hasLowerBound,
                        int lowerBound,
                        boolean hasUpperBound,
                        int upperBound)
Creates a new integer parameter with the specified name, display name, description, value, and required/optional indicator, as well as information pertaining to upper and lower bounds.

Parameters:
name - The name to use for this parameter.
displayName - The name to use for this parameter when it is displayed to the end user.
description - The description to use for this parameter.
isRequired - Indicates whether this parameter is required to have a value.
value - The value to use for this parameter.
hasLowerBound - Indicates whether the lower bound will be enforced for this parameter.
lowerBound - The lower bound to use for this parameter (will only be effective if hasLowerBound is true).
hasUpperBound - Indicates whether the upper bound will be enforced for this parameter.
upperBound - The upper bound to use for this parameter (will only be effective if hasUpperBound is true).
Method Detail

getIntValue

public int getIntValue()
Retrieves the value associated with this parameter as a Java integer. Note that you should check to make sure that this parameter actually has a value before calling this method, because it is possible to have an integer parameter whose value is not required. If this parameter does not have a value, then the value returned from this function is unreliable.

Returns:
The value associated with this parameter as a Java integer.

getValue

public java.lang.Object getValue()
Retrieves the value associated with this parameter. If it does not have a value, then null will be returned. If it does have a value, then that value will be returned as a Java Integer object.

Overrides:
getValue in class Parameter
Returns:
The value associated with this parameter.

setValue

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

Parameters:
value - The value to use for this parameter.
Throws:
InvalidValueException - If the specified value does not meet the upper or lower bounds requirements (if they are to be enforced).

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 cannot be interpreted as a Java integer, or if it does not meet the upper or lower bounds requirements (if they are to be enforced).

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.

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.

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.

getLowerBound

public int getLowerBound()
Retrieves the lower bound that will be used if a lower bound is to be enforced. If the lower bound is not to be enforced, then the value returned from this method will be meaningless.

Returns:
The lower bound that will be used if a lower bound is to be enforced.

setLowerBound

public void setLowerBound(int lowerBound)
Specifies the value to use as the lower bound, and indicates that a lower bound is to be enforced for this parameter.

Parameters:
lowerBound - The value to use as the lower bound.

unsetLowerBound

public void unsetLowerBound()
Specifies that a lower bound should not be enforced for this parameter.


hasLowerBound

public boolean hasLowerBound()
Indicates whether a lower bound will be enforced for this parameter.

Returns:
true if a lower bound will be enforced, or false if not.

getUpperBound

public int getUpperBound()
Retrieves the upper bound that will be used if an upper bound is to be enforced. If the upper bound is not to be enforced, then the value returned from this method will be meaningless.

Returns:
The lower bound that will be used if a lower bound is to be enforced.

setUpperBound

public void setUpperBound(int upperBound)
Specifies the value to use as the upper bound, and indicates that an upper bound is to be enforced for this parameter.

Parameters:
upperBound - The value to use as the upper bound.

unsetUpperBound

public void unsetUpperBound()
Specifies that an upper bound should not be enforced for this parameter.


hasUpperBound

public boolean hasUpperBound()
Indicates whether an upper bound will be enforced for this parameter.

Returns:
true if an upper bound will be enforced, or false if not.

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 a String that can be used when displaying the value of this parameter to the end user.

Specified by:
getDisplayValue in class Parameter
Returns:
A String that can be used when displaying the value of this parameter to the end user.

getHTMLDisplayValue

public java.lang.String getHTMLDisplayValue()
Retrieves a String that can be used when displaying the value of this parameter to the end user in the context of an HTML page.

Overrides:
getHTMLDisplayValue in class Parameter
Returns:
A String that can be used when displaying the value of this parameter to the end user in the context of an HTML page.

getVisibleColumns

public int getVisibleColumns()
Retrieves the number of columns that should be visible in the HTML input form.

Returns:
The number of columns that should be visible in the HTML input form.

setVisibleColumns

public void setVisibleColumns(int visibleColumns)
Specifies the number of columns that should be visible in the HTML input form.

Parameters:
visibleColumns - The number of columns that should be visible in the HTML input form.

getHTMLInputForm

public java.lang.String getHTMLInputForm(java.lang.String prefix)
Retrieves a string of text that can be used to request a value for this parameter using an HTML form. Note that this should just be for the input field itself and should not use the display name or have any special marker to indicate whether the value is required or not, as those are to be added by whaterver is generating the HTML page.

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:
A string of text that can be used to request a value for this parameter using 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.