edu.iu.iv.common.boot
Class ConfigFile

java.lang.Object
  |
  +--edu.iu.iv.common.boot.ConfigFile

public class ConfigFile
extends java.lang.Object

A simple config file reader. The format for the config files it reads is the following: Comments are started with either "//", "#", or "[". The last one is used for demarking sections (for example "[IVCInitializer Properties]"). Each property being assigned is formatted as follows: Property = Value. Note that currently if a config file is read in then written out, the comments are not guaranteed to be saved.

Author:
Team IVC

Field Summary
static java.lang.String ERROR_LOG_FILE
           
static java.lang.String LIB_DIRECTORY
           
static java.lang.String PLUGIN_DIRECTORY
           
static java.lang.String USER_LOG_FILE
           
 
Constructor Summary
ConfigFile(java.io.File configFile)
          create a new config file object with the configFile being read in and parsed for any data it may have.
 
Method Summary
 java.util.prefs.Preferences getPreferences()
          Gets the backing java.util.prefs.Preferences node
 java.lang.String getValue(java.lang.String property)
          get the associated value for the property.
 void setProperty(java.lang.String property, java.lang.String value)
          Sets a property for the configuration.
 void writeConfigFile()
          Writes out the config file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIB_DIRECTORY

public static final java.lang.String LIB_DIRECTORY
See Also:
Constant Field Values

PLUGIN_DIRECTORY

public static final java.lang.String PLUGIN_DIRECTORY
See Also:
Constant Field Values

ERROR_LOG_FILE

public static final java.lang.String ERROR_LOG_FILE
See Also:
Constant Field Values

USER_LOG_FILE

public static final java.lang.String USER_LOG_FILE
See Also:
Constant Field Values
Constructor Detail

ConfigFile

public ConfigFile(java.io.File configFile)
           throws java.io.IOException
create a new config file object with the configFile being read in and parsed for any data it may have. If the file is not there, then a new config file with that name will be created with no data currently in it when it is written out.

Parameters:
configFile - the config file to use. it does not have to be currently created.
Throws:
java.io.IOException - if there is any IO problems while reading the file an exception will be thrown.
Method Detail

getValue

public java.lang.String getValue(java.lang.String property)
get the associated value for the property.

Parameters:
property - the property to get its value from.
Returns:
the value of the given property

setProperty

public void setProperty(java.lang.String property,
                        java.lang.String value)
Sets a property for the configuration.

Parameters:
property - the property
value - the property's associated value.

getPreferences

public java.util.prefs.Preferences getPreferences()
Gets the backing java.util.prefs.Preferences node

Returns:
the backing java preferences node.

writeConfigFile

public void writeConfigFile()
                     throws java.io.IOException
Writes out the config file

Throws:
java.io.IOException - if a file error occurs