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.
ParameterRealValueis slightly more efficient thanParameterValuesince it avoid the creation ofDoubleobjects.- 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 booleanbooleanValue()Returnstrueif the value is different from 0,falseotherwise.FloatParameterclone()Returns a clone of this parameter.doubledoubleValue()Returns 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[]doubleValueList()Wraps the value in an array of length 1.double[]doubleValueList(Unit<?> unit)Wraps the value in an array of length 1.booleanequals(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.DoublegetValue()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[]intValueList()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.voidsetValue(Object value)Set the parameter value as aDoubleobject.StringstringValue()Returns the string representation of the value.URIvalueFile()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:
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:
ParameterValue.doubleValue(),ParameterValue.doubleValueList(javax.measure.Unit<?>),ParameterValue.getValue()
-
doubleValue
public double doubleValue(Unit<?> unit) throws IllegalArgumentExceptionReturns 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:
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:
doubleValuein 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:
intValuein 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()
Returnstrueif the value is different from 0,falseotherwise.- Specified by:
booleanValuein 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:
stringValuein interfaceParameterValue<Double>- Returns:
- The string value represented by this parameter.
- See Also:
ParameterValue.getValue(),ParameterValue.setValue(Object)
-
doubleValueList
public double[] doubleValueList(Unit<?> unit) throws IllegalArgumentExceptionWraps 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:
ParameterValue.getUnit(),ParameterValue.setValue(double[],Unit),ParameterValue.doubleValue(Unit)
-
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:
ParameterValue.getUnit(),ParameterValue.setValue(Object),ParameterValue.doubleValue()
-
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:
ParameterValue.setValue(Object),ParameterValue.intValue()
-
valueFile
public URI valueFile() throws InvalidParameterTypeException
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:
ParameterValue.getValue(),ParameterValue.setValue(Object)
-
getValue
public Double getValue()
Returns the parameter value as {Double,- Specified by:
getValuein interfaceParameterValue<Double>- Returns:
- The parameter value as an object.
- See Also:
ParameterValue.setValue(Object)
-
setValue
public void setValue(double value, Unit<?> unit) throws InvalidParameterValueExceptionSet 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:
ParameterValue.setValue(double),ParameterValue.doubleValue(Unit)
-
setValue
public void setValue(double value) throws InvalidParameterValueExceptionSet 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:
ParameterValue.setValue(double,Unit),ParameterValue.doubleValue()
-
setValue
public void setValue(int value) throws InvalidParameterValueExceptionSet 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:
ParameterValue.intValue()
-
setValue
public void setValue(boolean value) throws InvalidParameterValueExceptionSet 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:
ParameterValue.booleanValue()
-
setValue
public void setValue(Object value) throws InvalidParameterValueException
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:
ParameterValue.getValue()
-
setValue
public void setValue(double[] values, Unit<?> unit) throws InvalidParameterValueExceptionAlways 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
public boolean equals(Object object)
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
public FloatParameter 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:
Object.clone()
-
-