|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.informatica.app.CommandLine
public class CommandLine
Command-line parameter/argument handling.
Generic encapsulation of command-line parameters, with the following general rules:
Those options prefixed by a "-" or "--" are called "parameters" or "options", while the rest are called "last arguments" or simply "arguments".
public static void main(String[] args) {
CommandLine cmdline = new CommandLine(args);
String opt_a = cmdline.getParam("a"); // opt_a = "first_arg"
Enumeration enu = cmdline.getParameterValues("D");
while (enu.hasMoreElements()) {
String s = (String) enu.nextElement(); // s = "name1=value"
// s = "logic"
}
String param_dir = cmdline.getAssignParam("dir"); // param_dir = "/var/tmp"
}
| Constructor Summary | |
|---|---|
CommandLine(String[] cmdline)
Constructor with a String array of command line arguments. |
|
| Method Summary | |
|---|---|
String[] |
getArguments()
|
String |
getAssignParam(String pname)
Gets the value assigned to a '--' parameter. |
String |
getLastArgument()
Returns the last command-line argument (the last of those arguments not starting with a "-"). |
String[] |
getLastArguments()
Returns the last command-line arguments (those arguments not starting with a "-"). |
String |
getParam(String pname)
Gets a parameter of a given name. |
Enumeration |
getParameterValues(String pname)
|
boolean |
hasParameter(String pname)
Tells if the command line has a parameter of the given name. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CommandLine(String[] cmdline)
cmdline - the String array of command line arguments as given in the
main method.| Method Detail |
|---|
public String getParam(String pname)
pname - parameter name.
public String getAssignParam(String pname)
pname - parameter name.
public boolean hasParameter(String pname)
pname - the parameter name.
public String getLastArgument()
public String[] getLastArguments()
public String[] getArguments()
public Enumeration getParameterValues(String pname)
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||