Package org.geotools.parameter
Class Parameter<T>
Object
Formattable
AbstractParameter
Parameter<T>
- Type Parameters:
T- The value type.
- All Implemented Interfaces:
Serializable,Cloneable,GeneralParameterValue,ParameterValue<T>,Cloneable
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
- Author:
- Martin Desruisseaux (IRD), Jody Garnett (Refractions Research)
- See Also:
-
Field Summary
Fields inherited from class Formattable
SINGLE_LINE -
Constructor Summary
ConstructorsConstructorDescriptionParameter(ParameterDescriptor<T> descriptor) Constructs a parameter value from the specified descriptor.Parameter(ParameterDescriptor<T> descriptor, T value) Constructs a parameter value from the specified descriptor and value. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the boolean value of an operation parameter.clone()Returns a clone of this parameter.Constructs a parameter from the specified name and value.Constructs a parameter from the specified name and value.Constructs a parameter from the specified code list.doubleReturns the numeric value of the coordinate operation parameter with its associated unit of measure.doubledoubleValue(Unit<?> unit) Returns the numeric value of the coordinate operation parameter in the specified unit of measure.double[]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(Unit<?> unit) Returns an ordered sequence of numeric values in the specified unit of measure.static <T> TensureValidValue(ParameterDescriptor<T> descriptor, Object value) Ensures that the given value is valid according the specified parameter descriptor.booleanCompares the specified object with this parameter for equality.Returns the abstract definition of this parameter.Unit<?>getUnit()Returns the unit of measure of the parameter value.getValue()Returns the parameter value as an object.inthashCode()Returns a hash value for this parameter.intintValue()Returns the positive integer value of an operation parameter, usually used for a count.int[]Returns an ordered sequence of two or more integer values of an operation parameter list, usually used for counts.voidsetValue(boolean value) Sets the parameter value as a boolean.voidsetValue(double value) Sets the parameter value as a floating point.voidsetValue(double[] values, Unit<?> unit) Set the parameter value as an array of floating point and their associated unit.voidsetValue(double value, Unit<?> unit) Sets the parameter value as a floating point and its associated unit.voidsetValue(int value) Sets the parameter value as an integer.voidSet the parameter value as an object.Returns the string value of an operation parameter.Returns a reference to a file or a part of a file containing one or more parameter values.Methods inherited from class AbstractParameter
formatWKT, toString, writeMethods inherited from class Formattable
cleanupThreadLocals, toWKT, toWKT, toWKT, toWKT
-
Constructor Details
-
Parameter
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
Constructs a parameter value from the specified descriptor and value.- Parameters:
descriptor- The abstract definition of this parameter.value- The parameter value.- Throws:
InvalidParameterValueException- if the type ofvalueis 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 Details
-
create
Constructs a parameter from the specified name and value. This convenience constructor creates aDefaultParameterDescriptorobject. But if such an object is available, then the preferred way to get aParameterValueis to invokeParameterDescriptor.createValue().- Parameters:
name- The parameter name.value- The parameter value.- Returns:
- A new parameter instance for the given name and value.
- Since:
- 2.5
-
create
Constructs a parameter from the specified name and value. This convenience constructor creates aDefaultParameterDescriptorobject. But if such an object is available, then the preferred way to get aParameterValueis to invokeParameterDescriptor.createValue().- Parameters:
name- The parameter name.value- The parameter value.unit- The unit for the parameter value.- Returns:
- A new parameter instance for the given name and value.
- Since:
- 2.5
-
create
Constructs a parameter from the specified code list. This convenience constructor creates aDefaultParameterDescriptorobject. But if such an object is available, then the preferred way to get aParameterValueis to invokeParameterDescriptor.createValue().- Type Parameters:
T- The parameter type.- Parameters:
name- The parameter name.type- The parameter type.value- The parameter value.- Returns:
- A new parameter instance for the given name and value.
- Since:
- 2.5
-
ensureValidValue
public static <T> T ensureValidValue(ParameterDescriptor<T> descriptor, Object value) throws InvalidParameterValueException Ensures that the given value is valid according the specified parameter descriptor. This convenience method ensures thatvalueis 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.This method is similar to
Parameters#isValid(descriptor, value)except that the exception contains an error message formatted with a description of the failure reason.- Type Parameters:
T- The type of parameter value. The givenvalueshould typically be an instance of this class. This is not required by this method signature but is checked by this method implementation.- Parameters:
descriptor- The parameter descriptor to check against.value- The value to check, ornull.- Returns:
- The value casted to the descriptor parameterized type.
- Throws:
InvalidParameterValueException- if the parameter value is invalid.
-
getDescriptor
Returns the abstract definition of this parameter.- Specified by:
getDescriptorin interfaceGeneralParameterValue- Specified by:
getDescriptorin interfaceParameterValue<T>- Overrides:
getDescriptorin classAbstractParameter- Returns:
- The abstract definition of this parameter or group of parameters.
-
getUnit
public Unit<?> getUnit()Returns the unit of measure of the parameter value. If the parameter value has no unit (for example because it is aStringtype), then this method returnsnull. Note that "no unit" doesn't means "dimensionless".- Specified by:
getUnitin interfaceParameterValue<T>- Returns:
- The unit of measure, or
nullif none. - See Also:
-
doubleValue
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:
doubleValuein interfaceParameterValue<T>- Parameters:
unit- The unit of measure for the value to be returned.- Returns:
- The numeric value represented by this parameter after conversion to type
doubleand conversion tounit. - Throws:
InvalidParameterTypeException- if the value is not a numeric type.IllegalArgumentException- if the specified unit is invalid for this parameter.- See Also:
-
doubleValue
Returns the numeric value of the coordinate operation parameter with its associated unit of measure.- Specified by:
doubleValuein interfaceParameterValue<T>- Returns:
- The numeric value represented by this parameter after conversion to type
double. - Throws:
InvalidParameterTypeException- if the value is not a numeric type.- See Also:
-
intValue
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:
intValuein interfaceParameterValue<T>- Returns:
- The numeric value represented by this parameter after conversion to type
int. - Throws:
InvalidParameterTypeException- if the value is not an integer type.- See Also:
-
booleanValue
Returns the boolean value of an operation parameter. A boolean value does not have an associated unit of measure.- Specified by:
booleanValuein interfaceParameterValue<T>- Returns:
- The boolean value represented by this parameter.
- Throws:
InvalidParameterTypeException- if the value is not a boolean type.- See Also:
-
stringValue
Returns the string value of an operation parameter. A string value does not have an associated unit of measure.- Specified by:
stringValuein interfaceParameterValue<T>- Returns:
- The string value represented by this parameter.
- Throws:
InvalidParameterTypeException- if the value is not a string.- See Also:
-
doubleValueList
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:
doubleValueListin interfaceParameterValue<T>- 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
doubleand conversion tounit. - Throws:
InvalidParameterTypeException- if the value is not an array ofdoubles.IllegalArgumentException- if the specified unit is invalid for this parameter.- See Also:
-
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.- Specified by:
doubleValueListin interfaceParameterValue<T>- Returns:
- The sequence of values represented by this parameter.
- Throws:
InvalidParameterTypeException- if the value is not an array ofdoubles.- See Also:
-
intValueList
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:
intValueListin interfaceParameterValue<T>- Returns:
- The sequence of values represented by this parameter.
- Throws:
InvalidParameterTypeException- if the value is not an array ofints.- See Also:
-
valueFile
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:
valueFilein interfaceParameterValue<T>- Returns:
- The reference to a file containing parameter values.
- Throws:
InvalidParameterTypeException- if the value is not a reference to a file or an URI.- See Also:
-
getValue
Returns the parameter value as an object. The object type is typically aDouble,Integer,Boolean,String,URI,double[]orint[].- Specified by:
getValuein interfaceParameterValue<T>- Returns:
- The parameter value as an object.
- See Also:
-
setValue
Sets the parameter value as a floating point and its associated unit.- Specified by:
setValuein interfaceParameterValue<T>- Parameters:
value- The parameter value.unit- The unit for the specified value.- Throws:
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
Sets the parameter value as a floating point. The unit, if any, stay unchanged.- Specified by:
setValuein interfaceParameterValue<T>- Parameters:
value- The parameter value.- Throws:
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
Sets the parameter value as an integer.- Specified by:
setValuein interfaceParameterValue<T>- Parameters:
value- The parameter value.- Throws:
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:
-
setValue
Sets the parameter value as a boolean.- Specified by:
setValuein interfaceParameterValue<T>- Parameters:
value- The parameter value.- Throws:
InvalidParameterValueException- if the boolean type is inappropriate for this parameter.- See Also:
-
setValue
Set the parameter value as an object. The object type is typically aDouble,Integer,Boolean,String,URI,double[]orint[].- Specified by:
setValuein interfaceParameterValue<T>- Parameters:
value- The parameter value.- Throws:
InvalidParameterValueException- if the type ofvalueis 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:
-
setValue
Set the parameter value as an array of floating point and their associated unit.- Specified by:
setValuein interfaceParameterValue<T>- Parameters:
values- The parameter values.unit- The unit for the specified value.- Throws:
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
Compares the specified object with this parameter for equality.- Overrides:
equalsin classAbstractParameter- Parameters:
object- The object to compare tothis.- Returns:
trueif both objects are equal.
-
hashCode
public int hashCode()Returns a hash value for this parameter.- Overrides:
hashCodein classAbstractParameter- Returns:
- The hash code value. This value doesn't need to be the same in past or future versions of this class.
-
clone
Returns a clone of this parameter.- Specified by:
clonein interfaceCloneable- Specified by:
clonein interfaceGeneralParameterValue- Specified by:
clonein interfaceParameterValue<T>- Overrides:
clonein classAbstractParameter- Returns:
- A copy of this parameter value or group.
- See Also:
-