org.geotools.parameter
Class Parameter

java.lang.Object
  extended byorg.geotools.referencing.wkt.Formattable
      extended byorg.geotools.parameter.AbstractParameter
          extended byorg.geotools.parameter.Parameter
All Implemented Interfaces:
org.opengis.util.Cloneable, java.lang.Cloneable, org.opengis.parameter.GeneralParameterValue, org.opengis.parameter.ParameterValue, java.io.Serializable
Direct Known Subclasses:
WMSParameterValue

public class Parameter
extends AbstractParameter
implements org.opengis.parameter.ParameterValue

A parameter value used by an operation method. Most CRS parameter values are numeric, but other types of parameter values are possible. The parameter type can be fetch with the getValue().getClass() idiom. The getValue() and setValue(Object) methods can be invoked at any time. Others getters and setters are parameter-type dependents.

Since:
2.1
Version:
$Id: Parameter.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux, Jody Garnett (Refractions Research)
See Also:
DefaultParameterDescriptor, ParameterGroup, Serialized Form

Constructor Summary
Parameter(org.opengis.parameter.ParameterDescriptor descriptor)
          Constructs a parameter value from the specified descriptor.
Parameter(org.opengis.parameter.ParameterDescriptor descriptor, java.lang.Object value)
          Constructs a parameter value from the specified descriptor and value.
Parameter(java.lang.String name, org.opengis.util.CodeList value)
          Constructs a parameter from the specified enumeration.
Parameter(java.lang.String name, double value, javax.units.Unit unit)
          Constructs a parameter from the specified name and value.
Parameter(java.lang.String name, int value)
          Constructs a parameter from the specified name and value.
 
Method Summary
 boolean booleanValue()
          Returns the boolean value of an operation parameter.
 double doubleValue()
          Returns the numeric value of the coordinate operation parameter with its associated unit of measure.
 double doubleValue(javax.units.Unit unit)
          Returns the numeric value of the coordinate operation parameter in the specified unit of measure.
 double[] doubleValueList()
          Returns an ordered sequence of two or more numeric values of an operation parameter list, where each value has the same associated unit of measure.
 double[] doubleValueList(javax.units.Unit unit)
          Returns an ordered sequence of numeric values in the specified unit of measure.
static void ensureValidValue(org.opengis.parameter.ParameterDescriptor descriptor, java.lang.Object value)
          Ensures that the given value is valid according the specified parameter descriptor.
 boolean equals(java.lang.Object object)
          Compares the specified object with this parameter for equality.
 javax.units.Unit getUnit()
          Returns the unit of measure of the parameter value.
 java.lang.Object getValue()
          Returns the parameter value as an object.
 int hashCode()
          Returns a hash value for this parameter.
 int intValue()
          Returns the positive integer value of an operation parameter, usually used for a count.
 int[] intValueList()
          Returns an ordered sequence of two or more integer values of an operation parameter list, usually used for counts.
 void setValue(boolean value)
          Set the parameter value as a boolean.
 void setValue(double value)
          Set the parameter value as a floating point.
 void setValue(double[] values, javax.units.Unit unit)
          Set the parameter value as an array of floating point and their associated unit.
 void setValue(double value, javax.units.Unit unit)
          Set the parameter value as a floating point and its associated unit.
 void setValue(int value)
          Set the parameter value as an integer.
 void setValue(java.lang.Object value)
          Set the parameter value as an object.
 java.lang.String stringValue()
          Returns the string value of an operation parameter.
 java.net.URI valueFile()
          Returns a reference to a file or a part of a file containing one or more parameter values.
 
Methods inherited from class org.geotools.parameter.AbstractParameter
clone, formatWKT, getDescriptor, toString, write
 
Methods inherited from class org.geotools.referencing.wkt.Formattable
toWKT, toWKT, toWKT
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opengis.parameter.ParameterValue
clone
 
Methods inherited from interface org.opengis.parameter.GeneralParameterValue
getDescriptor
 

Constructor Detail

Parameter

public Parameter(java.lang.String name,
                 int value)
Constructs a parameter from the specified name and value. This convenience constructor creates a DefaultParameterDescriptor object. But if such an object was available, then the preferred way to get a is to invokes GeneralParameterDescriptor.createValue().

Parameters:
name - The parameter name.
value - The parameter value.

Parameter

public Parameter(java.lang.String name,
                 double value,
                 javax.units.Unit unit)
Constructs a parameter from the specified name and value. This convenience constructor creates a DefaultParameterDescriptor object. But if such an object was available, then the preferred way to get a is to invokes GeneralParameterDescriptor.createValue().

Parameters:
name - The parameter name.
value - The parameter value.
unit - The unit for the parameter value.

Parameter

public Parameter(java.lang.String name,
                 org.opengis.util.CodeList value)
Constructs a parameter from the specified enumeration. This convenience constructor creates a DefaultParameterDescriptor object. But if such an object was available, then the preferred way to get a is to invokes GeneralParameterDescriptor.createValue().

Parameters:
name - The parameter name.
value - The parameter value.

Parameter

