FindBugs™ 1.3.4

edu.umd.cs.findbugs.config
Class CommandLine

java.lang.Object
  extended by edu.umd.cs.findbugs.config.CommandLine
Direct Known Subclasses:
FindBugsCommandLine

public abstract class CommandLine
extends java.lang.Object

Helper class for parsing command line arguments.


Nested Class Summary
static class CommandLine.HelpRequestedException
           
 
Constructor Summary
CommandLine()
           
 
Method Summary
 void addOption(java.lang.String option, java.lang.String argumentDesc, java.lang.String description)
          Add an option requiring an argument.
 void addSwitch(java.lang.String option, java.lang.String description)
          Add a command line switch.
 void addSwitchWithOptionalExtraPart(java.lang.String option, java.lang.String optionExtraPartSynopsis, java.lang.String description)
          Add a command line switch that allows optional extra information to be specified as part of it.
static java.lang.String[] expandOptionFiles(java.lang.String[] argv, boolean ignoreComments, boolean ignoreBlankLines)
          Expand option files in given command line.
protected abstract  void handleOption(java.lang.String option, java.lang.String optionExtraPart)
          Callback method for handling an option.
protected abstract  void handleOptionWithArgument(java.lang.String option, java.lang.String argument)
          Callback method for handling an option with an argument.
 void makeOptionUnlisted(java.lang.String option)
          Don't list this option when printing Usage information
 int parse(java.lang.String[] argv)
          Parse a command line.
 int parse(java.lang.String[] argv, int minArgs, int maxArgs, java.lang.String usage)
           
 void printUsage(java.io.OutputStream os)
          Print command line usage information to given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLine

public CommandLine()
Method Detail

addSwitch

public void addSwitch(java.lang.String option,
                      java.lang.String description)
Add a command line switch. This method is for adding options that do not require an argument.

Parameters:
option - the option, must start with "-"
description - single line description of the option

addSwitchWithOptionalExtraPart

public void addSwitchWithOptionalExtraPart(java.lang.String option,
                                           java.lang.String optionExtraPartSynopsis,
                                           java.lang.String description)
Add a command line switch that allows optional extra information to be specified as part of it.

Parameters:
option - the option, must start with "-"
optionExtraPartSynopsis - synopsis of the optional extra information
description - single-line description of the option

addOption

public void addOption(java.lang.String option,
                      java.lang.String argumentDesc,
                      java.lang.String description)
Add an option requiring an argument.

Parameters:
option - the option, must start with "-"
argumentDesc - brief (one or two word) description of the argument
description - single line description of the option

makeOptionUnlisted

public void makeOptionUnlisted(java.lang.String option)
Don't list this option when printing Usage information

Parameters:
option -

expandOptionFiles

public static java.lang.String[] expandOptionFiles(java.lang.String[] argv,
                                                   boolean ignoreComments,
                                                   boolean ignoreBlankLines)
                                            throws java.io.IOException
Expand option files in given command line. Any token beginning with "@" is assumed to be an option file. Option files contain one command line option per line.

Parameters:
argv - the original command line
ignoreComments - ignore comments (lines starting with "#")
ignoreBlankLines - ignore blank lines
Returns:
the expanded command line
Throws:
java.io.IOException

parse

public int parse(java.lang.String[] argv,
                 int minArgs,
                 int maxArgs,
                 java.lang.String usage)

parse

public int parse(java.lang.String[] argv)
          throws java.io.IOException,
                 CommandLine.HelpRequestedException
Parse a command line. Calls down to handleOption() and handleOptionWithArgument() methods. Stops parsing when it reaches the end of the command line, or when a command line argument not starting with "-" is seen.

Parameters:
argv - the arguments
Returns:
the number of arguments parsed; if equal to argv.length, then the entire command line was parsed
Throws:
CommandLine.HelpRequestedException
java.io.IOException

handleOption

protected abstract void handleOption(java.lang.String option,
                                     java.lang.String optionExtraPart)
                              throws java.io.IOException
Callback method for handling an option.

Parameters:
option - the option
optionExtraPart - the "extra" part of the option (everything after the colon: e.g., "withMessages" in "-xml:withMessages"); the empty string if there was no extra part
Throws:
java.io.IOException

handleOptionWithArgument

protected abstract void handleOptionWithArgument(java.lang.String option,
                                                 java.lang.String argument)
                                          throws java.io.IOException
Callback method for handling an option with an argument.

Parameters:
option - the option
argument - the argument
Throws:
java.io.IOException

printUsage

public void printUsage(java.io.OutputStream os)
Print command line usage information to given stream.

Parameters:
os - the output stream

FindBugs™ 1.3.4

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.