org.eigenbase.util.property
Class DoubleProperty

java.lang.Object
  extended by org.eigenbase.util.property.Property
      extended by org.eigenbase.util.property.DoubleProperty

public class DoubleProperty
extends Property

Definition and accessor for a double-precision property.

Since:
July 5, 2005
Version:
$Id: //open/dev/farrago/src/org/eigenbase/util/property/DoubleProperty.java#9 $
Author:
jhyde

Field Summary
private  double maxValue
           
private  double minValue
           
 
Fields inherited from class org.eigenbase.util.property.Property
properties
 
Constructor Summary
DoubleProperty(Properties properties, String path)
          Creates a Double property which has no default value.
DoubleProperty(Properties properties, String path, double defaultValue)
          Creates a Double property.
DoubleProperty(Properties properties, String path, double minValue, double maxValue)
          Creates a Double property which has no default value.
DoubleProperty(Properties properties, String path, double defaultValue, double minValue, double maxValue)
          Creates a Double property.
 
Method Summary
 double get()
          Retrieves the value of this double property according to these rules.
 double get(double defaultValue)
          Retrieves the value of this double property.
private  double limit(double value)
          Returns value limited to the range [minValue, maxValue].
private  double noValue()
          Returns 0.0 if that value is in the range [minValue, maxValue].
 double set(double value)
          Sets the value of this double property.
 
Methods inherited from class org.eigenbase.util.property.Property
addTrigger, booleanValue, getDefaultValue, getInternal, getPath, getString, isSet, onChange, removeTrigger, setString, stringValue, toBoolean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minValue

private final double minValue

maxValue

private final double maxValue
Constructor Detail

DoubleProperty

public DoubleProperty(Properties properties,
                      String path,
                      double defaultValue)
Creates a Double property.

Parameters:
properties - Properties object which holds values for this property.
path - Name by which this property is serialized to a properties file, for example "com.acme.trace.Verbosity".
defaultValue - Default value.

DoubleProperty

public DoubleProperty(Properties properties,
                      String path)
Creates a Double property which has no default value.

Parameters:
properties - Properties object which holds values for this property.
path - Name by which this property is serialized to a properties file, for example "com.acme.trace.Verbosity".

DoubleProperty

public DoubleProperty(Properties properties,
                      String path,
                      double defaultValue,
                      double minValue,
                      double maxValue)
Creates a Double property.

Parameters:
properties - Properties object which holds values for this property.
path - Name by which this property is serialized to a properties file, for example "com.acme.trace.Verbosity".
defaultValue - Default value.
Throws:
IllegalArgumentException - if defaultValue is not in the range [minValue, maxValue].

DoubleProperty

public DoubleProperty(Properties properties,
                      String path,
                      double minValue,
                      double maxValue)
Creates a Double property which has no default value.

Parameters:
properties - Properties object which holds values for this property.
path - Name by which this property is serialized to a properties file, for example "com.acme.trace.Verbosity".
Method Detail

get

public double get()
Retrieves the value of this double property according to these rules.


get

public double get(double defaultValue)
Retrieves the value of this double property. If the property has no value, returns the default value. If there is no default value, returns the given default value. In all cases, the returned value is limited to the min/max value range given during construction.


set

public double set(double value)
Sets the value of this double property. The value is limited to the min/max range given during construction.

Returns:
the previous value, or if not set: the default value. If no default value exists, 0.0 if that value is in the range [minValue, maxValue], or minValue if 0.0 is not in the range

limit

private double limit(double value)
Returns value limited to the range [minValue, maxValue].

Parameters:
value - the value to limit
Returns:
value limited to the range [minValue, maxValue].

noValue

private double noValue()
Returns 0.0 if that value is in the range [minValue, maxValue]. Otherwise, returns minValue.