de.hpi.fgis.dude.util
Class GlobalConfig

java.lang.Object
  extended by de.hpi.fgis.dude.util.GlobalConfig

public class GlobalConfig
extends Object

GlobalConfig manages the configuration parameters of DuDe.

Author:
Matthias Pohl

Field Summary
static String PARAM_NAME_DEFAULT_DIRECTORY
          The name of DuDe's default directory.
static String PARAM_NAME_DEFAULT_ENCODING
          The name of DuDe's default encoding.
static String PARAM_NAME_FORMATTED_JSON_OUTPUT
          Name of the parameter for specifying if the formatted Json shall be printed.
static String PARAM_NAME_MAXIMUM_MEMORY_USAGE
          Name of the parameter for specifying the maximum memory usage.
static String PARAM_NAME_MEMORY_CHECKER_STEP_SIZE
          Name of the parameter for specifying how many records can be loaded into memory when using the MemoryChecker.
static String PARAM_VALUE_DEFAULT_DIRECTORY
          The default directory where all files are stored during file-based processing.
static String PARAM_VALUE_DEFAULT_ENCODING
          The default encoding that is used internally.
static boolean PARAM_VALUE_FORMATTED_JSON_OUTPUT
          The default setting of the parameter that specifies if the Json written to the file is formatted or not.
static double PARAM_VALUE_MAXIMUM_MEMORY_USAGE
          The default maximum memory usage for sorting the data in percent.
static int PARAM_VALUE_MEMORY_CHECKER_STEP_SIZE
          The default setting of the parameter that specifies how many records can be loaded into memory when using the MemoryChecker.
 
Method Summary
 void deleteWorkingDirOnExit()
           
 void disableFormattedJson()
          Disables formatted Json.
 void enableFormattedJson()
          Enables formatted Json.
 boolean formattedJsonIsEnabled()
          Checks whether formatted Json is enabled.
 String getDefaultEncoding()
          Returns the default encoding used by DuDe.
 int getInMemoryObjectThreshold()
          Returns the maximum number of DuDeObject that will be stored in memory, if file-based processing is enabled.
static GlobalConfig getInstance()
          Returns the Singleton instance of GlobalConfig.
 double getMaximumMemoryUsage()
          Returns the maximum relative memory used during the sorting phase.
 String getWorkingDirectory()
          Returns the working directory path.
 boolean loadConfig(Properties properties)
          Loads the configuration from the passed Properties.
 void saveConfig(OutputStream outputStream)
          Persists the current configuration using the Properties format.
 void setCommandLineArguments(String[] args)
          Sets the global configuration based on the command-line arguments.
 void setDefaultEncoding(String defaultEnc)
          Sets DuDe's default encoding for file-based data-processing.
 void setInMemoryObjectThreshold(int value)
          Sets the threshold for storing DuDeObjects in memory, if file-based processing is enabled.
protected  void setInMemoryObjectThreshold(String str)
          Sets the in-memory object threshold based on the passed String.
 void setMaximumMemoryUsage(double value)
          Sets the maximum relative memory that is used for sorting the data.
protected  void setMaximumMemoryUsage(String str)
          Sets the maximum relative memory usage based on the passed String.
 void setWorkingDirectory(String workingDir)
          Sets DuDe's default directory for file-based data-processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_VALUE_DEFAULT_ENCODING

public static final String PARAM_VALUE_DEFAULT_ENCODING
The default encoding that is used internally.

See Also:
Constant Field Values

PARAM_NAME_DEFAULT_ENCODING

public static final String PARAM_NAME_DEFAULT_ENCODING
The name of DuDe's default encoding.

See Also:
Constant Field Values

PARAM_VALUE_DEFAULT_DIRECTORY

public static final String PARAM_VALUE_DEFAULT_DIRECTORY
The default directory where all files are stored during file-based processing.

See Also:
Constant Field Values

PARAM_NAME_DEFAULT_DIRECTORY

public static final String PARAM_NAME_DEFAULT_DIRECTORY
The name of DuDe's default directory.

See Also:
Constant Field Values

PARAM_VALUE_MEMORY_CHECKER_STEP_SIZE

public static final int PARAM_VALUE_MEMORY_CHECKER_STEP_SIZE
The default setting of the parameter that specifies how many records can be loaded into memory when using the MemoryChecker.

See Also:
MemoryChecker.enoughMemoryAvailable(), Constant Field Values

PARAM_NAME_MEMORY_CHECKER_STEP_SIZE

public static final String PARAM_NAME_MEMORY_CHECKER_STEP_SIZE
Name of the parameter for specifying how many records can be loaded into memory when using the MemoryChecker.

