org.writersforge.catalan.util
Class CommandArgs

java.lang.Object
  extended byorg.writersforge.catalan.util.CommandArgs

public class CommandArgs
extends java.lang.Object

Utility class for managing command line arguments.

Author:
jsheets

Constructor Summary
CommandArgs(java.lang.String[] args)
          Creates a new instance of CommandArgs.
 
Method Summary
 java.lang.String getNamedArg(java.lang.String name)
          Retrieves the value of the named argument, or null if the argument does not exist.
 java.util.Map getNamedArgs()
          Retrieves a Map of named arguments, i.e., matched pairs of arguments consisting of an argument name prefixed by "-" or "--" and the following value of that argument.
 java.lang.String[] getParams()
          Retrieves all unnamed arguments.
 java.lang.String[] getRawArgs()
          Retrieves the full original array of command-line arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandArgs

public CommandArgs(java.lang.String[] args)
Creates a new instance of CommandArgs.

Parameters:
args - command-line arguments
Method Detail

getRawArgs

public java.lang.String[] getRawArgs()
Retrieves the full original array of command-line arguments.

Returns:
raw command-line arguments

getNamedArgs

public java.util.Map getNamedArgs()
Retrieves a Map of named arguments, i.e., matched pairs of arguments consisting of an argument name prefixed by "-" or "--" and the following value of that argument. For example, an argument array of [ "-f", "myfile", "--basedir", "mybasedir", "param1", "param2" ] would yield a Map with the keys "f" and "basedir", which mapped to the values "myfile" and "mybasedir", respectively. The unnamed arguments "param1" and "param2" would not show up in the named argument Map.

Returns:
named argument map

getNamedArg

public java.lang.String getNamedArg(java.lang.String name)
Retrieves the value of the named argument, or null if the argument does not exist.

Parameters:
name - argument name
Returns:
argument value, or null if not found

getParams

public java.lang.String[] getParams()
Retrieves all unnamed arguments. For example, an argument array of [ "-f", "myfile", "--basedir", "mybasedir", "param1", "param2" ] would yield an array of [ "param1", "param2" ], ignoring the named argument/value pairs of "-f" and "--basedir".

Returns:
unnamed arguments