org.elkoserver.foundation.json
Class OptInteger

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

public class OptInteger
extends Object

An optional JSON message parameter of type int.


Field Summary
static OptInteger theMissingValue
          Singleton instance of OptInteger with the value not present.
 
Constructor Summary
OptInteger(int value)
          Constructor (value present).
 
Method Summary
 boolean present()
          Test if this parameter's value was present.
 int value()
          Get the int value of the parameter.
 int value(int defaultValue)
          Get the int 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 OptInteger theMissingValue
Singleton instance of OptInteger with the value not present.

Constructor Detail

OptInteger

public OptInteger(int value)
Constructor (value present).

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

value

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

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

value

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

Parameters:
defaultValue - The default value for the parameter.
Returns:
the int 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.