getopt-0.3

jrowe.getopt
Interface Option

All Known Implementing Classes:
DefaultOption

public interface Option
extends Cloneable

An interface representing a program option.

Version:
1.2 MAR 10 2000 Moved from package org.jrowe.getopt to jrowe.getopt.
Author:
Joshua T. Rowe

Field Summary
static int BOOLEAN_ARG
          An indicator used when the program option takes a boolean argument.
static int COUNT_ARG
          An indicator used when the program option takes as it's argument the number of times the option appears on the command line.
static int INTEGER_ARG
           An indicator used when the program option takes an integer argument.
static int LIST_ARG
          An indicator used when the program option takes a list of arguments.
static int NESTED_ARG
           
static int NO_ARG
          An indicator used when the program option takes no arguments.
static int NUMERIC_ARG
          An indicator used when the program option takes a numeric argument.
static int REAL_ARG
           An indicator used when the program option takes an real argument.
static int SCALAR_ARG
          An indicator used when the program option takes a scalar argument.
static int STRING_ARG
          An indicator used when the program option takes a string argument.
 
Method Summary
 void clear()
          Reinitializes this Option to it's default state.
 Object clone()
          Creates and returns a copy of this object.
 Option createNewInstance()
          Creates an Option of the same class as this Option.
 Object getArg()
          Returns the argument for this program option.
 int getArgType()
          Returns the argument type for this program option.
 char getChar()
          Returns the short name of this program option.
 Character getCharacter()
          Returns the short name of this program option.
 String getName()
          Returns the long name for this program option.
 boolean isArgOptional()
          Returns whether the argument for this Option is optional
 void runMethod()
          Invokes the Runnable object that is to be run if this program option is found.
 void runMethod(Object arg)
          Deprecated.  
 void setArg(Object arg)
          Sets the argument for this program option.
 void setArgOptional(boolean argOptional)
          Sets whether the argument for this Option is optional
 void setArgType(int argType)
          Sets the argument type for this program option.
 void setChar(char c)
          Sets the short name of this program option.
 void setCharacter(Character c)
          Sets the short name of this program option.
 void setMethod(OptionMethod method)
          Sets the Runnable object to invoke if the program option is found.
 void setName(String name)
          Sets the long name for this program option.
 

Field Detail

NO_ARG

public static final int NO_ARG
An indicator used when the program option takes no arguments.

SCALAR_ARG

public static final int SCALAR_ARG
An indicator used when the program option takes a scalar argument.

STRING_ARG

public static final int STRING_ARG
An indicator used when the program option takes a string argument.

INTEGER_ARG

public static final int INTEGER_ARG

An indicator used when the program option takes an integer argument.

NOTE:

Integer being defined in the mathematical sense, not strictly an Integer type in Java.


REAL_ARG

public static final int REAL_ARG

An indicator used when the program option takes an real argument.


LIST_ARG

public static final int LIST_ARG
An indicator used when the program option takes a list of arguments.

NESTED_ARG

public static final int NESTED_ARG

BOOLEAN_ARG

public static final int BOOLEAN_ARG
An indicator used when the program option takes a boolean argument.

COUNT_ARG

public static final int COUNT_ARG
An indicator used when the program option takes as it's argument the number of times the option appears on the command line.

NUMERIC_ARG

public static final int NUMERIC_ARG
An indicator used when the program option takes a numeric argument.
Method Detail

setName

public void setName(String name)
Sets the long name for this program option.
Parameters:
name - the name for this option

getName

public String getName()
Returns the long name for this program option.
Returns:
the name for this option

setArg

public void setArg(Object arg)
Sets the argument for this program option.
Parameters:
arg - the argument for this program option

getArg

public Object getArg()
Returns the argument for this program option.
Returns:
the argument for this program option

setArgType

public void setArgType(int argType)
Sets the argument type for this program option.
Parameters:
argType - The type of argument this program option takes.
Valid types are:
NO_ARG
SCALAR_ARG
STRING_ARG
LIST_ARG
COUNT_ARG
NUMERIC_ARG
REAL_ARG
INTEGER_ARG
BOOLEAN_ARG

getArgType

public int getArgType()
Returns the argument type for this program option.
Returns:
the argument type for this program option
See Also:
setArgType(int)

setArgOptional

public void setArgOptional(boolean argOptional)
Sets whether the argument for this Option is optional
Returns:
argOptional whether the argument for this Option is optional

isArgOptional

public boolean isArgOptional()
Returns whether the argument for this Option is optional
Returns:
whether the argument for this Option is optional

clear

public void clear()
Reinitializes this Option to it's default state.

setChar

public void setChar(char c)
Sets the short name of this program option.
Parameters:
c - the short name of this program option

getChar

public char getChar()
Returns the short name of this program option.
Returns:
the short name of this program option

setCharacter

public void setCharacter(Character c)
Sets the short name of this program option.
Parameters:
c - the short name of this program option

getCharacter

public Character getCharacter()
Returns the short name of this program option.
Returns:
the short name of this program option

setMethod

public void setMethod(OptionMethod method)
Sets the Runnable object to invoke if the program option is found.
Parameters:
method - the object to invoke

runMethod

public void runMethod()
Invokes the Runnable object that is to be run if this program option is found.

runMethod

public void runMethod(Object arg)
Deprecated.  

Invokes the Runnable object that is to be run if this program option is found.
Parameters:
arg - the argument

clone

public Object clone()
Creates and returns a copy of this object.

Overrides:
clone in class Object
Throws:
OutOfMemoryError - if there is not enough memory.
See Also:
Cloneable, Object.clone()

createNewInstance

public Option createNewInstance()
Creates an Option of the same class as this Option.

This is similar to the clone method except none of the data contained in the object is copied.

See Also:
clone()

getopt-0.3