|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.actf.util.command.CLArgumentProcessor
public class CLArgumentProcessor
The CLArgumentProcessor can be used to process arguments on the command line for
any application. A set of CLSwitches are associated with the processor upon its
instantiation and the resolved values of these switches can be obtained via the set of
getXXXArgument
methods of this class. The type of the value to which the
argument for a given switch is resolved is determined by the IArgumentResolver
for that switch.
CLSwitch
Constructor Summary | |
---|---|
CLArgumentProcessor()
construct a new command line argument processor with no switches associated with it |
|
CLArgumentProcessor(boolean preserveCase)
construct a new command line argument processor with no switches associated with it |
|
CLArgumentProcessor(CLSwitch[] switches)
construct a new command line argument processor with the given switches. |
|
CLArgumentProcessor(CLSwitch[] switches,
boolean preserveCase)
construct a new command line argument processor with the given switches. |
Method Summary | |
---|---|
void |
addSwitch(CLSwitch s)
add a switch to the set of switches processed by this processor |
void |
appendToUsage(String post)
append the given string to the usage. |
Object |
getArgument(String name)
get the resolved argument for the switch with the given name |
boolean |
getBooleanArgument(String name)
get the boolean argument value of the switch with the given name |
double |
getDoubleArgument(String name)
get the double argument value of the switch with the given name |
float |
getFloatArgument(String name)
get the float argument value of the switch with the given name |
int |
getIntArgument(String name)
get the int argument value of the switch with the given name |
long |
getLongArgument(String name)
get the long argument value of the switch with the given name |
CLSwitch |
getSwitch(String name)
return the command line switch with the given name |
CLSwitch[] |
getSwitches()
return the switches that are currently being handled by this processor |
String |
nameIfValidSwitch(String sw)
determines whether or not the given string is a valid switch. |
void |
prependToUsage(String pre)
prepend the given string to the usage statement. |
protected void |
printUsage()
|
void |
processArguments(String[] args)
process the given arguments from the command line. |
CLSwitch |
removeSwitch(String name)
remove the switch with the given name from this processor |
void |
setSwitches(CLSwitch[] switches)
set the command line switches to be associated with this command line processor. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CLArgumentProcessor()
public CLArgumentProcessor(CLSwitch[] switches)
switches
- - valid switches for this processorpublic CLArgumentProcessor(boolean preserveCase)
preserveCase
- public CLArgumentProcessor(CLSwitch[] switches, boolean preserveCase)
switches
- - valid switches for this processorpreserveCase
- - boolean to process arguments as case sensitive or notMethod Detail |
---|
public CLSwitch getSwitch(String name)
name
- - name of desired switch (Without prefix)
public CLSwitch[] getSwitches()
public void setSwitches(CLSwitch[] switches)
switches
- - valid switches for this command line argument processorpublic void addSwitch(CLSwitch s)
s
- - switch to be addedpublic CLSwitch removeSwitch(String name)
name
- - name of switch to be removed
public void processArguments(String[] args) throws CLArgumentException
getXXXArgument
methods of this class.
If the argument array is empty, the printAUsage()
method
is invoked. Usage for a switch consists of the name of
that switch along with its description.
args
- - arguments from command line
CLArgumentException
public int getIntArgument(String name) throws CLArgumentException
name
- - name of switch for which value is desired
CLArgumentException
- - if switch value is not of appropriate typepublic long getLongArgument(String name) throws CLArgumentException
name
- - name of switch for which value is desired
CLArgumentException
- - if switch value is not of appropriate typepublic float getFloatArgument(String name) throws CLArgumentException
name
- - name of switch for which value is desired
CLArgumentException
- - if switch value is not of appropriate typepublic double getDoubleArgument(String name) throws CLArgumentException
name
- - name of switch for which value is desired
CLArgumentException
- - if switch value is not of appropriate typepublic boolean getBooleanArgument(String name) throws CLArgumentException
name
- - name of switch for which value is desired
CLArgumentException
- - if switch value is not of appropriate typepublic Object getArgument(String name)
name
- - name of switch for which argument is desired
null
if switch with the given name is not foundpublic String nameIfValidSwitch(String sw)
sw
- - string to examine for validity
null
if notpublic void prependToUsage(String pre)
printUsage
method is called.
pre
- - first message to be printed for usagepublic void appendToUsage(String post)
post
- - to be printed after the usageprotected void printUsage()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |