deegree-tools-3.0-pre-nightly (2010/03/05 00:05) - official

org.deegree.tools
Class CommandUtils

java.lang.Object
  extended by org.deegree.tools.CommandUtils

public class CommandUtils
extends Object

This class contains some static convenience methods for commandline tools.

Version:
$Revision: 18595 $, $Date: 2009-07-22 11:06:14 +0200 (Mi, 22 Jul 2009) $
Author:
Oliver Tonnhofer, last edited by: $Author: aionita $

Field Summary
static int HELP_TEXT_WIDTH
          The width of the help text, for automatic text wrap.
 
Constructor Summary
CommandUtils()
           
 
Method Summary
static float getFloatOption(org.apache.commons.cli.CommandLine line, String optName, float defaultValue)
          Parse a command line argument as float.
static int getIntOption(org.apache.commons.cli.CommandLine line, String optName, int defaultValue)
          Parse a command line argument as integer.
static void printHelp(org.apache.commons.cli.Options options, String toolName, String helpMsg, String otherUsageInfo)
          Prints a help message for a apache commons-cli based command line tool and terminates the programm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HELP_TEXT_WIDTH

public static int HELP_TEXT_WIDTH
The width of the help text, for automatic text wrap.

Constructor Detail

CommandUtils

public CommandUtils()
Method Detail

printHelp

public static void printHelp(org.apache.commons.cli.Options options,
                             String toolName,
                             String helpMsg,
                             String otherUsageInfo)
Prints a help message for a apache commons-cli based command line tool and terminates the programm.

Parameters:
options - the options to generate help/usage information for
toolName - the name of the command line tool
helpMsg - some further information
otherUsageInfo - an optional string to append to the usage information (e.g. for additional arguments like input files)

getIntOption

public static int getIntOption(org.apache.commons.cli.CommandLine line,
                               String optName,
                               int defaultValue)
                        throws org.apache.commons.cli.ParseException
Parse a command line argument as integer.

Parameters:
line - the parsed command line
optName - the option name
defaultValue - the default value
Returns:
the parsed integer argument or defaulValue, if the argument is missing
Throws:
org.apache.commons.cli.ParseException - if the argument is not a number

getFloatOption

public static float getFloatOption(org.apache.commons.cli.CommandLine line,
                                   String optName,
                                   float defaultValue)
                            throws org.apache.commons.cli.ParseException
Parse a command line argument as float.

Parameters:
line - the parsed command line
optName - the option name
defaultValue - the default value
Returns:
the parsed float argument or defaulValue, if the argument is missing
Throws:
org.apache.commons.cli.ParseException - if the argument is not a number

deegree-tools-3.0-pre-nightly (2010/03/05 00:05) - official

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org

]]>