laser.util.argument
Class BooleanOption

java.lang.Object
  extended by laser.util.argument.Argument
      extended by laser.util.argument.Option
          extended by laser.util.argument.BooleanOption
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class BooleanOption
extends Option

The BooleanOption class defines a user-defined option of type Boolean. Its default will be the given value or false if unspecified.

Author:
Heather M. Conboy (laser-software@cs.umass.edu)
See Also:
Serialized Form

Field Summary
static boolean BOOLEAN_DEFAULT
          If the default value is unspecified then this will be used
static boolean BOOLEAN_REPEATABLE_DEFAULT
          The default setting for isRepeatable
 
Fields inherited from class laser.util.argument.Option
DEFAULT_PREFIX, DEFAULT_SUFFIX, NOT_REPEATABLE_CHAR, REPEATABLE_CHAR
 
Fields inherited from class laser.util.argument.Argument
FIRST, HELP_DEFAULT, HELP_PREFIX, REPEATABLE_DEFAULT, TYPE_PREFIX, TYPE_SUFFIX
 
Constructor Summary
BooleanOption(java.lang.String name)
          Creates a new BooleanOption with all of the default settings.
BooleanOption(java.lang.String name, boolean defaultValue)
          Creates a new BooleanOption with the given name and default value.
BooleanOption(java.lang.String name, boolean defaultValue, java.lang.String helpMessage)
          Creates a new BooleanOption with the given name and default value.
 
Method Summary
 void check()
          Checks whether or not the user correctly specified a value for this argument.
 java.lang.Object clone()
          Clones this Object.
protected  java.lang.Object fromStringValue(java.lang.String value)
          Parses a String value into an Object appropriate for the type NOTE: In Java when parsing a string to a boolean value, true ( case insensitive ) is true and ANYTHING else is false.
 java.lang.Boolean getBooleanDefault()
          Gets the default value of this BooleanOption.
 java.lang.Boolean getBooleanValue()
          Gets the first value of this BooleanOption.
 java.lang.Boolean getBooleanValue(int index)
          Gets the value of this BooleanOption at the specified index.
protected  java.lang.String getDefaultString()
          Gets the default string which describes the default value of this BooleanOption.
 java.lang.Class getType()
          Gets the type of this Option.
 void setValue(java.lang.Boolean value)
          Sets the value of this BooleanOption to the specified value.
 
Methods inherited from class laser.util.argument.Option
getDefault, getHelp, getRepeatableChar, getValue, numberOfValues
 
Methods inherited from class laser.util.argument.Argument
checkValue, clear, equals, getHelpMessage, getName, getValue, getValues, initialize, isRepeatable, numberOfActualValues, parseValue, save, setValue, toString, toStringValue, toStringValue
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BOOLEAN_DEFAULT

public static final boolean BOOLEAN_DEFAULT
If the default value is unspecified then this will be used

See Also:
Constant Field Values

BOOLEAN_REPEATABLE_DEFAULT

public static final boolean BOOLEAN_REPEATABLE_DEFAULT
The default setting for isRepeatable

See Also:
Constant Field Values
Constructor Detail

BooleanOption

public BooleanOption(java.lang.String name,
                     boolean defaultValue,
                     java.lang.String helpMessage)
Creates a new BooleanOption with the given name and default value. It will be single-valued. The help message will be made available to the user upon request.

Parameters:
name - The name for the option
defaultValue - The value of the option if the user doesn't specify a value
helpMessage - The help message to report to the user upon request
See Also:
BooleanOption.BOOLEAN_REPEATABLE_DEFAULT

BooleanOption

public BooleanOption(java.lang.String name,
                     boolean defaultValue)
Creates a new BooleanOption with the given name and default value. It will be single-valued. It will have the default setting for helpMessage.

Parameters:
name - The name for the option
defaultValue - The value of the option if the user doesn't specify a value
See Also:
BooleanOption.BOOLEAN_REPEATABLE_DEFAULT, Argument.HELP_DEFAULT

BooleanOption

public BooleanOption(java.lang.String name)
Creates a new BooleanOption with all of the default settings.

Parameters:
name - The name for the option
See Also:
BooleanOption.BOOLEAN_DEFAULT, BooleanOption.BOOLEAN_REPEATABLE_DEFAULT, Argument.HELP_DEFAULT
Method Detail

setValue

public void setValue(java.lang.Boolean value)
              throws ArgumentFormatException,
                     ArgumentNotRepeatableException
Sets the value of this BooleanOption to the specified value.

Parameters:
value - The value for this BooleanOption
Throws:
ArgumentFormatException - if the value is incorrectly formatted
ArgumentNotRepeatableException - if the user attempted to set the value of a single-valued argument multiple times

getBooleanDefault

public java.lang.Boolean getBooleanDefault()
Gets the default value of this BooleanOption.

Returns:
The default value

getBooleanValue

public java.lang.Boolean getBooleanValue()
Gets the first value of this BooleanOption.

Returns:
The first value

getBooleanValue

public java.lang.Boolean getBooleanValue(int index)
Gets the value of this BooleanOption at the specified index.

NOTE: All options will have at least one value at index Argument.FIRST.

Parameters:
index - The index of the value
Returns:
The boolean value

fromStringValue

protected java.lang.Object fromStringValue(java.lang.String value)
                                    throws ArgumentFormatException
Parses a String value into an Object appropriate for the type NOTE: In Java when parsing a string to a boolean value, true ( case insensitive ) is true and ANYTHING else is false.

Specified by:
fromStringValue in class Argument
Parameters:
value - the value
Returns:
the parsed Object
Throws:
ArgumentFormatException - if the value is malformed
See Also:
laser.util.argument.Argument.toStringValue(Object)

getType

public java.lang.Class getType()
Gets the type of this Option.

Specified by:
getType in class Argument
Returns:
The type description

getDefaultString

protected java.lang.String getDefaultString()
Gets the default string which describes the default value of this BooleanOption.

Specified by:
getDefaultString in class Option
Returns:
The default string description

check

public void check()
           throws ArgumentFormatException
Checks whether or not the user correctly specified a value for this argument.

Specified by:
check in class Argument
Throws:
ArgumentFormatException

clone

public java.lang.Object clone()
Clones this Object.

Specified by:
clone in class Argument
Returns:
The clone