startup
Class ParameterFileParser

java.lang.Object
  extended by startup.ParameterFileParser

public final class ParameterFileParser
extends java.lang.Object

This class is used for loading an parsing the parameterfile for the FunSiP project. The parsing of the parameterfile should not take too long, and care is taken that as many faulty inputs as possible are catched by the system before poisining the workflow.

Author:
Michiel Van Bel

Field Summary
static int MIN_TABS
           
 
Constructor Summary
ParameterFileParser(org.apache.log4j.Logger logger)
          Constructor for the Parameter file parser.
 
Method Summary
static java.io.File createConfigurationFile(ClassificationAction action, java.lang.String fileName)
          This method creates the configuration file for a single classification-action, so the classification can be started remotely.
 FunSiPWorkflow fatalErrorExit(java.lang.String message)
          Method which displays the given string and then exists the program, due to the fact that one of the parameters could not be parsed.
static java.lang.String getConfigString(java.lang.String command, java.lang.String result)
          This method creates a string that contains both a parameter and its value.
static java.lang.String getConfigString(java.lang.String command, java.lang.String[] result)
          This method creates a string that contains both a parameter and its values.
static java.lang.String getConfigurationFileString(ClassificationAction ca)
          This method creates the string that is associated with the given classification action.
static java.lang.String getConfigurationFileString(FunSiPWorkflow workflow)
          This method creates a single string that contains the entire configuration file.
 FunSiPWorkflow parseFile(java.lang.String fileName)
          This method parses a configuration file and sets all the appropiate values to the parameters defined in the configuration file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_TABS

public static final int MIN_TABS
See Also:
Constant Field Values
Constructor Detail

ParameterFileParser

public ParameterFileParser(org.apache.log4j.Logger logger)
Constructor for the Parameter file parser.

Parameters:
logger - The logging facility used by the parser.
Method Detail

getConfigString

public static java.lang.String getConfigString(java.lang.String command,
                                               java.lang.String result)
This method creates a string that contains both a parameter and its value. The line is produced in the most aesthetically feasible way.

Parameters:
command - The parameter command
result - The parameter value
Returns:
The resulting string.

getConfigString

public static java.lang.String getConfigString(java.lang.String command,
                                               java.lang.String[] result)
This method creates a string that contains both a parameter and its values. The lines is produced in the most aesthetically feasible way.

Parameters:
command - The parameter command.
result - The parameter values
Returns:
The resulting string

getConfigurationFileString

public static java.lang.String getConfigurationFileString(FunSiPWorkflow workflow)
This method creates a single string that contains the entire configuration file. It first defines the data for the workflow, after which it iterates over the various classification actions that are defined in the workflow. This method can for example by used by interactive programs that change the content of a configuration file, and want this changes to be kept.

Parameters:
workflow - The workflow for which a configuration file needs to be defined.
Returns:
The string that consists of the entire content of the configuration file associated with the workflow.

getConfigurationFileString

public static java.lang.String getConfigurationFileString(ClassificationAction ca)
This method creates the string that is associated with the given classification action. It is clear that the produced string cannot be used on its own. Instead, the produced string should be used inside a workflow command string.

Parameters:
ca - The classification action for which the configuration file string should be produced.
Returns:
The configuration file string associated with the provided classification action.

createConfigurationFile

public static java.io.File createConfigurationFile(ClassificationAction action,
                                                   java.lang.String fileName)
                                            throws java.io.IOException
This method creates the configuration file for a single classification-action, so the classification can be started remotely. This method's primary use is aimed at creating configurationfiles for jobs that will be started on the cluster. Towards this end, a standard workflow object will be created, to which the provided classificationAction will be added. Following up to the fact that only one classification-action is defined and will be used, several of the general_options will be disabled: a) is useless with less than two classification actions b) should definitily be disabled, since it

Parameters:
action - The classification action for which a configuration file should be produced.
fileName - The name for the file to which the configuration data should be written.
Returns:
The file containing the configuration data.
Throws:
java.io.IOException - In case the production of the configurationfile goes wrong.

parseFile

public FunSiPWorkflow parseFile(java.lang.String fileName)
This method parses a configuration file and sets all the appropiate values to the parameters defined in the configuration file. The method tries to locate the configuration file in different ways, dependent on whether or not the program is started from a jar-archive or not.

Parameters:
fileName - The name of the configuration file.
Returns:
The workflow-object with all its options set, and with its defined classification actions.

fatalErrorExit

public FunSiPWorkflow fatalErrorExit(java.lang.String message)
Method which displays the given string and then exists the program, due to the fact that one of the parameters could not be parsed. Because it is still unclear which options are necessary and which are optional, we opted to halt the program on every parsing error, to prevent faulty or unclear results.

Parameters:
message - The message to be displayed.