org.apache.commons.cli
Class PosixParser

java.lang.Object
  extended by org.apache.commons.cli.Parser
      extended by org.apache.commons.cli.PosixParser
All Implemented Interfaces:
CommandLineParser

public class PosixParser
extends Parser

The class PosixParser provides an implementation of the flatten method.

Version:
$Revision: 695760 $, $Date: 2008-09-16 01:05:03 -0700 (Tue, 16 Sep 2008) $
Author:
John Keyes (john at integralsource.com)

Field Summary
 
Fields inherited from class org.apache.commons.cli.Parser
cmd
 
Constructor Summary
PosixParser()
           
 
Method Summary
protected  void burstToken(String token, boolean stopAtNonOption)
          Breaks token into its constituent parts using the following algorithm.
protected  String[] flatten(Options options, String[] arguments, boolean stopAtNonOption)
          An implementation of Parser's abstract flatten method.
 
Methods inherited from class org.apache.commons.cli.Parser
checkRequiredOptions, getOptions, getRequiredOptions, parse, parse, parse, parse, processArgs, processOption, processProperties, setOptions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PosixParser

public PosixParser()
Method Detail

flatten

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

An implementation of Parser's abstract flatten method.

The following are the rules used by this flatten method.

  1. if stopAtNonOption is true then do not burst anymore of arguments entries, just add each successive entry without further processing. Otherwise, ignore stopAtNonOption.
  2. if the current arguments entry is "--" just add the entry to the list of processed tokens
  3. if the current arguments entry is "-" just add the entry to the list of processed tokens
  4. if the current arguments entry is two characters in length and the first character is "-" then check if this is a valid Option id. If it is a valid id, then add the entry to the list of processed tokens and set the current Option member. If it is not a valid id and stopAtNonOption is true, then the remaining entries are copied to the list of processed tokens. Otherwise, the current entry is ignored.
  5. if the current arguments entry is more than two characters in length and the first character is "-" then we need to burst the entry to determine its constituents. For more information on the bursting algorithm see burstToken.
  6. if the current arguments entry is not handled by any of the previous rules, then the entry is added to the list of processed tokens.

Specified by:
flatten in class Parser
Parameters:
options - The command line Options
arguments - The command line arguments to be parsed
stopAtNonOption - Specifies whether to stop flattening when an non option is found.
Returns:
The flattened arguments String array.

burstToken

protected void burstToken(String token,
                          boolean stopAtNonOption)
Breaks token into its constituent parts using the following algorithm.

Parameters:
token - The current token to be burst
stopAtNonOption - Specifies whether to stop processing at the first non-Option encountered.


Copyright © 2002-2009 The Apache Software Foundation. All Rights Reserved.