com.sun.slamd.parameter
Class Parameter

java.lang.Object
  extended bycom.sun.slamd.parameter.Parameter
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
BooleanParameter, FileURLParameter, FloatParameter, IntegerParameter, IntegerWithUnitParameter, LabelParameter, LongParameter, MultiChoiceParameter, MultiLineTextParameter, MultiValuedParameter, PasswordParameter, PlaceholderParameter, StringParameter

public abstract class Parameter
extends java.lang.Object
implements java.lang.Cloneable

This class defines a generic parameter that can be passed to a job to customize the way that it operates. It also defines functions that can be used to request and accept the value in the context of an HTML form.


Field Summary
protected  java.lang.String description
           
protected  java.lang.String displayName
           
protected  boolean isRequired
           
protected  java.lang.String name
           
protected  java.lang.Object value
           
 
Constructor Summary
Parameter()
          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.
Parameter(java.lang.String name, java.lang.String displayName, java.lang.String description, boolean isRequired, java.lang.Object value)
          Creates a new instance of the Parameter based on the provided information.
 
Method Summary
abstract  java.lang.Object clone()
          Creates a clone of this parameter.
static Parameter decode(ASN1Element element)
          Decodes the provided ASN.1 element as a parameter.
 ASN1Element encode()
          Encodes this parameter as an ASN.1 element.
 java.lang.String getDescription()
          Retrieves the description for this parameter.
 java.lang.String getDisplayName()
          Retrieves the name of this parameter as it is displayed to the end user.
abstract  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.
abstract  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.
 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()
          Retrieves the reason that the current value is not valid.
abstract  java.lang.String getInvalidReason(java.lang.Object value)
          Retrieves the reason that the specified value is not valid.
 java.lang.String getName()
          Retrieves the name of this parameter as it is used internally.
 java.lang.Object getValue()
          Retrieves the value for this parameter.
abstract  java.lang.String getValueString()
          Retrieves a string representation of the value of this parameter.
 boolean hasValue()
          Indicates whether a value has been specified for this parameter.
abstract  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.
 boolean isRequired()
          Indicates whether this parameter is required to have a value.
 boolean isValid()
          Indicates whether the current value for this parameter is valid.
 boolean isValid(java.lang.Object value)
          Indicates whether the specified value would be a valid value for this parameter.
 void setDescription(java.lang.String description)
          Specifies the description for this parameter.
 void setDisplayName(java.lang.String displayName)
          Specifies the name of this parameter as it should be displayed to the end user.
 void setName(java.lang.String name)
          Specifies the name to use for this parameter.
 void setRequired(boolean isRequired)
          Specifies whether this parameter is required to have a value.
 void setValue(java.lang.Object value)
          Specifies the value to use for this parameter.
abstract  void setValueFrom(Parameter parameter)
          Sets the value for this parameter from the information in the provided parameter.
abstract  void setValueFromString(java.lang.String valueString)
          Specifies the value to use for this parameter from the provided String.
 java.lang.String toString()
          Retrieves a string representation of this parameter.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isRequired

protected boolean isRequired

value

protected java.lang.Object value

description

protected java.lang.String description

displayName

protected java.lang.String displayName

name

protected java.lang.String name
Constructor Detail

Parameter

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


Parameter

public Parameter(java.lang.String name,
                 java.lang.String displayName,
                 java.lang.String description,
                 boolean isRequired,
                 java.lang.Object value)
Creates a new instance of the Parameter based on the provided information. This is only to be called by subclasses that actually implement valid Parameter objects. Note that if a value is provided, no validation is performed on it to verify that it is acceptable.

Parameters:
name - The name of the parameter as it is used internally.
displayName - The name of the parameter as it is to be displayed to the end user.
description - A description of this parameter that provides more information than just the name.
isRequired - Indicates whether this parameter must have a value.
value - The value for this parameter.
Method Detail

getName

public final java.lang.String getName()
Retrieves the name of this parameter as it is used internally.

Returns:
The name of this parameter as it is used internally.

setName

public final void setName(java.lang.String name)
Specifies the name to use for this parameter.

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

getDisplayName

public final java.lang.String getDisplayName()
Retrieves the name of this parameter as it is displayed to the end user.

Returns:
The name of this parameter as it is displayed to the end user.

setDisplayName

public final void setDisplayName(java.lang.String displayName)
Specifies the name of this parameter as it should be displayed to the end user.

Parameters:
displayName - The name of this parameter as it should be displayed to the end user.

getDescription

public final java.lang.String getDescription()
Retrieves the description for this parameter.

Returns:
The description for this parameter.

setDescription

public final void setDescription(java.lang.String description)
Specifies the description for this parameter.

Parameters:
description - The description for this parameter.

isRequired

public final boolean isRequired()
Indicates whether this parameter is required to have a value.

Returns:
true if this parameter is required to have a value, or false if it does not need a value.

setRequired

public final void setRequired(boolean isRequired)
Specifies whether this parameter is required to have a value.

Parameters:
isRequired - Indicates whether this parameter is required to have a value.

getValue

public java.lang.Object getValue()
Retrieves the value for this parameter.

Returns:
The value for this parameter.

setValue

public void setValue(java.lang.Object 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 is not acceptable for use in this parameter.

setValueFrom

public abstract 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.

Parameters:
parameter - The parameter from which to take the value for this parameter.

getValueString

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

Returns:
A string representation of the value of this parameter.

setValueFromString

public abstract void setValueFromString(java.lang.String valueString)
                                 throws InvalidValueException
Specifies the value to use for this parameter from the provided String.

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 a value has been specified for this parameter.

Returns:
true if a value has been specified for this parameter or false if not.

isValid

public final boolean isValid()
Indicates whether the current value for this parameter is valid.

Returns:
true if the current value for this parameter is valid, or false if it is not.

isValid

public final boolean isValid(java.lang.Object value)
Indicates whether the specified value would be a valid value for this parameter.

Parameters:
value - The value for which to make the determination.
Returns:
true if the specified value would be a valid value for this parameter, or false if it would not be.

getInvalidReason

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

Returns:
The reason that the current value is not valid, or null if it is valid.

getInvalidReason

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

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 abstract java.lang.String getDisplayValue()
Retrieves a String that can be used when displaying the value of this parameter to the end user.

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.

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.

getHTMLPostValue

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

Returns:
The value of this parameter as it would be submitted by a browser posting the request.

getHTMLInputForm

public abstract 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.

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

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.

toString

public java.lang.String toString()
Retrieves a string representation of this parameter.

Returns:
A string representation of this parameter.

clone

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

Returns:
A clone of this parameter.

decode

public static final Parameter decode(ASN1Element element)
                              throws SLAMDException
Decodes the provided ASN.1 element as a parameter.

Parameters:
element - The ASN.1 element to decode.
Returns:
The parameter decoded from the ASN.1 element.
Throws:
SLAMDException - If the provided ASN.1 element cannot be decoded as a parameter.

encode

public final ASN1Element encode()
Encodes this parameter as an ASN.1 element. The ASN.1 syntax for a parameter is:

Parameter ::= SEQUENCE { className OCTET STRING, name OCTET STRING, value OCTET STRING }

Returns:
The encoded ASN.1 element.