iaik.tc.utils.cmdline
Class ParamParser

java.lang.Object
  extended by iaik.tc.utils.cmdline.CommonParser
      extended by iaik.tc.utils.cmdline.ParamParser

public class ParamParser
extends CommonParser

This class parses the command line configuration options. The developer can add a set of parameters which are parsed by the this class. The parsed values are then made accessible via getter methods.


Constructor Summary
ParamParser()
          Default constructor.
 
Method Summary
 void addParam(Param param)
          This method is used to add a new parameter that should be handled by the parser.
 java.lang.String getDefaultValue(java.lang.String key)
          This method returns the default value for the given key.
 java.lang.String getValue(java.lang.String key)
          This method returns the corresponding value for the given key.
 boolean isPresent(java.lang.String key)
          This method returns true if the given key is present (i.e.
 void parse(java.lang.String[] args)
          This method parses the the given command line arguments.
 void parse(java.lang.String[] args, int offset)
          This method parses the the given command line arguments.
 void printUsage()
          This method prints the usage message of the application.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParamParser

public ParamParser()
Default constructor.

Method Detail

addParam

public void addParam(Param param)
This method is used to add a new parameter that should be handled by the parser.

Parameters:
param - new command line parameter

parse

public void parse(java.lang.String[] args)
           throws java.lang.IllegalArgumentException
This method parses the the given command line arguments.

Parameters:
args - The command line arguments to be parsed.
Throws:
java.lang.IllegalArgumentException

parse

public void parse(java.lang.String[] args,
                  int offset)
           throws java.lang.IllegalArgumentException
This method parses the the given command line arguments.

Parameters:
args - The command line arguments to be parsed.
offset - This defines an offset where to start parsing the args parameter.
Throws:
java.lang.IllegalArgumentException

getValue

public java.lang.String getValue(java.lang.String key)
This method returns the corresponding value for the given key.

Parameters:
key -
Returns:
value for given key

getDefaultValue

public java.lang.String getDefaultValue(java.lang.String key)
This method returns the default value for the given key.

Parameters:
key -
Returns:
the default value

isPresent

public boolean isPresent(java.lang.String key)
This method returns true if the given key is present (i.e. the given key was specified by the user on the command line).

Parameters:
key -
Returns:
presence status

printUsage

public void printUsage()
This method prints the usage message of the application. The message is assembled from the individual parts of the command line parameters.