com.ireasoning.util
Class ParseArguments
java.lang.Object
|
+--com.ireasoning.util.ParseArguments
- public class ParseArguments
- extends Object
This class is used to parse the command line arguments.
Concepts in this class
switches: without value, such as -g in javac
options: with value, such as -d in javac
Example:
ParseArguments p = new ParseArguments(args, "gO", "d");
boolean g = p.isSwitchPresent('g');
String dir = p.getOptionValue('d');
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ParseArguments
public ParseArguments(String[] args,
String switches,
String options)
- Parameters:
switches
- a string of switchesoptions
- a string of options
ParseArguments
public ParseArguments(String[] args,
String options)
- Parameters:
options
- a string of options
isSwitchPresent
public boolean isSwitchPresent(char switchChar)
- Returns true if the passed switch is present
getOptionValue
public String getOptionValue(char option)
- Returns the value of an option
- Parameters:
option
- the option
getOptionValue
public String getOptionValue(char option,
String defaultVal)
- Returns the value of an option
- Parameters:
option
- the optiondefaultVal
- the default value of the option
getArguments
public String[] getArguments()
- Returns an array of 'real' arguememnts, without switches and options.
Copyright © 2002 iReasoning Inc. All Rights Reserved.