public Parameter(org.opengis.parameter.ParameterDescriptor descriptor)
Constructs a parameter value from the specified descriptor. The value will be initialized to the default value, if any.

Parameters:
descriptor - The abstract definition of this parameter.

Parameter

public Parameter(org.opengis.parameter.ParameterDescriptor descriptor,
                 java.lang.Object value)
          throws org.opengis.parameter.InvalidParameterValueException
Constructs a parameter value from the specified descriptor and value.

Parameters:
descriptor - The abstract definition of this parameter.
value - The parameter value.
Throws:
org.opengis.parameter.InvalidParameterValueException - if the type of is inappropriate for this parameter, or if the value is illegal for some other reason (for example the value is numeric and out of range).
Method Detail

ensureValidValue

public static void ensureValidValue(org.opengis.parameter.ParameterDescriptor descriptor,
                                    java.lang.Object value)
                             throws org.opengis.parameter.InvalidParameterValueException
Ensures that the given value is valid according the specified parameter descriptor. This convenience method ensures that is assignable to the expected class, is between the minimum and maximum values and is one of the set of valid values. If the value fails any of those tests, then an exception is thrown.

Parameters:
descriptor - The parameter descriptor to check against.
value - The value to check, or .
Throws:
org.opengis.parameter.InvalidParameterValueException - if the parameter value is invalid.

getUnit

public javax.units.Unit getUnit()
Returns the unit of measure of the parameter value. If the parameter value has no unit (for example because it is a String type), then this method returns . Note that "no unit" doesn't means "dimensionless".

Specified by:
getUnit in interface org.opengis.parameter.ParameterValue
Returns:
The unit of measure, or if none.
See Also:
doubleValue(), doubleValueList(), getValue()

doubleValue

public double doubleValue(javax.units.Unit unit)
                   throws org.opengis.parameter.InvalidParameterTypeException
Returns the numeric value of the coordinate operation parameter in the specified unit of measure. This convenience method apply unit conversion on the fly as needed.

Specified by:
doubleValue in interface org.opengis.parameter.ParameterValue
Parameters:
unit - The unit of measure for the value to be returned.
Returns:
The numeric value represented by this parameter after conversion to type and conversion to .
Throws:
org.opengis.parameter.InvalidParameterTypeException - if the value is not a numeric type.
java.lang.IllegalArgumentException - if the specified unit is invalid for this parameter.
See Also:
getUnit(), setValue(double,Unit), doubleValueList(Unit)

doubleValue

public double doubleValue()
                   throws org.opengis.parameter.InvalidParameterTypeException
Returns the numeric value of the coordinate operation parameter with its associated unit of measure.

Specified by:
doubleValue in interface org.opengis.parameter.ParameterValue
Returns:
The numeric value represented by this parameter after conversion to type .
Throws:
org.opengis.parameter.InvalidParameterTypeException - if the value is not a numeric type.
See Also:
getUnit(), setValue(double), doubleValueList()

intValue

public int intValue()
             throws org.opengis.parameter.InvalidParameterTypeException
Returns the positive integer value of an operation parameter, usually used for a count. An integer value does not have an associated unit of measure.

Specified by:
intValue in interface org.opengis.parameter.ParameterValue
Returns:
The numeric value represented by this parameter after conversion to type .
Throws:
org.opengis.parameter.InvalidParameterTypeException - if the value is not an integer type.
See Also:
setValue(int), intValueList()

booleanValue

public boolean booleanValue()
                     throws org.opengis.parameter.InvalidParameterTypeException
Returns the boolean value of an operation parameter. A boolean value does not have an associated unit of measure.

Specified by:
booleanValue in interface org.opengis.parameter.ParameterValue
Returns:
The boolean value represented by this parameter.
Throws:
org.opengis.parameter.InvalidParameterTypeException - if the value is not a boolean type.
See Also:
setValue(boolean)

stringValue

public java.lang.String stringValue()
                             throws org.opengis.parameter.InvalidParameterTypeException
Returns the string value of an operation parameter. A string value does not have an associated unit of measure.

Specified by:
stringValue in interface org.opengis.parameter.ParameterValue
Returns:
The string value represented by this parameter.
Throws:
org.opengis.parameter.InvalidParameterTypeException - if the value is not a string.
See Also:
getValue(), setValue(Object)

doubleValueList

public double[] doubleValueList(javax.units.Unit unit)
                         throws org.opengis.parameter.InvalidParameterTypeException
Returns an ordered sequence of numeric values in the specified unit of measure. This convenience method apply unit conversion on the fly as needed.

Specified by:
doubleValueList in interface org.opengis.parameter.ParameterValue
Parameters:
unit - The unit of measure for the value to be returned.
Returns:
The sequence of values represented by this parameter after conversion to type and conversion to .
Throws:
org.opengis.parameter.InvalidParameterTypeException - if the value is not an array of s.
java.lang.IllegalArgumentException - if the specified unit is invalid for this parameter.
See Also:
getUnit(), setValue(double[],Unit), doubleValue(Unit)

doubleValueList

public double[] doubleValueList()
                         throws org.opengis.parameter.InvalidParameterTypeException
Returns an ordered sequence of two or more numeric values of an operation parameter list, where each value has the same associated unit of measure.

Specified by:
doubleValueList in interface org.opengis.parameter.ParameterValue
Returns:
The sequence of values represented by this parameter.
Throws:
org.opengis.parameter.InvalidParameterTypeException - if the value is not an array of s.
See Also:
getUnit(), setValue(Object), doubleValue()

intValueList

public int[] intValueList()
                   throws org.opengis.parameter.InvalidParameterTypeException
Returns an ordered sequence of two or more integer values of an operation parameter list, usually used for counts. These integer values do not have an associated unit of measure.

Specified by:
intValueList in interface org.opengis.parameter.ParameterValue
Returns:
The sequence of values represented by this parameter.
Throws:
org.opengis.parameter.InvalidParameterTypeException - if the value is not an array of s.
See Also:
setValue(Object), intValue()

valueFile

public java.net.URI valueFile()
                       throws org.opengis.parameter.InvalidParameterTypeException
Returns a reference to a file or a part of a file containing one or more parameter values. When referencing a part of a file, that file must contain multiple identified parts, such as an XML encoded document. Furthermore, the referenced file or part of a file can reference another part of the same or different files, as allowed in XML documents.

Specified by:
valueFile in interface org.opengis.parameter.ParameterValue
Returns:
The reference to a file containing parameter values.
Throws:
org.opengis.parameter.InvalidParameterTypeException - if the value is not a reference to a file or an URI.
See Also:
getValue(), setValue(Object)

getValue

public java.lang.Object getValue()
Returns the parameter value as an object. The object type is typically a Double, Integer, Boolean, String, URI, or .

Specified by:
getValue in interface org.opengis.parameter.ParameterValue
Returns:
The parameter value as an object.
See Also:
setValue(Object)

setValue

public void setValue(double value,
                     javax.units.Unit unit)
              throws org.opengis.parameter.InvalidParameterValueException
Set the parameter value as a floating point and its associated unit.

Specified by:
setValue in interface org.opengis.parameter.ParameterValue
Parameters:
value - The parameter value.
unit - The unit for the specified value.
Throws:
org.opengis.parameter.InvalidParameterValueException - if the floating point type is inappropriate for this parameter, or if the value is illegal for some other reason (for example a value out of range).
See Also:
setValue(double), doubleValue(Unit)

setValue

public void setValue(double value)
              throws org.opengis.parameter.InvalidParameterValueException
Set the parameter value as a floating point. The unit, if any, stay unchanged.

Specified by:
setValue in interface org.opengis.parameter.ParameterValue
Parameters:
value - The parameter value.
Throws:
org.opengis.parameter.InvalidParameterValueException - if the floating point type is inappropriate for this parameter, or if the value is illegal for some other reason (for example a value out of range).
See Also:
setValue(double,Unit), doubleValue()

setValue

public void setValue(int value)
              throws org.opengis.parameter.InvalidParameterValueException
Set the parameter value as an integer.

Specified by:
setValue in interface org.opengis.parameter.ParameterValue
Parameters:
value - The parameter value.
Throws:
org.opengis.parameter.InvalidParameterValueException - if the integer type is inappropriate for this parameter, or if the value is illegal for some other reason (for example a value out of range).
See Also:
intValue()

setValue

public void setValue(boolean value)
              throws org.opengis.parameter.InvalidParameterValueException
Set the parameter value as a boolean.

Specified by:
setValue in interface org.opengis.parameter.ParameterValue
Parameters:
value - The parameter value.
Throws:
org.opengis.parameter.InvalidParameterValueException - if the boolean type is inappropriate for this parameter.
See Also:
booleanValue()

setValue

public void setValue(java.lang.Object value)
              throws org.opengis.parameter.InvalidParameterValueException
Set the parameter value as an object. The object type is typically a Double, Integer, Boolean, String, URI, or .

Specified by:
setValue in interface org.opengis.parameter.ParameterValue
Parameters:
value - The parameter value.
Throws:
org.opengis.parameter.InvalidParameterValueException - if the type of is inappropriate for this parameter, or if the value is illegal for some other reason (for example the value is numeric and out of range).
See Also:
getValue()

setValue

public void setValue(double[] values,
                     javax.units.Unit unit)
              throws org.opengis.parameter.InvalidParameterValueException
Set the parameter value as an array of floating point and their associated unit.

Specified by:
setValue in interface org.opengis.parameter.ParameterValue
Parameters:
values - The parameter values.
unit - The unit for the specified value.
Throws:
org.opengis.parameter.InvalidParameterValueException - if the floating point type is inappropriate for this parameter, or if the value is illegal for some other reason (for example a value out of range).

equals

public boolean equals(java.lang.Object object)
Compares the specified object with this parameter for equality.

Overrides:
equals in class AbstractParameter
Parameters:
object - The object to compare to .
Returns:
if both objects are equal.

hashCode

public int hashCode()
Returns a hash value for this parameter.

Overrides:
hashCode in class AbstractParameter
Returns:
The hash code value. This value doesn't need to be the same in past or future versions of this class.


Copyright © GeoTools. All Rights Reserved.