org.elkoserver.foundation.json
Class OptString

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

public class OptString
extends Object

An optional JSON message parameter of type String.


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

Constructor Detail

OptString

public OptString(String value)
Constructor (value present).

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

value

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

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

value

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

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