net.ontopia.utils
Class CmdlineOptions

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

public class CmdlineOptions
extends java.lang.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  java.lang.String application
           
protected  java.util.List<java.lang.String> arguments
           
protected  java.lang.String[] argv
           
protected  java.util.List<gnu.getopt.LongOpt> largs
           
protected  java.util.Map<java.lang.Integer,CmdlineOptions.ListenerIF> listeners
           
protected  java.lang.StringBuffer sargs
           
 
Constructor Summary
CmdlineOptions(java.lang.String application, java.lang.String[] argv)
           
 
Method Summary
 void addLong(CmdlineOptions.ListenerIF listener, java.lang.String name, char c)
          Add a long argumentless option with the specified listener.
 void addLong(CmdlineOptions.ListenerIF listener, java.lang.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.
 java.lang.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 java.lang.String application

argv

protected java.lang.String[] argv

sargs

protected java.lang.StringBuffer sargs

largs

protected java.util.List<gnu.getopt.LongOpt> largs

listeners

protected java.util.Map<java.lang.Integer,CmdlineOptions.ListenerIF> listeners

arguments

protected java.util.List<java.lang.String> arguments
Constructor Detail

CmdlineOptions

public CmdlineOptions(java.lang.String application,
                      java.lang.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,
                    java.lang.String name,
                    char c)
Add a long argumentless option with the specified listener.


addLong

public void addLong(CmdlineOptions.ListenerIF listener,
                    java.lang.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 java.lang.String[] getArguments()
Return non-option arguments that are remaining after parsing the command line arguments.



Copyright © 2000-2012 Ontopia.