Package org.geotools.parameter
Class FloatParameter
- Object
-
- Formattable
-
- AbstractParameter
-
- FloatParameter
-
- All Implemented Interfaces:
Serializable
,Cloneable
,GeneralParameterValue
,ParameterValue<Double>
,Cloneable
public class FloatParameter extends AbstractParameter implements ParameterValue<Double>
A parameter value as a floating point (double precision) number. This class provides the same functionalities thanParameter
, except that:- Values are always floating point numbers of type
double
. - Units are the same than the default units.
ParameterRealValue
is slightly more efficient thanParameterValue
since it avoid the creation ofDouble
objects.- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
- See Also:
DefaultParameterDescriptor
,ParameterGroup
, Serialized Form
-
-
Field Summary
-
Fields inherited from class Formattable
SINGLE_LINE
-
-
Constructor Summary
Constructors Constructor Description FloatParameter(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
booleanValue()
Returnstrue
if the value is different from 0,false
otherwise.FloatParameter
clone()
Returns a clone of this parameter.double
doubleValue()
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[]
doubleValueList()
Wraps the value in an array of length 1.double[]
doubleValueList(Unit<?> unit)
Wraps the value in an array of length 1.boolean
equals(Object object)
Compares the specified object with this parameter for equality.ParameterDescriptor<Double>
getDescriptor()
Returns the abstract definition of this parameter.Unit<?>
getUnit()
Returns the unit of measure of the parameter value.Double
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[]
intValueList()
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
setValue(Object value)
Set the parameter value as aDouble
object.String
stringValue()
Returns the string representation of the value.URI
valueFile()
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 Detail
-
FloatParameter
public FloatParameter(ParameterDescriptor<Double> descriptor)
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
public FloatParameter(ParameterDescriptor<Double> descriptor, double value)
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 Detail
-
getDescriptor
public ParameterDescriptor<Double> 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:
ParameterValue.doubleValue()
,ParameterValue.doubleValueList(javax.measure.Unit<?>)
,ParameterValue.getValue()
-
doubleValue
public double doubleValue(Unit<?> unit) throws IllegalArgumentException
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:
ParameterValue.getUnit()
,ParameterValue.setValue(double,Unit)
,ParameterValue.doubleValueList(Unit)
-
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:
ParameterValue.getUnit()
,ParameterValue.setValue(double)
,ParameterValue.doubleValueList(javax.measure.Unit<?>)
-
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:
ParameterValue.setValue(int)
,ParameterValue.intValueList()
-
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:
ParameterValue.setValue(boolean)
-
stringValue
public String stringValue()
Returns the string representation of the value.- Specified by:
stringValue
in interfaceParameterValue<Double>
- Returns:
- The string value represented by this parameter.
- See Also:
ParameterValue.getValue()
,ParameterValue.setValue(Object)
-
doubleValueList
public double[] doubleValueList(Unit<?> unit) throws IllegalArgumentException
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:
ParameterValue.getUnit()
,ParameterValue.setValue(double[],Unit)
,ParameterValue.doubleValue(Unit)
-
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:
ParameterValue.getUnit()
,ParameterValue.setValue(Object)
,ParameterValue.doubleValue()
-
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:
ParameterValue.setValue(Object)
,ParameterValue.intValue()
-
valueFile
public URI valueFile() throws InvalidParameterTypeException
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:
ParameterValue.getValue()
,ParameterValue.setValue(Object)
-
getValue
public Double getValue()
Returns the parameter value as {Double
,- Specified by:
getValue
in interfaceParameterValue<Double>
- Returns:
- The parameter value as an object.
- See Also:
ParameterValue.setValue(Object)
-
setValue
public void setValue(double value, Unit<?> unit) throws InvalidParameterValueException
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:
ParameterValue.setValue(double)
,ParameterValue.doubleValue(Unit)
-
setValue
public void setValue(double value) throws InvalidParameterValueException
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:
ParameterValue.setValue(double,Unit)
,ParameterValue.doubleValue()
-
setValue
public void setValue(int value) throws InvalidParameterValueException
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:
ParameterValue.intValue()
-
setValue
public void setValue(boolean value) throws InvalidParameterValueException
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:
ParameterValue.booleanValue()
-
setValue
public void setValue(Object value) throws InvalidParameterValueException
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:
ParameterValue.getValue()
-
setValue
public void setValue(double[] values, Unit<?> unit) throws InvalidParameterValueException
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
public boolean equals(Object object)
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
public FloatParameter 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:
Object.clone()
-
-