laser.util.argument
Class LongOption

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

public class LongOption
extends Option

The LongOption class defines a user-defined option of type Long. Its default will be the given value or zero (0) if unspecified.

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

Field Summary
static long LONG_DEFAULT
          If the default value is unspecified then this will be used
 
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
LongOption(java.lang.String name)
          Creates a new LongOption with all of the default settings.
LongOption(java.lang.String name, long defaultValue)
          Creates a new LongOption with the given name and default value.
LongOption(java.lang.String name, long defaultValue, boolean isRepeatable, java.lang.String helpMessage)
          Creates a new LongOption 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
protected  java.lang.String getDefaultString()
          Gets the default string which describes the default value of this LongOption.
 java.lang.Long getLongValue()
          Gets the first value of this LongOption.
 java.lang.Long getLongValue(int index)
          Gets the value of this LongOption at the specified index.
 java.lang.Class getType()
          Gets the type of this Option.
 void setValue(java.lang.Long value)
          Sets the value of this LongOption 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

LONG_DEFAULT

public static final long LONG_DEFAULT
If the default value is unspecified then this will be used

See Also:
Constant Field Values
Constructor Detail

LongOption

public LongOption(java.lang.String name,
                  long defaultValue,
                  boolean isRepeatable,
                  java.lang.String helpMessage)
Creates a new LongOption with the given name and default value. It will be multi-valued if isRepeatable is true and single-valued otherwise. 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
isRepeatable - If true then this option is multi-valued otherwise it is single-valued
helpMessage - The help message to report to the user upon request

LongOption

public LongOption(java.lang.String name,
                  long defaultValue)
Creates a new LongOption with the given name and default value. It will have the default setting for isRepeatable and helpMessage.

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

LongOption

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

Parameters:
name - The name for the option
See Also:
LongOption.LONG_DEFAULT, Argument.REPEATABLE_DEFAULT, Argument.HELP_DEFAULT
Method Detail

setValue

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

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

getLongValue

public java.lang.Long getLongValue()
Gets the first value of this LongOption.

Returns:
The first value

getLongValue

public java.lang.Long getLongValue(int index)
Gets the value of this LongOption 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 long value

fromStringValue

protected java.lang.Object fromStringValue(java.lang.String value)
                                    throws ArgumentFormatException
Parses a String value into an Object appropriate for the type

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 LongOption.

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