Groovy Documentation

org.codehaus.groovy.cli
[Java] Class GroovyPosixParser

java.lang.Object
  org.apache.commons.cli.Parser
      org.codehaus.groovy.cli.GroovyPosixParser

public class GroovyPosixParser
extends org.apache.commons.cli.Parser

DO NOT USE. Hacked version until Commons CLI 1.3 is released. NOTE: this is a mirror copy of org.apache.commons.cli.GroovyInternalPosixParser DON'T MAKE CHANGES without keeping the other file in sync! The class GroovyPosixParser provides an implementation of the org.apache.commons.cli.Parser#flatten(org.apache.commons.cli.Options,String[],boolean) method.

Authors:
John Keyes (john at integralsource.com)
Paul King (Groovy hacks/fixes)


Method Summary
protected void burstToken(java.lang.String token, boolean stopAtNonOption)

Breaks token into its constituent parts using the following algorithm.

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

An implementation of org.apache.commons.cli.Parser's abstract org.apache.commons.cli.Parser#flatten(org.apache.commons.cli.Options, java.lang.String, boolean) method.

 
Methods inherited from class org.apache.commons.cli.Parser
org.apache.commons.cli.Parser#processArgs(org.apache.commons.cli.Option, java.util.ListIterator), org.apache.commons.cli.Parser#parse(org.apache.commons.cli.Options, [Ljava.lang.String;, java.util.Properties, boolean), org.apache.commons.cli.Parser#parse(org.apache.commons.cli.Options, [Ljava.lang.String;, boolean), org.apache.commons.cli.Parser#parse(org.apache.commons.cli.Options, [Ljava.lang.String;, java.util.Properties), org.apache.commons.cli.Parser#parse(org.apache.commons.cli.Options, [Ljava.lang.String;), org.apache.commons.cli.Parser#wait(long, int), org.apache.commons.cli.Parser#wait(long), org.apache.commons.cli.Parser#wait(), org.apache.commons.cli.Parser#equals(java.lang.Object), org.apache.commons.cli.Parser#toString(), org.apache.commons.cli.Parser#hashCode(), org.apache.commons.cli.Parser#getClass(), org.apache.commons.cli.Parser#notify(), org.apache.commons.cli.Parser#notifyAll()
 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Method Detail

burstToken

protected void burstToken(java.lang.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.


flatten

protected java.lang.String[] flatten(org.apache.commons.cli.Options options, java.lang.String[] arguments, boolean stopAtNonOption)
An implementation of org.apache.commons.cli.Parser's abstract org.apache.commons.cli.Parser#flatten(org.apache.commons.cli.Options, java.lang.String, boolean) 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 org.apache.commons.cli.Option id. If it is a valid id, then add the entry to the list of processed tokens and set the current org.apache.commons.cli.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.
Parameters:
options - The command line org.apache.commons.cli.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.


 

Groovy Documentation