|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--com.syncbuilder.app.BasicAppSkeleton
This class is a skeleton for any command-line application. It uses an extremely powerful command-line parser (derived from GNU getopt), and it can control the flow of the entire initialization sequence of the app.
It can also turn almost any command-line app into a simple GUI app. Every application which
you create with this skeleton will contain two standard options:
-gui will turn on the GUI interface.
-help will display usage information.
| Field Summary | |
protected java.util.Hashtable |
_arguments
|
protected boolean |
_has_gui
|
int |
extra_args
|
protected java.util.Vector |
options
|
| Constructor Summary | |
BasicAppSkeleton()
|
|
| Method Summary | |
protected void |
_displayUsage()
|
protected void |
_inquireParameters()
Determine the missing parameters, either through the default-values, or by asking the user. |
protected void |
_parseArguments(java.lang.String[] args,
Index extra_args)
Parse the arguments from the command line, and fill them into a Hashtable. |
void |
addCustomOptions()
Add new custom options to the list of options. |
protected void |
addFixedOptions()
This one will be invoked by runApp before addCustomOptions(). |
void |
appMain()
The custom-code for your application goes here. |
void |
displayMessage(java.lang.String msg,
java.lang.String action)
Use this method to display messages that require the immediate attention of the user. |
boolean |
getFlagOpt(java.lang.String name)
Get the boolean value of an option |
int |
getNumericalOpt(java.lang.String name)
Get the numerical value of an option |
java.lang.String |
getProgramInfo()
Return a String which contains information about the program. |
java.lang.String |
getStringOpt(java.lang.String name)
Get the String value of an option |
void |
runApp(java.lang.String[] args)
Invoke this method to run the application. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
protected java.util.Vector options
protected java.util.Hashtable _arguments
public int extra_args
protected boolean _has_gui
| Constructor Detail |
public BasicAppSkeleton()
| Method Detail |
public void addCustomOptions()
This method will typically be overwritten by your specialization. Your code will have to add specializations of the LongOpt class to the end of the options Vector.
Example:
options.addElement(new NumericalOpt("minimum", "The minimum value", 3, true, 0, 5));
options - the options, as a Vector of LongOpt objectsLongOpt,
NumericalOpt,
StringOpt,
FlagOpt
public void appMain()
throws java.lang.Exception
public java.lang.String getProgramInfo()
You will almost always overwrite this method in order to return information about your program.
public void runApp(java.lang.String[] args)
runApp handles all the command-line parsing for you. It will also display help-texts if appropriate. It will only call your code if all the parameters are valid.
public int getNumericalOpt(java.lang.String name)
public java.lang.String getStringOpt(java.lang.String name)
public boolean getFlagOpt(java.lang.String name)
public void displayMessage(java.lang.String msg,
java.lang.String action)
msg - the text of the messageaction - a description of what happens when the user acknowledges the message (e.g. continue).
protected void _parseArguments(java.lang.String[] args,
Index extra_args)
args - the args-array contains the command-line parametersextra_args - if this is != null it will be filled with the index of the first extra-argument after the last command-line parameterprotected void _inquireParameters()
protected void _displayUsage()
protected void addFixedOptions()
addCustomOptions()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||