org.openmdx.base.application.control
Class CmdLineArgs

java.lang.Object
  extended by org.openmdx.base.application.control.CmdLineArgs

public class CmdLineArgs
extends Object

CmdLineArgs holds the parsed command line arguments.


Constructor Summary
CmdLineArgs()
           
 
Method Summary
 Properties getAsProperties()
          Returns all command line attribute as Properties
 String getFirstValue(String id)
          Returns the first command line attribute value of a possible multi-value option id.
 List getFreeArgs()
          Get the non option (free) arguments
 List getRawArgs()
          Returns the argument list as passed in by Java main()
 List getValues(String id)
          Returns all command line attribute values for a given option id.
 boolean hasArg(String id)
          Checks wether the argument given by 'id' has been passed in the command line The option id has no leading option marker "-", "--" E.g.
 boolean readArgumentFile(String fileName)
          Reads additional arguments from an external argument file, and mergers it with current raw args
 void setParsedArgs(ArrayList parsedArgs, ArrayList parsedFreeArgs)
          Set the parsed command line arguments
 void setRawArgs(String[] args)
          Set the raw command line arguments
 String toString()
          Returns a string representation of the parsed arguments
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CmdLineArgs

public CmdLineArgs()
Method Detail

hasArg

public boolean hasArg(String id)
Checks wether the argument given by 'id' has been passed in the command line The option id has no leading option marker "-", "--" E.g. args.hasArg("k") // short option -k args.hasArg("host") // long option --host

Returns:
true if arg has been set

getFirstValue

public String getFirstValue(String id)
Returns the first command line attribute value of a possible multi-value option id. The attribute may be an empty string if the option is defined with 'optional_argument' and no arguments have been passed. The option id has no leading option marker "-", "--" E.g. args.getFirstValue("k") // short option -k args.getFirstValue("host") // long option --host

Returns:
A string or null

getValues

public List getValues(String id)
Returns all command line attribute values for a given option id. Only arguments with non zero strings are passed back. The option id has no leading option marker "-", "--" E.g. args.getValues("k") // short option -k args.getValues("host") // long option --host

Returns:
A list of Strings

getAsProperties

public Properties getAsProperties()
Returns all command line attribute as Properties

Switches: property-name=name; property-value=(null)

Single value arguments: property-name=name; property-value=value

Multiple value arguments: property-name=name[ii]; property-value=value

Free arguments: property-name=free-arg[ii]; property-value=value

Returns:
A list of Strings

getFreeArgs

public List getFreeArgs()
Get the non option (free) arguments

Returns:
A list of Strings

getRawArgs

public List getRawArgs()
Returns the argument list as passed in by Java main()

Returns:
The args

toString

public String toString()
Returns a string representation of the parsed arguments

Overrides:
toString in class Object
Returns:
A string

setRawArgs

public void setRawArgs(String[] args)
Set the raw command line arguments

Parameters:
args - The arguments from main()

setParsedArgs

public void setParsedArgs(ArrayList parsedArgs,
                          ArrayList parsedFreeArgs)
Set the parsed command line arguments

Parameters:
parsedArgs - The parsed arguments a list of objects of class CmdLineArg
parsedFreeArgs - The parsed free arguments a list of objects of class String

readArgumentFile

public boolean readArgumentFile(String fileName)
Reads additional arguments from an external argument file, and mergers it with current raw args

Parameters:
fileName - an argument file
Returns:
true on successful reading the file


This software is published under the BSD license. Copyright © 2003-2007, OMEX AG, Switzerland, All rights reserved. Use is subject to license terms.