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 TypeMethodDescriptionbooleanReturnstrueif the value is different from 0,falseotherwise.clone()Returns a clone of this parameter.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[]Wraps the value in an array of length 1.double[]doubleValueList(Unit<?> unit) Wraps the value in an array of length 1.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 {Double,inthashCode()Returns a hash value for this parameter.intintValue()Returns the numeric value rounded to the nearest integer.int[]Wraps the value in an array of length 1.voidsetValue(boolean value) Set the parameter value as a boolean.voidsetValue(double value) Set the parameter value as a floating point.voidsetValue(double[] values, Unit<?> unit) Always throws an exception, since this parameter is not an array.voidsetValue(double value, Unit<?> unit) Set the parameter value as a floating point and its associated unit.voidsetValue(int value) Set the parameter value as an integer.voidSet the parameter value as aDoubleobject.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, writeMethods 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:
getDescriptorin interfaceGeneralParameterValue- Specified by:
getDescriptorin interfaceParameterValue<Double>- 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. The default implementation always delegates toParameterDescriptor.getUnit().- Specified by:
getUnitin interfaceParameterValue<Double>- 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<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
doubleand 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:
doubleValuein 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:
intValuein interfaceParameterValue<Double>- Returns:
- The numeric value represented by this parameter after conversion to type
int. - See Also:
-
booleanValue
public boolean booleanValue()Returnstrueif the value is different from 0,falseotherwise.- Specified by:
booleanValuein interfaceParameterValue<Double>- Returns:
- The boolean value represented by this parameter.
- See Also:
-
stringValue
Returns the string representation of the value.- Specified by:
stringValuein interfaceParameterValue<Double>- Returns:
- The string value represented by this parameter.
- See Also:
-
doubleValueList
Wraps the value in an array of length 1.- Specified by:
doubleValueListin 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
doubleand 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:
doubleValueListin 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:
intValueListin 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:
valueFilein 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:
getValuein 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:
setValuein 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:
setValuein 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:
setValuein 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:
setValuein 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 aDoubleobject.- Specified by:
setValuein interfaceParameterValue<Double>- 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
Always throws an exception, since this parameter is not an array.- Specified by:
setValuein 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:
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<Double>- Overrides:
clonein classAbstractParameter- Returns:
- A copy of this parameter value or group.
- See Also:
-