org.finetracker
Class ConfigurationFromCmd

java.lang.Object
  extended by org.finetracker.ConfigurationFromCmd

public class ConfigurationFromCmd
extends java.lang.Object

This class parses the command line arguments, and stores them in two data structures. The first data structure is a Map which stores parameters with their values. The second datas structure is a List which stores the remaining arguments. The parameters can be retrieved using getOption(String parameter), and the arguments using getArguments(). There is one exception: if '--exportconfig' is defined, its value is stored in a separate String. The set-methods in this class have 'Long' and 'Short' variants. They are implemented equally, but the \@Option statements differ. The long ones are used for arguments with two dashes (like '--wordentrancepenalty', while the short ones are used for arguments with one dash ('-wip'). This class is only used by Configuration.

Author:
Frank Kusters

Constructor Summary
ConfigurationFromCmd(java.lang.String[] args)
          Constructs a ConfigurationFromCmd object containing settings read from the command line, retrieved from args.
 
Method Summary
 java.util.List<java.lang.String> getArguments()
          Gets the list of arguments (any options that do not start with a dash ('-')).
 java.io.File getExportConfig()
          Gets the file to export the default configuration to.
 java.lang.Double getOption(java.lang.String parameter)
          Get the value belonging to the option specified on the command line.
 java.lang.String getUsageString()
          Returns the usage (command line options) of the application.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationFromCmd

public ConfigurationFromCmd(java.lang.String[] args)
                     throws java.io.IOException
Constructs a ConfigurationFromCmd object containing settings read from the command line, retrieved from args.

Parameters:
args - an array of Strings containing the arguments as normally used in a main() method.
Throws:
java.io.IOException - when the commandline could not be parsed correctly
Method Detail

getUsageString

public java.lang.String getUsageString()
Returns the usage (command line options) of the application. The returned string is meant for display to the user.

Returns:
the command line options of the applications combined with explaining text

getExportConfig

public java.io.File getExportConfig()
Gets the file to export the default configuration to.

Returns:
the file to export the default configuration to, or null if the file was not specified (so no configuration needs to be exported).

getOption

public java.lang.Double getOption(java.lang.String parameter)
Get the value belonging to the option specified on the command line.

Parameters:
parameter - the parameter
Returns:
the value belonging to the parameter, or null if the parameter was not specified.

getArguments

public java.util.List<java.lang.String> getArguments()
Gets the list of arguments (any options that do not start with a dash ('-')).

Returns:
the list of arguments. If no arguments where specified, the list is of zero-length.