com.sun.slamd.parameter
Class FileURLParameter

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

public class FileURLParameter
extends Parameter

This class defines a parameter whose value specifies a file from which clients may obtain data to use during processing. The file specified must be accessible to all clients. If a client cannot access the specified file, then an attempt to obtain its contents will result in an exception. Note that a call to retrieve the information in the file will read the entire contents of that file into memory, so it is best to keep the files small. That should also be done if the files are to be retrieved from a remote server because of the transfer involved.
The file specified in this parameter should actually be in the form of a URL. The URL may be either a file URL that points to a file on the local or network-attached filesystem (e.g., "file:///tmp/file.txt" would refer to the file "/tmp/file.txt"), or may be an HTTP URL that points to a publicly-readable file on a Web server (via HTTP -- not HTTPS).


Field Summary
static int URL_TYPE_FILE
          The URL type that indicates the file will be retrieved from the local filesystem.
static int URL_TYPE_FTP
          The URL type that indicates the file will be retrieved from a remote server over FTP.
static int URL_TYPE_HTTP
          The URL type that indicates the file will be retrieved from a remote server over HTTP.
static int URL_TYPE_HTTPS
          The URL type that indicates the file will be retrieved from a remote server over HTTPS.
static int URL_TYPE_NONE
          The URL type that indicates that no URL was provided.
 
Fields inherited from class com.sun.slamd.parameter.Parameter
description, displayName, isRequired, name, value
 
Constructor Summary
FileURLParameter()
          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.
FileURLParameter(java.lang.String name)
          Creates a new file parameter with the specified name.
FileURLParameter(java.lang.String name, boolean isRequired)
          Creates a new file parameter with the specified name and required/optional indicator.
FileURLParameter(java.lang.String name, java.lang.String displayName)
          Creates a new file parameter with the specified name and display name.
FileURLParameter(java.lang.String name, java.lang.String displayName, boolean isRequired)
          Creates a new file parameter with the specified name, display name, and required/optional indicator.
FileURLParameter(java.lang.String name, java.lang.String displayName, java.lang.String description, boolean isRequired, java.lang.String urlString)
          Creates a new file URL parameter with the specified information.
FileURLParameter(java.lang.String name, java.lang.String displayName, java.lang.String description, java.net.URL fileURL)
          Creates a new file parameter with the specified name, display name, description, and file URL.
FileURLParameter(java.lang.String name, java.lang.String displayName, java.lang.String description, java.net.URL fileURL, boolean isRequired)
          Creates a new file parameter with the specified name, display name, description and file URL, and required/optional indicator.
FileURLParameter(java.lang.String name, java.lang.String displayName, java.net.URL fileURL)
          Creates a new file parameter with the specified name, display name, and file URL.
FileURLParameter(java.lang.String name, java.lang.String displayName, java.net.URL fileURL, boolean isRequired)
          Creates a new file parameter with the specified name, display name, file URL, and required/optional indicator.
 
