org.geotools.parameter
Class FloatParameter

Object
  extended by Formattable
      extended by AbstractParameter
          extended by FloatParameter
All Implemented Interfaces:
Serializable, Cloneable, GeneralParameterValue, ParameterValue<Double>

public class FloatParameter
extends AbstractParameter
implements ParameterValue<Double>

A parameter value as a floating point (double precision) number. This class provides the same functionalities than Parameter, except that:

When those conditions are meet, ParameterRealValue is slightly more efficient than ParameterValue since it avoid the creation of Double 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
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
 boolean booleanValue()
          Returns true 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 a Double 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
 
Methods inherited from class Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FloatParameter

public FloatParameter(ParameterDescriptor<Double> descriptor)
Constructs a parameter from the specified descriptor. The descriptor value class must be Double.class.

Parameters:
descriptor - The abstract definition of this parameter.
Throws:
IllegalArgumentException - if the value class is not Double.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 to setValue(double).

Parameters:
descriptor - The abstract definition of this parameter.
value - The parameter value.
Throws:
IllegalArgumentException - if the value class is not Double.class.
Method Detail

getDescriptor

public ParameterDescriptor<Double> getDescriptor()
Returns the abstract definition of this parameter.

Specified by:
getDescriptor in interface GeneralParameterValue
Specified by:
getDescriptor in interface ParameterValue<Double>
Overrides:
getDescriptor in class AbstractParameter
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 to ParameterDescriptor.getUnit().

Specified by:
getUnit in interface ParameterValue<Double>
Returns:
The unit of measure, or null if none.
See Also:
ParameterValue.doubleValue(), ParameterValue.doubleValueList(javax.measure.unit.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 interface ParameterValue<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 to unit.
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 interface ParameterValue<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.Unit)

intValue

public int intValue()
Returns the numeric value rounded to the nearest integer.

Specified by:
intValue in interface ParameterValue<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()
Returns true if the value is different from 0, false otherwise.

Specified by:
booleanValue in interface ParameterValue<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 interface ParameterValue<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 interface ParameterValue<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 to unit.
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 interface ParameterValue<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 interface ParameterValue<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 interface ParameterValue<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 interface ParameterValue<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 interface ParameterValue<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 interface ParameterValue<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 interface ParameterValue<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 interface ParameterValue<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 a Double object.

Specified by:
setValue in interface ParameterValue<Double>
Parameters:
value - The parameter value.
Throws:
InvalidParameterValueException - if the type of value 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 interface ParameterValue<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 class AbstractParameter
Parameters:
object - The object to compare to this.
Returns:
true if both objects are equal.

hashCode

public int hashCode()
Returns a hash value for this parameter.

Overrides:
hashCode in class AbstractParameter
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 interface GeneralParameterValue
Specified by:
clone in interface ParameterValue<Double>
Overrides:
clone in class AbstractParameter
Returns:
A copy of this parameter value or group.
See Also:
Object.clone()


Copyright © 1996-2014 Geotools. All Rights Reserved.