net.ontopia.utils
Class CmdlineOptions

java.lang.Object
  extended by net.ontopia.utils.CmdlineOptions

public class CmdlineOptions
extends Object

INTERNAL: A class that parses command line options.


Nested Class Summary
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
protected  String application
           
protected  List<String> arguments
           
protected  String[] argv
           
protected  List<gnu.getopt.LongOpt> largs
           
protected  Map<Integer,CmdlineOptions.ListenerIF> listeners
           
protected  StringBuffer sargs
           
 
Constructor Summary
CmdlineOptions(String application, String[] argv)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

application

protected String application

argv

protected String[] argv

sargs

protected StringBuffer sargs

largs

protected List<gnu.getopt.LongOpt> largs

listeners

protected Map<Integer,CmdlineOptions.ListenerIF> listeners

arguments

protected List<String> arguments
Constructor Detail

CmdlineOptions

public CmdlineOptions(String application,
                      String[] argv)
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.



Copyright © 2000-2012 Ontopia.