Package net.ontopia.utils
Class CmdlineOptions
- java.lang.Object
-
- net.ontopia.utils.CmdlineOptions
-
public class CmdlineOptions extends Object
INTERNAL: A class that parses command line options.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
CmdlineOptions.ListenerIF
INTERNAL: A listener interface that must be implemented by object that are interested in options found by the CmdlineOptions instance.static class
CmdlineOptions.OptionsException
INTERNAL: An exception that is thrown when there are problems with the options specified on the command line.
-
Field Summary
Fields Modifier and Type Field Description protected String
application
protected List<String>
arguments
protected String[]
argv
protected List<gnu.getopt.LongOpt>
largs
protected Map<Integer,CmdlineOptions.ListenerIF>
listeners
protected StringBuilder
sargs
-
Constructor Summary
Constructors Constructor Description CmdlineOptions(String application, String[] argv)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLong(CmdlineOptions.ListenerIF listener, String name, char c)
Add a long argumentless option with the specified listener.void
addLong(CmdlineOptions.ListenerIF listener, String name, char c, boolean req_arg)
Add a long option with argument with the specified listener.void
addShort(CmdlineOptions.ListenerIF listener, char c)
Add a short argumentless option with the specified listener.void
addShort(CmdlineOptions.ListenerIF listener, char c, boolean req_arg)
Add a short option with argument with the specified listener.String[]
getArguments()
Return non-option arguments that are remaining after parsing the command line arguments.void
parse()
Parse the command line arguments and notify option listeners.
-
-
-
Field Detail
-
application
protected String application
-
argv
protected String[] argv
-
sargs
protected StringBuilder sargs
-
largs
protected List<gnu.getopt.LongOpt> largs
-
listeners
protected Map<Integer,CmdlineOptions.ListenerIF> listeners
-
-
Method Detail
-
addShort
public void addShort(CmdlineOptions.ListenerIF listener, char c)
Add a short argumentless option with the specified listener.
-
addShort
public void addShort(CmdlineOptions.ListenerIF listener, char c, boolean req_arg)
Add a short option with argument with the specified listener.
-
addLong
public void addLong(CmdlineOptions.ListenerIF listener, String name, char c)
Add a long argumentless option with the specified listener.
-
addLong
public void addLong(CmdlineOptions.ListenerIF listener, String name, char c, boolean req_arg)
Add a long option with argument with the specified listener.
-
parse
public void parse() throws CmdlineOptions.OptionsException
Parse the command line arguments and notify option listeners.- Throws:
CmdlineOptions.OptionsException
-
getArguments
public String[] getArguments()
Return non-option arguments that are remaining after parsing the command line arguments.
-
-