iiitToolkit 1.0

de.iiit.xmlconfig
Class Configuration

java.lang.Object
  |
  +--de.iiit.xmlconfig.Configuration

public class Configuration
extends Object

Represents the configuration read by ConfigFileReader.

Version:
$Revision: 1.15 $ $Date: 2003/04/02 15:58:01 $

Constructor Summary
protected Configuration(String name)
          Creates a new instance of Configuration
 
Method Summary
 void addAttribute(String key, String value)
          Add a single attribute to the configuration
 void addSubConfiguration(Configuration config)
          Adds a subconfiguration
 String getAttribute(String key)
          Retrieve an attribute of the current configuration with a given name
 String getAttribute(String key, String defaultValue)
          Retrieve an attribute from the current configuration with a given name
 Enumeration getAttributeKeys()
          Returns an Enumeration of all defined attribute names of the current configuration
 Hashtable getAttributes()
          Get the Hashtable containig all attributes of the current configuration
 boolean getBooleanAttribute(String key)
          Retrieve an boolean attribute of the current configuration with a given name
 boolean getBooleanAttribute(String key, boolean defaultValue)
          Retrieve an boolean attribute of the current configuration with a given name
 int getIntAttribute(String key)
          Retrieve an integer attribute of the current configuration with a given name
 int getIntAttribute(String key, int defaultValue)
          Retrieve an integer attribute of the current configuration with a given name
 String getName()
          Get the name of the current configuration
 Configuration getSubConfiguration(String name)
          Retrieve a single sub-configuration with a given name.
 Vector getSubConfigurations()
          Get all sub-configurations of the current configuration
 Vector getSubConfigurations(String name)
          Get all sub-configurations of the current configuration with a given name
static Configuration load(String filename)
          Loads a configuration from a XML file.
 void logConfig()
          Print the current configuration to an already initialized Log4J-Logger with level DEBUG.
 void printConfig()
          Print the current configuration to System.out().
 void save(String filename)
          Saves the XML representation of the current configuration to a file.
protected  void setName(String name)
          Set the name of the current configuration
 StringBuffer toXML()
          Creates a XML representation of the current configuration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Configuration

protected Configuration(String name)
Creates a new instance of Configuration

Parameters:
name - The name of the configuration
Method Detail

load

public static Configuration load(String filename)
                          throws FileNotFoundException,
                                 IOException,
                                 SAXException
Loads a configuration from a XML file.

Parameters:
filename - the full pathname of the file to read.
Returns:
the read configuration or null if the file is empty.
Throws:
FileNotFoundException - if the named file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
IOException - if an I/O error occurs.
SAXException - any SAX exception, possibly wrapping another exception.

save

public void save(String filename)
          throws IOException
Saves the XML representation of the current configuration to a file.

Parameters:
filename - the full pathname of the file to write.
Throws:
IOException - if an I/O error occurs.

toXML

public StringBuffer toXML()
Creates a XML representation of the current configuration

Returns:
the XML data.

logConfig

public void logConfig()
Print the current configuration to an already initialized Log4J-Logger with level DEBUG.


printConfig

public void printConfig()
Print the current configuration to System.out().


setName

protected void setName(String name)
Set the name of the current configuration

Parameters:
name - The name

addSubConfiguration

public void addSubConfiguration(Configuration config)
Adds a subconfiguration

Parameters:
config - The configuration to add

addAttribute

public void addAttribute(String key,
                         String value)
Add a single attribute to the configuration

Parameters:
key - The name of the attribute
value - The value of the attribute

getName

public String getName()
Get the name of the current configuration

Returns:
The name of the current configuration

getSubConfigurations

public Vector getSubConfigurations()
Get all sub-configurations of the current configuration

Returns:
A Vector of Configuration objects or null if there is no subconfiguration

getSubConfigurations

public Vector getSubConfigurations(String name)
Get all sub-configurations of the current configuration with a given name

Parameters:
name - The name of the sub-configuration to retrieve
Returns:
A Vector with the retrieved Configuration Object or null if there is no sub-configuration with the given name.

getSubConfiguration

public Configuration getSubConfiguration(String name)
Retrieve a single sub-configuration with a given name. If there is more than one Block with this name only the first of them is returned.

Parameters:
name - The name of the sub-configuration
Returns:
The sub-configuration or null if there is no one with the given name.

getAttributes

public Hashtable getAttributes()
Get the Hashtable containig all attributes of the current configuration

Returns:
A HashTable with all attributes

getAttribute

public String getAttribute(String key)
Retrieve an attribute of the current configuration with a given name

Parameters:
key - The name of the attribute to retrieve
Returns:
The attribute with the given name or null if there is no attribute with the given name.

getIntAttribute

public int getIntAttribute(String key)
Retrieve an integer attribute of the current configuration with a given name

Parameters:
key - The name of the attribute to retrieve
Returns:
The value of attribute with the given name. If there is no attribute with the given name 0 is returned.

getBooleanAttribute

public boolean getBooleanAttribute(String key)
Retrieve an boolean attribute of the current configuration with a given name

Parameters:
key - The name of the attribute to retrieve
Returns:
The value of attribute with the given name. If there is no attribute with the given name, false is returned.

getAttribute

public String getAttribute(String key,
                           String defaultValue)
Retrieve an attribute from the current configuration with a given name

Parameters:
key - The name of the attribute to retrieve
defaultValue - The value to return if the is no attribute with the given name
Returns:
The attribute with the given name or defaultValue if there is no attribute with the given name.

getIntAttribute

public int getIntAttribute(String key,
                           int defaultValue)
Retrieve an integer attribute of the current configuration with a given name

Parameters:
key - The name of the attribute to retrieve
defaultValue - The value to return if the is no attribute with the given name
Returns:
The attribute with the given name or defaultValue if there is no attribute with the given name.

getBooleanAttribute

public boolean getBooleanAttribute(String key,
                                   boolean defaultValue)
Retrieve an boolean attribute of the current configuration with a given name

Parameters:
key - The name of the attribute to retrieve
defaultValue - The value to return if the is no attribute with the given name
Returns:
The attribute with the given name or defaultValue if there is no attribute with the given name.

getAttributeKeys

public Enumeration getAttributeKeys()
Returns an Enumeration of all defined attribute names of the current configuration

Returns:
An Enumeration of all defined attribute names of the current configuration

iiitToolkit 1.0

Copyright © 2002, 2003 ingeneurbuero fuer innovative informationstechnik, Dipl.-Ing. Joerg Beckmann, Dortmund, Germany. All Rights Reserved.
See Copyright statement