org.apache.commons.cli
Class GnuParser

java.lang.Object
  |
  +--org.apache.commons.cli.Parser
        |
        +--org.apache.commons.cli.GnuParser

public class GnuParser
extends Parser

The class GnuParser provides an implementation of the flatten method.

Version:
$Revision: 1.10 $
Author:
John Keyes (john at integralsource.com)
See Also:
Parser

Field Summary
private  java.util.ArrayList tokens
          holder for flattened tokens
 
Fields inherited from class org.apache.commons.cli.Parser
cmd, options, requiredOptions
 
Constructor Summary
GnuParser()
           
 
Method Summary
protected  java.lang.String[] flatten(Options options, java.lang.String[] arguments, boolean stopAtNonOption)
          This flatten method does so using the following rules: If an Option exists for the first character of the arguments entry AND an Option does not exist for the whole argument then add the first character as an option to the processed tokens list e.g.
private  void init()
          Resets the members to their original state i.e.
 
Methods inherited from class org.apache.commons.cli.Parser
checkRequiredOptions, parse, parse, processArgs, processOption
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

tokens

private java.util.ArrayList tokens
holder for flattened tokens
Constructor Detail

GnuParser

public GnuParser()
Method Detail

init

private void init()

Resets the members to their original state i.e. remove all of tokens entries.


flatten

protected java.lang.String[] flatten(Options options,
                                     java.lang.String[] arguments,
                                     boolean stopAtNonOption)

This flatten method does so using the following rules:

  1. If an Option exists for the first character of the arguments entry AND an Option does not exist for the whole argument then add the first character as an option to the processed tokens list e.g. "-D" and add the rest of the entry to the also.
  2. Otherwise just add the token to the processed tokens list.

Overrides:
flatten in class Parser
Tags copied from class: Parser
Parameters:
opts - The Options to parse the arguments by.
args - The arguments that have to be flattened.
stopAtNonOption - specifies whether to stop flattening when a non option has been encountered
Returns:
a String array of the flattened arguments