JML

org.multijava.util
Class Options

java.lang.Object
  extended byorg.multijava.util.Options
Direct Known Subclasses:
BackendOptions, ClassfileOptions, DisOptions, LexgenOptions, MjcCommonOptions, OptimizeOptions, TestingOptions

public abstract class Options
extends Object

This class implements basic option parsing. Subclasses add tool-specific options to the set of options that are accepted. Subclasses are typically generated using the option generating utility Main.


Field Summary
private  String name
           
private  String[] nonOptions
          The array of non-option arguments.
private static int NOVERSION_CASE
           
private static String VERSION
           
private  boolean Xnoversion
           
 
Constructor Summary
Options(String name)
          Creates a new Option object.
 
Method Summary
protected  String[] formOneColumnArray(String firstArg)
           
protected  String[] formTwoColumnArray(String firstArg, String secondArg)
           
 Hashtable getCurrentValue()
          Returns the current value
 Hashtable getDefaultValue()
          Returns the default value
 Hashtable getGuiType()
          Returns the GUI categories that this option is in
 Hashtable getHelpString()
          Returns the help messages
protected  int getInt(gnu.getopt.Getopt g, int defaultValue)
           
 LinkedHashSet getLongname()
          Returns the longname
 gnu.getopt.LongOpt[] getLongOptions()
          Gets long options
protected  String getNonNullString(String str)
           
protected  String[][] getNonNullStringArray(String[][] str)
           
 HashMap getOptions()
           
 Hashtable getSelectionList()
          Returns the list of selections for an option
 String getShortOptions()
          Gets short options
protected  String getString(gnu.getopt.Getopt g, String defaultValue)
           
protected  String getString(String newValue)
           
protected  String getSystemProperty(String property)
           
 Hashtable getTableHeader()
          Returns the header for a table
 Hashtable getType()
          Returns the type
abstract  void help()
          shows an usage message
 String[] nonOptions()
           
 boolean parseCommandLine(String[] argv)
           
 boolean parseCommandLine(String[] argv, ArrayList infiles)
          Parses and evaluates the command line arguments.
 void printOptions()
          Prints the options
 void printVersion()
          Prints the version information
 boolean processOption(int code, gnu.getopt.Getopt g)
          Handles the option identified by the given code, perhaps using g to process any arguments to the option.
 boolean setOption(String name, Object newValue)
           
protected abstract  void usage()
          shows a help message
protected  String version()
          Returns the version information
 boolean Xnoversion()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nonOptions

private String[] nonOptions
The array of non-option arguments.


name

private final String name

VERSION

private static final String VERSION

Xnoversion

private boolean Xnoversion

NOVERSION_CASE

private static final int NOVERSION_CASE
Constructor Detail

Options

public Options(String name)
Creates a new Option object.

Parameters:
name - the command name to pass to getopt
Method Detail

parseCommandLine

public boolean parseCommandLine(String[] argv)

parseCommandLine

public boolean parseCommandLine(String[] argv,
                                ArrayList infiles)
Parses and evaluates the command line arguments.

Parameters:
argv - the command line arguments
infiles - where to put non-option arguments
Returns:
true iff the command line was parsed successfully

setOption

public boolean setOption(String name,
                         Object newValue)

processOption

public boolean processOption(int code,
                             gnu.getopt.Getopt g)
Handles the option identified by the given code, perhaps using g to process any arguments to the option. This method is typically overridden in subclasses to process additional arguments with the subclass defering to the superclass if code is unknown.

Parameters:
g - the command line arguments

getOptions

public HashMap getOptions()

printOptions

public void printOptions()
Prints the options


getLongname

public LinkedHashSet getLongname()
Returns the longname


getTableHeader

public Hashtable getTableHeader()
Returns the header for a table


getType

public Hashtable getType()
Returns the type


getDefaultValue

public Hashtable getDefaultValue()
Returns the default value


getCurrentValue

public Hashtable getCurrentValue()
Returns the current value


getSelectionList

public Hashtable getSelectionList()
Returns the list of selections for an option


getHelpString

public Hashtable getHelpString()
Returns the help messages


getGuiType

public Hashtable getGuiType()
Returns the GUI categories that this option is in


help

public abstract void help()
shows an usage message


version

protected String version()
Returns the version information


printVersion

public void printVersion()
Prints the version information


usage

protected abstract void usage()
shows a help message


getInt

protected int getInt(gnu.getopt.Getopt g,
                     int defaultValue)

getString

protected String getString(gnu.getopt.Getopt g,
                           String defaultValue)

getString

protected String getString(String newValue)

getNonNullString

protected String getNonNullString(String str)

getNonNullStringArray

protected String[][] getNonNullStringArray(String[][] str)

getSystemProperty

protected String getSystemProperty(String property)

formOneColumnArray

protected String[] formOneColumnArray(String firstArg)

formTwoColumnArray

protected String[] formTwoColumnArray(String firstArg,
                                      String secondArg)

getShortOptions

public String getShortOptions()
Gets short options


getLongOptions

public gnu.getopt.LongOpt[] getLongOptions()
Gets long options


nonOptions

public String[] nonOptions()

Xnoversion

public boolean Xnoversion()

JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.