org.exolab.jms.util
Class CommandLine

java.lang.Object
  |
  +--org.exolab.jms.util.CommandLine

public class CommandLine
extends java.lang.Object

This core class is responsible for processing the command line and storing away the list of options and parameters specified. The difference between an option and a command line is that an option is a boolean value (true if it is specified and false otherwise) and a parameter always has an associated value.

Version:
$version$
Author:
jima

Constructor Summary
CommandLine()
          Default constructor which simply initialised the class
CommandLine(java.lang.String[] args)
          Construct an instance of this class with the specified string array.
 
Method Summary
 boolean add(java.lang.String name, java.lang.String value)
          Add the following option or parameter to the list.
 boolean add(java.lang.String name, java.lang.String value, boolean overwrite)
          Add the following option or parameter to the list.
 boolean exists(java.lang.String name)
          Check if the following option or command has been specified
 boolean isParameter(java.lang.String name)
          Check if the following parameter has been specified.
 boolean isSwitch(java.lang.String name)
          Check if the following option has been specified.
 java.lang.String value(java.lang.String name)
          Return the value of the parameter or option.
 java.lang.String value(java.lang.String name, java.lang.String defaultValue)
          Return the value of the parameter or option, returning a default value if none is specified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLine

public CommandLine(java.lang.String[] args)
Construct an instance of this class with the specified string array.
Parameters:
args - command line argument

CommandLine

public CommandLine()
Default constructor which simply initialised the class
Method Detail

exists

public boolean exists(java.lang.String name)
Check if the following option or command has been specified
Parameters:
name - name of option or command
Returns:
boolean true if it has been specified

isSwitch

public boolean isSwitch(java.lang.String name)
Check if the following option has been specified.
Parameters:
name - name of the option
Returns:
boolean true if it has been specified

isParameter

public boolean isParameter(java.lang.String name)
Check if the following parameter has been specified.
Parameters:
name - name of the parameter
Returns:
boolean true if it has been specified

value

public java.lang.String value(java.lang.String name)
Return the value of the parameter or option. If the string nominates an option then return null
Parameters:
name - name of option or parameter
Returns:
String value of parameter or null

value

public java.lang.String value(java.lang.String name,
                              java.lang.String defaultValue)
Return the value of the parameter or option, returning a default value if none is specified
Parameters:
name - name of option or parameter
defaultValue - the default value
Returns:
String value of parameter

add

public boolean add(java.lang.String name,
                   java.lang.String value)
Add the following option or parameter to the list. An option will have a null value, whereas a parameter will have a non-null value.

This will automatically overwrite the previous value, if one has been specified.

Parameters:
name - name of option or parameter
value - value of name
Returns:
boolean true if it was successfully added

add

public boolean add(java.lang.String name,
                   java.lang.String value,
                   boolean overwrite)
Add the following option or parameter to the list. An option will have a null value, whereas a parameter will have a non-null value.

If the overwrite flag is true then this value will overwrite the previous value. If the overwrite flag is false and the name already exists then it will not overwrite it and the function will return false. In all other circumstances it will return true.

Parameters:
name - name of option or parameter
value - value of name
overwrite - true to overwrite previous value
Returns:
boolean true if it was successfully added


Copyright © 1999-2007 The OpenJMS Group. All Rights Reserved.