Method Summary
 java.lang.Object clone()
          Creates a clone of this parameter.
 java.lang.String getDisplayValue()
          Retrieves the value of the parameter in a form that may be displayed to the end user.
 java.lang.String[] getFileLines()
          Retrieves the contents of the file as an array of strings corresponding to the lines in the file.
 java.net.URL getFileURL()
          Retrieves the URL associated with this file parameter.
 java.lang.String getHTMLDisplayValue()
          Retrieves the value of the parameter in a form that may be displayed to the end user as part of an HTML document.
 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.io.InputStream getInputStream()
          Retrieves an input stream that allows the caller to get access to the information in the file.
 java.lang.String getInvalidReason(java.lang.Object value)
          Retrieves the reason that the specified value is not acceptable for use with this parameter.
 java.lang.String[] getNonBlankFileLines()
          Retrieves the contents of the file as an array of strings corresponding to the lines in the file, with blank lines omitted.
 byte[] getRawFileData()
          Retrieves the contents of the file as an array of the bytes contained in that file.
 java.lang.Object getValue()
          Retrieves the file URL associated with this parameter.
 java.lang.String getValueString()
          Retrieves the value of this parameter in text form.
 int getVisibleColumns()
          Retrieves the number of columns that should be visible in the HTML input form.
 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(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.
 
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
 

Field Detail

URL_TYPE_NONE

public static final int URL_TYPE_NONE
The URL type that indicates that no URL was provided.

See Also:
Constant Field Values

URL_TYPE_FILE

public static final int URL_TYPE_FILE
The URL type that indicates the file will be retrieved from the local filesystem.

See Also:
Constant Field Values

URL_TYPE_HTTP

public static final int URL_TYPE_HTTP
The URL type that indicates the file will be retrieved from a remote server over HTTP.

See Also:
Constant Field Values

URL_TYPE_HTTPS

public static final int URL_TYPE_HTTPS
The URL type that indicates the file will be retrieved from a remote server over HTTPS.

See Also:
Constant Field Values

URL_TYPE_FTP

public static final int URL_TYPE_FTP
The URL type that indicates the file will be retrieved from a remote server over FTP.

See Also:
Constant Field Values
Constructor Detail

FileURLParameter

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


FileURLParameter

public FileURLParameter(java.lang.String name)
Creates a new file parameter with the specified name. The display name will be the same as the name, it will not have a description or value, and it will not be required.

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

FileURLParameter

public FileURLParameter(java.lang.String name,
                        boolean isRequired)
Creates a new file parameter with the specified name and required/optional indicator. The display name will be the same as the name, and it will not have a description or value.

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

FileURLParameter

public FileURLParameter(java.lang.String name,
                        java.lang.String displayName)
Creates a new file parameter with the specified name and display name. It will not have a description or value, and it will not be required.

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

FileURLParameter

public FileURLParameter(java.lang.String name,
                        java.lang.String displayName,
                        boolean isRequired)
Creates a new file parameter with the specified name, display name, and required/optional indicator. It will not have a description or value.

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

FileURLParameter

public FileURLParameter(java.lang.String name,
                        java.lang.String displayName,
                        java.net.URL fileURL)
Creates a new file parameter with the specified name, display name, and file URL. It will not have a description, and will not be required.

Parameters:
name - The name to use for this parameter.
displayName - The display name to use for this parameter.
fileURL - The URL specifying the location and access method for the file to use for this parameter.

FileURLParameter

public FileURLParameter(java.lang.String name,
                        java.lang.String displayName,
                        java.net.URL fileURL,
                        boolean isRequired)
Creates a new file parameter with the specified name, display name, file URL, and required/optional indicator. It will not have a description.

Parameters:
name - The name to use for this parameter.
displayName - The display name to use for this parameter.
fileURL - The URL specifying the location and access method for the file to use for this parameter.
isRequired - Indicates whether this parameter is required to have a value.

FileURLParameter

public FileURLParameter(java.lang.String name,
                        java.lang.String displayName,
                        java.lang.String description,
                        java.net.URL fileURL)
Creates a new file parameter with the specified name, display name, description, and file URL. 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.
fileURL - The URL specifying the location and access method for the file to use for this parameter.

FileURLParameter

public FileURLParameter(java.lang.String name,
                        java.lang.String displayName,
                        java.lang.String description,
                        java.net.URL fileURL,
                        boolean isRequired)
Creates a new file parameter with the specified name, display name, description and file URL, 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.
fileURL - The URL specifying the location and access method for the file to use for this parameter.
isRequired - Indicates whether this parameter is required to have a value.

FileURLParameter

public FileURLParameter(java.lang.String name,
                        java.lang.String displayName,
                        java.lang.String description,
                        boolean isRequired,
                        java.lang.String urlString)
                 throws InvalidValueException
Creates a new file URL parameter with the specified information.

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.
isRequired - Indicates whether this parameter is required to have a value.
urlString - The string representation of the URL specifying the location and access method for the file to use for this parameter.
Throws:
InvalidValueException - If the provided URL string does not contain a valid or supported URL.
Method Detail

getFileURL

public java.net.URL getFileURL()
Retrieves the URL associated with this file parameter. Note that this may not contain all information in the URL, since the java.net.URL object does not have any way of dealing with authentication data.

Returns:
The URL associated with this file parameter.

getFileLines

public java.lang.String[] getFileLines()
                                throws java.io.IOException,
                                       SLAMDException
Retrieves the contents of the file as an array of strings corresponding to the lines in the file.

Returns:
The contents of the file as an array of lines.
Throws:
java.io.IOException - If a problem occurs while attempting to access the information in the specified file.
SLAMDException - If a problem is encountered while parsing the file URL to retrieve the appropriate information from it.

getNonBlankFileLines

public java.lang.String[] getNonBlankFileLines()
                                        throws java.io.IOException,
                                               SLAMDException
Retrieves the contents of the file as an array of strings corresponding to the lines in the file, with blank lines omitted.

Returns:
The contents of the file as an array of lines with blank lines omitted.
Throws:
java.io.IOException - If a problem occurs while attempting to access the information in the specified file.
SLAMDException - If a problem is encountered while parsing the file URL to retrieve the appropriate information from it.

getRawFileData

public byte[] getRawFileData()
                      throws java.io.IOException,
                             SLAMDException
Retrieves the contents of the file as an array of the bytes contained in that file.

Returns:
The binary contents of the specified file.
Throws:
java.io.IOException - If a problem occurs while attempting to access the information in the specified file.
SLAMDException - If a problem is encountered while parsing the file URL to retrieve the appropriate information from it.

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException,
                                          SLAMDException
Retrieves an input stream that allows the caller to get access to the information in the file.

Returns:
An input stream that allows the caller to get access to the information in the file.
Throws:
java.io.IOException - If a problem occurs while opening the input stream.
SLAMDException - If a problem is encountered while parsing the file URL to retrieve the appropriate information from it.

getValue

public java.lang.Object getValue()
Retrieves the file URL associated with this parameter.

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

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 provided value is not acceptable for use with this parameter.

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 the value of this parameter in text form.

Specified by:
getValueString in class Parameter
Returns:
The value of this parameter in text form.

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 acceptable for use with this parameter.

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 acceptable for use with this parameter, or null if it is acceptable.

getDisplayValue

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

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

getHTMLDisplayValue

public java.lang.String getHTMLDisplayValue()
Retrieves the value of the parameter in a form that may be displayed to the end user as part of an HTML document.

Overrides:
getHTMLDisplayValue in class Parameter
Returns:
The value of the parameter in a form that may be displayed to the end user as part of an HTML document.

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