mjc

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 java.lang.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  java.lang.String name
           
private  java.lang.String[] nonOptions
          The array of non-option arguments.
private static int NOVERSION_CASE
           
private static java.lang.String VERSION
           
private  boolean Xnoversion
           
 
Constructor Summary
Options(java.lang.String name)
          Creates a new Option object.
 
Method Summary
protected  java.lang.String[] formOneColumnArray(java.lang.String firstArg)
           
protected  java.lang.String[] formTwoColumnArray(java.lang.String firstArg, java.lang.String secondArg)
           
 java.util.Hashtable getCurrentValue()
          Returns the current value
 java.util.Hashtable getDefaultValue()
          Returns the default value
 java.util.Hashtable getGuiType()
          Returns the GUI categories that this option is in
 java.util.Hashtable getHelpString()
          Returns the help messages
protected  int getInt(gnu.getopt.Getopt g, int defaultValue)
           
 java.util.LinkedHashSet getLongname()
          Returns the longname
 gnu.getopt.LongOpt[] getLongOptions()
          Gets long options
protected  java.lang.String getNonNullString(java.lang.String str)
           
protected  java.lang.String[][] getNonNullStringArray(java.lang.String[][] str)
           
 java.util.HashMap getOptions()
           
 java.util.Hashtable getSelectionList()
          Returns the list of selections for an option
 java.lang.String getShortOptions()
          Gets short options
protected  java.lang.String getString(gnu.getopt.Getopt g, java.lang.String defaultValue)
           
protected  java.lang.String getString(java.lang.String newValue)
           
protected  java.lang.String getSystemProperty(java.lang.String property)
           
 java.util.Hashtable getTableHeader()
          Returns the header for a table
 java.util.Hashtable getType()
          Returns the type
abstract  void help()
          shows an usage message
 java.lang.String[] nonOptions()
           
 boolean parseCommandLine(java.lang.String[] argv)
           
 boolean parseCommandLine(java.lang.String[] argv, java.util.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(java.lang.String name, java.lang.Object newValue)
           
protected abstract  void usage()
          shows a help message
protected  java.lang.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 java.lang.String[] nonOptions
The array of non-option arguments.


name

private final java.lang.String name

VERSION

private static final java.lang.String VERSION

Xnoversion

private boolean Xnoversion

NOVERSION_CASE

private static final int NOVERSION_CASE
Constructor Detail

Options

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

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

parseCommandLine

public boolean parseCommandLine(java.lang.String[] argv)

parseCommandLine

public boolean parseCommandLine(java.lang.String[] argv,
                                java.util.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(java.lang.String name,
                         java.lang.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 java.util.HashMap getOptions()

printOptions

public void printOptions()
Prints the options


getLongname

public java.util.LinkedHashSet getLongname()
Returns the longname


getTableHeader

public java.util.Hashtable getTableHeader()
Returns the header for a table


getType

public java.util.Hashtable getType()
Returns the type


getDefaultValue

public java.util.Hashtable getDefaultValue()
Returns the default value


getCurrentValue

public java.util.Hashtable getCurrentValue()
Returns the current value


getSelectionList

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


getHelpString

public java.util.Hashtable getHelpString()
Returns the help messages


getGuiType

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


help

public abstract void help()
shows an usage message


version

protected java.lang.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 java.lang.String getString(gnu.getopt.Getopt g,
                                     java.lang.String defaultValue)

getString

protected java.lang.String getString(java.lang.String newValue)

getNonNullString

protected java.lang.String getNonNullString(java.lang.String str)

getNonNullStringArray

protected java.lang.String[][] getNonNullStringArray(java.lang.String[][] str)

getSystemProperty

protected java.lang.String getSystemProperty(java.lang.String property)

formOneColumnArray

protected java.lang.String[] formOneColumnArray(java.lang.String firstArg)

formTwoColumnArray

protected java.lang.String[] formTwoColumnArray(java.lang.String firstArg,
                                                java.lang.String secondArg)

getShortOptions

public java.lang.String getShortOptions()
Gets short options


getLongOptions

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


nonOptions

public java.lang.String[] nonOptions()

Xnoversion

public boolean Xnoversion()

mjc

mjc is Copyright (C) 2000-2004 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. mjc is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.