Hilbert II - Version 0.03.04

org.qedeq.kernel.config
Class ConfigAccess

java.lang.Object
  extended byorg.qedeq.kernel.config.ConfigAccess

final class ConfigAccess
extends Object

This class reads entries from property files. This class should not be used outside this package.

Version:
$Revision: 1.3 $

Constructor Summary
ConfigAccess(File configDirectory, String configFileName, String description)
          Get access for a config file.
 
Method Summary
 String getConfigDescription()
          Get description for config file.
 File getConfigDirectory()
          Get config directory.
 File getConfigFile()
          Get config file.
 String getFileName()
          Get config file name.
 int getInteger(String name)
          Get int property.
 int getInteger(String name, int defaultValue)
          Return int property.
 String getString(String name)
          Return String property.
 String getString(String name, String defaultValue)
          Return String property.
 String[] getStringProperties(String namePrefix)
          Get list of String properties with certain prefix.
 void removeProperties(String namePrefix)
          Remove properties with certain prefix.
 void removeProperty(String name)
          Remove property.
 void setInteger(String name, int value)
          Set int property.
 void setString(String name, String value)
          Set String property.
 void store()
          Store properties in config.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigAccess

public ConfigAccess(File configDirectory,
                    String configFileName,
                    String description)
             throws IOException
Get access for a config file.

Parameters:
configDirectory - Directory location of config file.
configFileName - Name of config file.
description - Config file description
Throws:
IOException - Config file couldn't be loaded.
Method Detail

getConfigDirectory

public final File getConfigDirectory()
Get config directory.

Returns:
Start directory.

getFileName

public final String getFileName()
Get config file name.

Returns:
Config file name.

getConfigFile

public final File getConfigFile()
Get config file.

Returns:
Config file.

getConfigDescription

public final String getConfigDescription()
Get description for config file.

Returns:
Config file description.

store

public final void store()
                 throws IOException
Store properties in config.

Throws:
IOException - Saving failed.

getString

public final String getString(String name)
Return String property.

Parameters:
name - Get this property.
Returns:
String for looked property. null, if property is missing.

getString

public final String getString(String name,
                              String defaultValue)
Return String property.

Parameters:
name - Look for this String property
defaultValue - Return this value if property doesn't exist.
Returns:
Value of property. Equal to default value if parameter doesn't exist.

setString

public final void setString(String name,
                            String value)
Set String property.

Parameters:
name - Set this property.
value - Set property to this value.

getStringProperties

public final String[] getStringProperties(String namePrefix)
Get list of String properties with certain prefix. Example: The sequence of resulting properties is sorted by their keys.

Parameters:
namePrefix - Prefix of seeked property name.
Returns:
List of key sorted string properties (maybe empty).

setInteger

public final void setInteger(String name,
                             int value)
Set int property.

Parameters:
name - Set this property.
value - Set property to this value.

getInteger

public final int getInteger(String name)
Get int property.

Parameters:
name - look for this property
Returns:
property
Throws:
IllegalArgumentException - Property is no valid int value
NullPointerException - Property doesn't exist

getInteger

public final int getInteger(String name,
                            int defaultValue)
Return int property.

Parameters:
name - Look for this integer property.
defaultValue - Return this value if property doesn't exist.
Returns:
int value of property. Equal to default value if parameter doesn't exist.
Throws:
IllegalArgumentException - Property is no valid int value.

removeProperty

public final void removeProperty(String name)
Remove property.

Parameters:
name - Property to delete.

removeProperties

public final void removeProperties(String namePrefix)
Remove properties with certain prefix. Example: Calling with value module deletes all.

Parameters:
namePrefix - Prefix of seeked property name.

Hilbert II - Version 0.03.04

©left GNU General Public Licence
All Rights Reserved.