jwo.landserf.script
Class LSCommand

java.lang.Object
  extended by jwo.landserf.script.LSCommand

public class LSCommand
extends Object

Stores a command for the control of a LandSerf process.

Version:
2.3, 7th March, 2007.
Author:
Jo Wood

Constructor Summary
LSCommand(String name, String desc)
          Creates a command with the given name and description.
LSCommand(String name, String desc, LSParameter[] params)
          Creates a command with the given name, description and list of parameters.
LSCommand(String name, String desc, LSParameter[] params, int returnType)
          Creates a command with the given name, description, list of parameters and return type.
 
Method Summary
 void addParameter(LSParameter param)
          Adds a parameter to the command.
 String getDescription()
          Reports the description of the command.
 String getHelp()
          Reports a longer help message associated with this command.
 String getName()
          Reports the name of the command.
 LSParameter[] getParameters()
          Reports the parameters used by the command.
 int getReturnType()
          Reports the type of value returned by the command.
 void setHelp(String message)
          Sets a longer help message to be associated with this command.
 boolean setParameterValues(Vector paramList)
          Sets the parameter values with those given in the given collection.
 String toFormattedString()
          Reports a formatted help message describing command and its parameters.
 String toString()
          Reports a help message describing command and its parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LSCommand

public LSCommand(String name,
                 String desc)
Creates a command with the given name and description. To add parameters to the command created with this constructor, use addParameter().

Parameters:
name - Name of the command.
desc - Description of the command.

LSCommand

public LSCommand(String name,
                 String desc,
                 LSParameter[] params)
Creates a command with the given name, description and list of parameters. Assumes the return type is void.

Parameters:
name - Name of the command.
desc - Description of the command.
params - List of parameters used by command.

LSCommand

public LSCommand(String name,
                 String desc,
                 LSParameter[] params,
                 int returnType)
Creates a command with the given name, description, list of parameters and return type. Return type can be LSParameter variable types or LSParamater.VOID if nothing is returned.

Parameters:
name - Name of the command.
desc - Description of the command.
params - List of parameters used by command.
returnType - Type of value returned by the command.
Method Detail

getName

public String getName()
Reports the name of the command.

Returns:
Name of command.

getDescription

public String getDescription()
Reports the description of the command. Should be one or two sentences at most. This is useful for help and error messages. For longer help text, such as examples and extended discussion of use, consider using getHelp().

Returns:
Description of the command.

getHelp

public String getHelp()
Reports a longer help message associated with this command. Typically would include examples and extended discussion of use. Help message shoulbe be formatted using well formed XHTML. If no help message is provided, this will return null.

Returns:
Extended description of the command or null if not defined.

setHelp

public void setHelp(String message)
Sets a longer help message to be associated with this command. Typically would include examples and extended discussion of use. Help message should be formatted using well formed XHTML.

Parameters:
message - XHTML Help message to be associated with the command.

getParameters

public LSParameter[] getParameters()
Reports the parameters used by the command.

Returns:
Array of parameters.

getReturnType

public int getReturnType()
Reports the type of value returned by the command. Can be LSParameter.VOID if nothing returned or one of the LSParameter types (STRING, NUMBER, RASTER_PARAM etc.)

Returns:
Return type of command.

setParameterValues

public boolean setParameterValues(Vector paramList)
Sets the parameter values with those given in the given collection.

Parameters:
paramList - List of parameters values to supply to this command. This should stored as a collection of objects of type SpatialObject or String (including number and boolean representations). If any values are null and the command has default values supplied, these will be substituted.
Returns:
True if parameters stored successfully. Can be false if the parameter types do not match those defined by the command.

addParameter

public void addParameter(LSParameter param)
Adds a parameter to the command.

Parameters:
param - Parameter to add.

toString

public String toString()
Reports a help message describing command and its parameters. Note that this version does not include any extended help information. To generate full help message use toFormattedString()

Overrides:
toString in class Object
Returns:
Command description.

toFormattedString

public String toFormattedString()
Reports a formatted help message describing command and its parameters. This version includes extended help message if it exists.

Returns:
Command description.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009