See Also:
Constant Field Values

PARAM_VALUE_MAXIMUM_MEMORY_USAGE

public static final double PARAM_VALUE_MAXIMUM_MEMORY_USAGE
The default maximum memory usage for sorting the data in percent.

See Also:
Constant Field Values

PARAM_NAME_MAXIMUM_MEMORY_USAGE

public static final String PARAM_NAME_MAXIMUM_MEMORY_USAGE
Name of the parameter for specifying the maximum memory usage.

See Also:
Constant Field Values

PARAM_VALUE_FORMATTED_JSON_OUTPUT

public static final boolean PARAM_VALUE_FORMATTED_JSON_OUTPUT
The default setting of the parameter that specifies if the Json written to the file is formatted or not.

See Also:
Constant Field Values

PARAM_NAME_FORMATTED_JSON_OUTPUT

public static final String PARAM_NAME_FORMATTED_JSON_OUTPUT
Name of the parameter for specifying if the formatted Json shall be printed.

See Also:
Constant Field Values
Method Detail

getInstance

public static GlobalConfig getInstance()
Returns the Singleton instance of GlobalConfig.

Returns:
The Singleton instance.

getDefaultEncoding

public String getDefaultEncoding()
Returns the default encoding used by DuDe.

Returns:
The default encoding.

setDefaultEncoding

public void setDefaultEncoding(String defaultEnc)
Sets DuDe's default encoding for file-based data-processing.

Parameters:
defaultEnc - The new default directory.

getWorkingDirectory

public String getWorkingDirectory()
Returns the working directory path. This directory is used for storing all files that are generated during file-based processing of the data.

Returns:
The path of the working directory.

deleteWorkingDirOnExit

public void deleteWorkingDirOnExit()

setWorkingDirectory

public void setWorkingDirectory(String workingDir)
Sets DuDe's default directory for file-based data-processing.

Parameters:
workingDir - The new default directory.

getInMemoryObjectThreshold

public int getInMemoryObjectThreshold()
Returns the maximum number of DuDeObject that will be stored in memory, if file-based processing is enabled.

Returns:
The in-memory object count.
See Also:
MemoryChecker

setInMemoryObjectThreshold

public void setInMemoryObjectThreshold(int value)
Sets the threshold for storing DuDeObjects in memory, if file-based processing is enabled.

Parameters:
value - The new threshold.
See Also:
MemoryChecker

setInMemoryObjectThreshold

protected void setInMemoryObjectThreshold(String str)
                                   throws NumberFormatException
Sets the in-memory object threshold based on the passed String.

Parameters:
str - The String that shall be converted in a valid threshold.
Throws:
NumberFormatException - If the passed String could not be converted into an Integer value.

getMaximumMemoryUsage

public double getMaximumMemoryUsage()
Returns the maximum relative memory used during the sorting phase.

Returns:
The maximum relative memory usage.

setMaximumMemoryUsage

public void setMaximumMemoryUsage(double value)
Sets the maximum relative memory that is used for sorting the data. The passed value needs to be within the range of 0 and 1.

Parameters:
value - The maximum relative memory usage.

setMaximumMemoryUsage

protected void setMaximumMemoryUsage(String str)
                              throws NumberFormatException
Sets the maximum relative memory usage based on the passed String.

Parameters:
str - The String that shall be converted into a valid Double value.
Throws:
NumberFormatException - If the passed String could not be converted into a Double value.

formattedJsonIsEnabled

public boolean formattedJsonIsEnabled()
Checks whether formatted Json is enabled. If this method returns true the Json code will be formatted within each generated Json file. This makes the Json easier to read but let increase the file size.

Returns:
true, if formatted Json is enabled; otherwise false.

enableFormattedJson

public void enableFormattedJson()
Enables formatted Json.


disableFormattedJson

public void disableFormattedJson()
Disables formatted Json.


loadConfig

public boolean loadConfig(Properties properties)
Loads the configuration from the passed Properties.

Parameters:
properties - The new parameters.
Returns:
true, if all parameters were set to the new values; otherwise false.

saveConfig

public void saveConfig(OutputStream outputStream)
                throws IOException
Persists the current configuration using the Properties format.

Parameters:
outputStream - The stream onto which the configuration will be written.
Throws:
IOException - If an error occurs during the writing process.

setCommandLineArguments

public void setCommandLineArguments(String[] args)
                             throws IllegalArgumentException
Sets the global configuration based on the command-line arguments.

Parameters:
args - The command-line arguments String array that was passed through the main method parameters.
Throws:
IllegalArgumentException - If an error occurs while parsing the arguments.


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.