Package org.geotools.parameter
Class FloatParameter
Object
Formattable
AbstractParameter
FloatParameter
- All Implemented Interfaces:
Serializable
,Cloneable
,GeneralParameterValue
,ParameterValue<Double>
,Cloneable
A parameter value as a floating point (double precision) number. This class provides the same functionalities than
Parameter
, except that:
- Values are always floating point numbers of type
double
. - Units are the same than the default units.
ParameterRealValue
is slightly more efficient than ParameterValue
since it avoid the creation of Double
objects.- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
- See Also:
-
Field Summary
Fields inherited from class Formattable
SINGLE_LINE
-
Constructor Summary
ConstructorsConstructorDescriptionFloatParameter
(ParameterDescriptor<Double> descriptor) Constructs a parameter from the specified descriptor.FloatParameter
(ParameterDescriptor<Double> descriptor, double value) Constructs a parameter from the specified descriptor and value. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if the value is different from 0,false
otherwise.clone()
Returns a clone of this parameter.double
Returns the numeric value of the coordinate operation parameter with its associated unit of measure.double
doubleValue
(Unit<?> unit) Returns the numeric value of the coordinate operation parameter in the specified unit of measure.double[]
Wraps the value in an array of length 1.double[]
doubleValueList
(Unit<?> unit) Wraps the value in an array of length 1.boolean
Compares 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 {Double
,int
hashCode()
Returns a hash value for this parameter.int
intValue()
Returns the numeric value rounded to the nearest integer.int[]
Wraps the value in an array of length 1.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, Unit<?> unit) Always throws an exception, since this parameter is not an array.void
setValue
(double value, 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
Set the parameter value as aDouble
object.Returns the string representation of the value.Always throws an exception, since this parameter is not an URI.Methods inherited from class AbstractParameter
formatWKT, toString, write
Methods inherited from class Formattable
cleanupThreadLocals, toWKT, toWKT, toWKT, toWKT
-
Constructor Details
-
FloatParameter
Constructs a parameter from the specified descriptor. The descriptor value class must beDouble.class
.- Parameters:
descriptor
- The abstract definition of this parameter.- Throws:
IllegalArgumentException
- if the value class is notDouble.class
.
-
FloatParameter
Constructs a parameter from the specified descriptor and value. This convenience constructor is equivalents to the one-argument constructor followed by a call tosetValue(double)
.- Parameters:
descriptor
- The abstract definition of this parameter.value
- The parameter value.- Throws:
IllegalArgumentException
- if the value class is notDouble.class
.
-
-
Method Details
-
getDescriptor
Returns the abstract definition of this parameter.- Specified by:
getDescriptor
in interfaceGeneralParameterValue
- Specified by:
getDescriptor
in interfaceParameterValue<Double>
- Overrides:
getDescriptor
in 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. The default implementation always delegates toParameterDescriptor.getUnit()
.- Specified by:
getUnit
in interfaceParameterValue<Double>
- Returns:
- The unit of measure, or
null
if 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:
doubleValue
in interfaceParameterValue<Double>
- Parameters:
unit
- The unit of measure for the value to be returned.- Returns:
- The numeric value represented by this parameter after conversion to type
double
and conversion tounit
. - Throws:
IllegalArgumentException
- if the specified unit is invalid for this parameter.- See Also:
-
doubleValue
public double doubleValue()Returns the numeric value of the coordinate operation parameter with its associated unit of measure.- Specified by:
doubleValue
in interfaceParameterValue<Double>
- Returns:
- The numeric value represented by this parameter after conversion to type
double
. - See Also:
-
intValue
public int intValue()Returns the numeric value rounded to the nearest integer.- Specified by:
intValue
in interfaceParameterValue<Double>
- Returns:
- The numeric value represented by this parameter after conversion to type
int
. - See Also:
-
booleanValue
public boolean booleanValue()Returnstrue
if the value is different from 0,false
otherwise.- Specified by:
booleanValue
in interfaceParameterValue<Double>
- Returns:
- The boolean value represented by this parameter.
- See Also:
-
stringValue
Returns the string representation of the value.- Specified by:
stringValue
in interfaceParameterValue<Double>
- Returns:
- The string value represented by this parameter.
- See Also:
-
doubleValueList
Wraps the value in an array of length 1.- Specified by:
doubleValueList
in interfaceParameterValue<Double>
- 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
double
and conversion tounit
. - Throws:
IllegalArgumentException
- if the specified unit is invalid for this parameter.- See Also:
-
doubleValueList
public double[] doubleValueList()Wraps the value in an array of length 1.- Specified by:
doubleValueList
in interfaceParameterValue<Double>
- Returns:
- The sequence of values represented by this parameter.
- See Also:
-
intValueList
public int[] intValueList()Wraps the value in an array of length 1.- Specified by:
intValueList
in interfaceParameterValue<Double>
- Returns:
- The sequence of values represented by this parameter.
- See Also:
-
valueFile
Always throws an exception, since this parameter is not an URI.- Specified by:
valueFile
in interfaceParameterValue<Double>
- Returns:
- Never return.
- Throws:
InvalidParameterTypeException
- The value is not a reference to a file or an URI.- See Also:
-
getValue
Returns the parameter value as {Double
,- Specified by:
getValue
in interfaceParameterValue<Double>
- Returns:
- The parameter value as an object.
- See Also:
-
setValue
Set the parameter value as a floating point and its associated unit.- Specified by:
setValue
in interfaceParameterValue<Double>
- Parameters:
value
- The parameter value.unit
- The unit for the specified value.- Throws:
InvalidParameterValueException
- if the value is illegal for some reason (for example a value out of range).- See Also:
-
setValue
Set the parameter value as a floating point.- Specified by:
setValue
in interfaceParameterValue<Double>
- Parameters:
value
- The parameter value.- Throws:
InvalidParameterValueException
- if the value is illegal for some reason (for example a value out of range).- See Also:
-
setValue
Set the parameter value as an integer.- Specified by:
setValue
in interfaceParameterValue<Double>
- Parameters:
value
- The parameter value.- Throws:
InvalidParameterValueException
- if the value is illegal for some reason (for example a value out of range).- See Also:
-
setValue
Set the parameter value as a boolean.- Specified by:
setValue
in interfaceParameterValue<Double>
- Parameters:
value
- The parameter value.- Throws:
InvalidParameterValueException
- if the boolean type is inappropriate for this parameter.- See Also:
-
setValue
Set the parameter value as aDouble
object.- Specified by:
setValue
in interfaceParameterValue<Double>
- Parameters:
value
- The parameter value.- Throws:
InvalidParameterValueException
- if the type ofvalue
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:
-
setValue
Always throws an exception, since this parameter is not an array.- Specified by:
setValue
in interfaceParameterValue<Double>
- 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:
equals
in classAbstractParameter
- Parameters:
object
- The object to compare tothis
.- Returns:
true
if both objects are equal.
-
hashCode
public int hashCode()Returns a hash value for this parameter.- Overrides:
hashCode
in 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:
clone
in interfaceCloneable
- Specified by:
clone
in interfaceGeneralParameterValue
- Specified by:
clone
in interfaceParameterValue<Double>
- Overrides:
clone
in classAbstractParameter
- Returns:
- A copy of this parameter value or group.
- See Also:
-