jwo.landserf.script
Class LSParameter

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

public class LSParameter
extends Object

Stores a parameter option for command line control of a LandSerf process.

Version:
2.3, 2nd October, 2008
Author:
Jo Wood

Field Summary
static int BOOLEAN
          Indicates a boolean (flag) parameter.
static int NUMBER
          Indicates a numerical parameter .
static int RASTER_PARAM
          Indicates a raster map parameter.
static int SPATIAL_PARAM
          Indicates a spatial object parameter.
static int STRING
          Indicates a string parameter.
static int UNDECLARED
          Indicates a parameter with an undeclared type.
static int VECTOR_PARAM
          Indicates a vector map parameter.
static int VOID
          Indicates a void return type.
 
Constructor Summary
LSParameter(String key, String desc)
          Creates a compulsory string parameter used for a landScript method.
LSParameter(String key, String desc, int type)
          Creates a compulsory parameter used for a landScript method.
LSParameter(String key, String desc, int type, String defaultVal)
          Creates a parameter used for a landScript method.
LSParameter(String key, String desc, String defaultVal)
          Creates an optional string parameter with default value used for a landScript method.
 
Method Summary
 String getDefault()
          Reports the default value for this parameter, or null if it is a required parameter.
 String getDesc()
          Describes the parameter.
 String getKey()
          Reports the parameter name (key).
 int getType()
          Reports the type of parameter.
static String getTypeAsString(int type)
          Reports the type of the given parameter id as a string message.
 Object getValue()
          Reports the parameter value.
 boolean isRequired()
          Reports whether or not the parameter is required.
 boolean setValue(SpatialObject value)
          Sets the parameter value.
 boolean setValue(String value)
          Sets the parameter value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VOID

public static final int VOID
Indicates a void return type.

See Also:
Constant Field Values

STRING

public static final int STRING
Indicates a string parameter.

See Also:
Constant Field Values

NUMBER

public static final int NUMBER
Indicates a numerical parameter .

See Also:
Constant Field Values

BOOLEAN

public static final int BOOLEAN
Indicates a boolean (flag) parameter.

See Also:
Constant Field Values

SPATIAL_PARAM

public static final int SPATIAL_PARAM
Indicates a spatial object parameter.

See Also:
Constant Field Values

RASTER_PARAM

public static final int RASTER_PARAM
Indicates a raster map parameter.

See Also:
Constant Field Values

VECTOR_PARAM

public static final int VECTOR_PARAM
Indicates a vector map parameter.

See Also:
Constant Field Values

UNDECLARED

public static final int UNDECLARED
Indicates a parameter with an undeclared type.

See Also:
Constant Field Values
Constructor Detail

LSParameter

public LSParameter(String key,
                   String desc)
Creates a compulsory string parameter used for a landScript method.

Parameters:
key - Parameter key (name used to identify parameter).
desc - Description of the parameter.

LSParameter

public LSParameter(String key,
                   String desc,
                   String defaultVal)
Creates an optional string parameter with default value used for a landScript method.

Parameters:
key - Parameter key (name used to identify parameter).
desc - Description of the parameter.
defaultVal - Default value for the parameter. If null, parameter assumed to be compulsory.

LSParameter

public LSParameter(String key,
                   String desc,
                   int type)
Creates a compulsory parameter used for a landScript method.

Parameters:
key - Parameter key (name used to identify parameter).
desc - Description of the parameter.
type - Type of parameter (e.g. STRING, NUMBER, RASTER_PARAM, VECTOR_PARAM, SPATIAL_PARAM).

LSParameter

public LSParameter(String key,
                   String desc,
                   int type,
                   String defaultVal)
Creates a parameter used for a landScript method. This version can specify whether or not the parameter is compulsory. Note that the only possible default value for a spatial object type is null which indicates object is not used or compulsory.

Parameters:
key - Parameter key (name used on command line).
desc - Description of the parameter.
type - Type of parameter (one of STRING, NUMBER, BOOLEAN, RASTER_PARAM, VECTOR_PARAM or SPATIAL_PARAM).
defaultVal - Default value for the parameter, or string value "null" if not used, or null if compulsory.
Method Detail

getDesc

public String getDesc()
Describes the parameter.

Returns:
Parameter description.

getKey

public String getKey()
Reports the parameter name (key).

Returns:
Parameter name.

isRequired

public boolean isRequired()
Reports whether or not the parameter is required.

Returns:
True if parameter is required, false if optional.

getDefault

public String getDefault()
Reports the default value for this parameter, or null if it is a required parameter.

Returns:
Default value.

getType

public int getType()
Reports the type of parameter.

Returns:
Type of parameter. One of STRING, NUMBER, BOOLEAN, RASTER_PARAM, VECTOR_PARAM, SPATIAL_PARAM or UNDECLARED.

getTypeAsString

public static String getTypeAsString(int type)
Reports the type of the given parameter id as a string message.

Parameters:
type - Type of parameter. Should be one of VOID, NUMBER, SPATIAL_PARAM etc.
Returns:
Text describing the type of parameter

setValue

public boolean setValue(String value)
Sets the parameter value. The type of object should be scalar and compatible with getType(). To store spatial objects, use SetValue(SpatialObject).
STRING types are stored as String objects.
NUMBER types are stored as Double objects.
BOOLEAN types are stored as Boolean objects.

Parameters:
value - String representation of the parameter value.
Returns:
True if parameter value successfully stored

setValue

public boolean setValue(SpatialObject value)
Sets the parameter value. The type of object should be spatial and compatible with getType(). To set scalar values, use setValue(String).
RASTER_PARAM types are stored as RasterMaps.
VECTOR_PARAM types are stored as VectorMaps.
SPATIAL_PARAM types are stored as SpatialObjects.

Parameters:
value - Spatial object representation of the parameter value.
Returns:
True if parameter value successfully stored

getValue

public Object getValue()
Reports the parameter value. The type of object can be determined by getType().
STRING types are stored as String objects.
NUMBER types are stored as Double objects.
BOOLEAN types are stored as Boolean objects.
RASTER_PARAM types are stored as RasterMaps.
VECTOR_PARAM types are stored as VectorMaps.
SPATIAL_PARAM types are stored as SpatialObjects.

Returns:
Parameter value or null if not yet defined.


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