2.17.2: 2011-06-17

net.sf.basedb.clients.jobagent
Class CmdLine

java.lang.Object
  extended by net.sf.basedb.clients.jobagent.CmdLine

public class CmdLine
extends Object

Utility class for parsing command line arguments. It supports a very limitied syntax: [options] [cmd]

Options starts with hyphen (-) and may have a value following it. The last parameter is the command unless it starts with a hyphen.

Examples:

./jobagent.sh start
./jobagent.sh -c agent.properties stop

Version:
2.0
Author:
nicklas
Last modified
$Date: 2008-09-11 22:05:50 +0200 (Thu, 11 Sep 2008) $

Field Summary
private  String cmd
           
private  Map<String,String> options
           
 
Constructor Summary
CmdLine(String[] args)
          Create a new object for parsing the command line.
 
Method Summary
 String getCmd()
          Get the command parameter
 String getOption(String option)
          Get the value for the specified option
 String getOption(String option, String defaultValue)
          Get the value for an option.
 boolean hasOption(String option)
          Check if an option was specified or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

options

private final Map<String,String> options

cmd

private final String cmd
Constructor Detail

CmdLine

public CmdLine(String[] args)
Create a new object for parsing the command line.

Parameters:
args - The command line arguments sent to the main() method
Method Detail

getCmd

public String getCmd()
Get the command parameter

Returns:
The command parameter, or null

getOption

public String getOption(String option)
Get the value for the specified option

Parameters:
option - The option to get the value for
Returns:
The value or null

getOption

public String getOption(String option,
                        String defaultValue)
Get the value for an option.

Parameters:
option - The option to get the value for
defaultValue - A default value if the option wasn't specified
Returns:
The options value or the default value

hasOption

public boolean hasOption(String option)
Check if an option was specified or not.

Parameters:
option - The option to check
Returns:
TRUE if the option was specified, FALSE otherwise

2.17.2: 2011-06-17