|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.gjt.universe.CommandLine
Parses the command line options and sets the appropriate flags in the class. In a (perhaps misguided) effort to increase the generality of the code, this class has been rewritten to use a Hashtable to store the command line options.
Currently, the parseArgs
function interprets an array of
String
options by checking if each element in the array has a
dash '-' as its first non-whitespace character, and storing it as a key in a
Hashtable if it does. The key for this option is the contents of the
String
after the initial dashes up to any equals '=' sign in
string. The value of this option will be any substring after an equals '='
sign, or otherwise any following options not starting with a dash. If there
is neither an equals sign in the option nor any parameters following, the
value stored is the string "true"
.
Examples:
The option --example
would have the key example
and the value true
.
The option --example=one
would have the key
example
and the value one
.
The options --example
and two
would have the key
example
and the value two
.
Further, if there are several options with the same name, or if the value
expression is a list separated by commas, semicolons or colons, the value
string will be a list of the values, separated by NUL (&backsl;u0000
).
The values can be copied to Config with copyOptionValues()
, and
read with getStringArray()
in that class.
The primary advantage of this rewritten form is that it is now possible
to write code to take advantage of a new command line option without
rewriting CommandLine.java. The code dependant on a particular option
being given now needs only check the return value of
getCLOState(option)
.
Field Summary | |
private static float |
HASH_LOAD_FACTOR
Value for the loadFactor parameter for the Hashtable. |
private static int |
HASH_SIZE_FACTOR
Value to multiply the number of command line options by in order to derive the initialCapacity value for the Hashtable. |
private static java.lang.String |
OPTION_DELIMS
Characters that can delimit values in an option of the form "-option=val1,val2,.... |
private static java.util.Hashtable |
options
|
Constructor Summary | |
CommandLine()
|
Method Summary | |
static void |
copyOptionValues()
Transfers the values from the command line to the Config . |
static boolean |
getAlpha()
Deprecated. Should use getCLOState("alpha") instead. |
static boolean |
getCLOState(java.lang.String key)
Checks if key is contained in the Hashtable. |
static java.lang.String |
getCLOValue(java.lang.String key)
Returns the value associated with key . |
static boolean |
getDebug()
Deprecated. Should use getCLOState("debug") instead. |
static boolean |
getOne()
Deprecated. Should use getCLOState("one") instead. |
static boolean |
getQuick()
Deprecated. Should use getCLOState("quick") instead. |
static boolean |
getText()
Deprecated. Should use getCLOState("text") instead. |
static void |
parseArgs(java.lang.String[] args)
Parses the the command line arguments and inserts them in a Hashtable. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.String OPTION_DELIMS
private static java.util.Hashtable options
private static final int HASH_SIZE_FACTOR
initialCapacity
value for the Hashtable.
Hashtable
,
Constant Field Valuesprivate static final float HASH_LOAD_FACTOR
loadFactor
parameter for the Hashtable.
Hashtable
,
Constant Field ValuesConstructor Detail |
public CommandLine()
Method Detail |
public static void parseArgs(java.lang.String[] args)
public static final boolean getCLOState(java.lang.String key)
key
is contained in the Hashtable.
key
- Option to look for in the options table. By definition, the
key for a particular command line option is that option, stripped of any
leading dashes. (E.g., the key for the -debug
command line
option would be debug
.)
true
if the requested key is contained in the
Hashtable, and false
if it does not. If, for some reason,
the actual value associated with the key is required, you should call
getCLOValue(key)
.public static final java.lang.String getCLOValue(java.lang.String key)
key
.
key
- Option to look for in the options table. By definition, the
key for a particular command line option is that option, stripped of any
leading dashes. (E.g., the key for the -debug
command line
option would be debug
.)
String
representation of the value
associated with the supplied key
if key
is
contained in the Hashtable, and null
otherwise.public static final void copyOptionValues()
Config
.
The keys text
, one
and jfc
are
translated into the name of the GUIFactory
class to be
instantiated. All other values are copied literally.
public static final boolean getText()
getCLOState("text")
instead.
public static final boolean getAlpha()
getCLOState("alpha")
instead.
public static final boolean getDebug()
getCLOState("debug")
instead.
public static final boolean getOne()
getCLOState("one")
instead.
public static final boolean getQuick()
getCLOState("quick")
instead.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |