org.elkoserver.foundation.json
Class OptDouble

java.lang.Object
  extended by org.elkoserver.foundation.json.OptDouble

public class OptDouble
extends Object

An optional JSON message parameter of type double.


Field Summary
static OptDouble theMissingValue
          Singleton instance of OptDouble with the value not present.
 
Constructor Summary
OptDouble(double value)
          Constructor (value present).
 
Method Summary
 boolean present()
          Test if this parameter's value was present.
 double value()
          Get the double value of the parameter.
 double value(double defaultValue)
          Get the double value of this parameter, or a default value if the value is absent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theMissingValue

public static final OptDouble theMissingValue
Singleton instance of OptDouble with the value not present.

Constructor Detail

OptDouble

public OptDouble(double value)
Constructor (value present).

Parameters:
value - The value of the parameter.
Method Detail

value

public double value()
Get the double value of the parameter. It is an error if the value is absent.

Returns:
the (double) value.
Throws:
Error - if the value is not present.

value

public double value(double defaultValue)
Get the double value of this parameter, or a default value if the value is absent.

Parameters:
defaultValue - The default value for the parameter.
Returns:
the double value of this parameter if present, or the value of 'defaultValue' if not present.

present

public boolean present()
Test if this parameter's value was present.

Returns:
true if the parameter value was present, false if not.