org.vivoweb.harvester.util.args
Class ArgParser

java.lang.Object
  extended by org.vivoweb.harvester.util.args.ArgParser

public class ArgParser
extends java.lang.Object

Argument Description Listing

Author:
Christopher Haines (hainesc@ctrip.ufl.edu)

Constructor Summary
ArgParser(java.lang.String appName)
          Default Constructor
 
Method Summary
 void addArgument(ArgDef arg)
          Add an Argument Definition to this Argument Parser
 java.lang.String getAppName()
          Get the application name
 java.util.Collection<ArgDef> getArgDefs()
          Get the argument definitions
protected  org.apache.commons.cli.Options getOptions()
          Get the Options
 java.util.Map<java.lang.String,ArgDef> getOptMap()
          Get the mapping of option flag to ArgDef
 java.lang.String getUsage()
          Get the usage message for this arg list
 ArgList parse(java.lang.String[] args)
          Parse the commandline arguments
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArgParser

public ArgParser(java.lang.String appName)
Default Constructor

Parameters:
appName - the application this parser is meant for
Method Detail

getOptions

protected org.apache.commons.cli.Options getOptions()
Get the Options

Returns:
the Options

getArgDefs

public java.util.Collection<ArgDef> getArgDefs()
Get the argument definitions

Returns:
the argument definitions

getOptMap

public java.util.Map<java.lang.String,ArgDef> getOptMap()
Get the mapping of option flag to ArgDef

Returns:
the mapping

getAppName

public java.lang.String getAppName()
Get the application name

Returns:
the application name

addArgument

public void addArgument(ArgDef arg)
Add an Argument Definition to this Argument Parser

Parameters:
arg - the argument to add

parse

public ArgList parse(java.lang.String[] args)
              throws java.lang.IllegalArgumentException,
                     java.io.IOException
Parse the commandline arguments

Parameters:
args - the commandline arguments
Returns:
the parsed arglist
Throws:
java.lang.IllegalArgumentException - bad arguments provided
java.io.IOException - error parsing args

getUsage

public java.lang.String getUsage()
Get the usage message for this arg list

Returns:
the usage string