eaLib API Docs
Last Modified : January 7 2002

mss.ea.conf
Class Configuration

java.lang.Object
  |
  +--mss.ea.conf.Configuration

public class Configuration
extends java.lang.Object

Supports the configuration of the whole eaLib package. The configuration is a tree-like structure similiar to the Windows registry. There are two internal trees: the system and the user tree. It is only possible to generate keys in the user tree, the system tree contains read-only values. Keys in the user tree mask those in the system tree. The format of the keys is 'my.key.foo'.

Since:
0.1
Version:
$Revision: 1.8 $ $Date: 2001/12/20 14:53:38 $
Author:
Andreas Rummler

Field Summary
protected static java.util.TreeMap systemMap
          Tree map containing the system tree.
protected static java.util.TreeMap userMap
          Tree map containing the user map.
 
Constructor Summary
Configuration()
           
 
Method Summary
static boolean getBoolean(java.lang.String key)
          Gets a boolean object.
static double getDouble(java.lang.String key)
          Gets a double.
static float getFloat(java.lang.String key)
          Gets a float.
protected static java.lang.String getIndent(int level)
          Gets the number of tabs for indentation.
static int getInteger(java.lang.String key)
          Gets an integer.
static long getLong(java.lang.String key)
          Gets a long.
protected static java.lang.Object getObject(java.lang.String fullPath)
          Gets an Object by its key.
protected static java.lang.Object getObject(java.lang.String[] fullPath)
          Gets an Object by its key.
protected static java.lang.Object getObject(java.lang.String[] fullPath, java.util.TreeMap map)
          Gets an Object by its key from the given treemap.
protected static java.lang.Object getObject(java.lang.String nodePath, java.lang.String key)
          Gets an Object by its key.
static java.lang.String getString(java.lang.String key)
          Gets a string.
static java.util.Iterator iterateEntries(java.lang.String key)
          Iterates over all entries under the given key.
protected static void printMap(java.util.TreeMap map, int level)
          Prints the given tree map to System.out.
static void printSystemMap()
          Prints the system tree to System.out.
static void printUserMap()
          Prints the user tree to System.out.
protected static void processElement(net.n3.nanoxml.XMLElement element, java.util.TreeMap parentMap)
          Processes an XML element.
protected static void removeKey(java.lang.String key, java.util.TreeMap map)
          Removes a key from the given treemap.
protected static void removeSystemKey(java.lang.String key)
          Removes a key from the system tree.
static void removeUserKey(java.lang.String key)
          Removes a key from the user tree.
protected static void setKey(java.lang.String key, java.lang.String value, java.util.TreeMap map)
          Stores a key-value pair in the given treemap.
protected static void setSystemKey(java.lang.String key, java.lang.String value)
          Stores a key-value-pair in the sytem tree.
static void setUserKey(java.lang.String key, java.lang.String value)
          Stores a key-value-pair in the user tree.
protected static java.lang.String[] tokenizeKey(java.lang.String path)
          Tokenizes a key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

systemMap

protected static java.util.TreeMap systemMap
Tree map containing the system tree.

userMap

protected static java.util.TreeMap userMap
Tree map containing the user map.
Constructor Detail

Configuration

public Configuration()
Method Detail

processElement

protected static void processElement(net.n3.nanoxml.XMLElement element,
                                     java.util.TreeMap parentMap)
Processes an XML element. This method is used for reading the XML configuration file and storing the keys in the tree.
Parameters:
element - XML element
parentMap - parent tree map of the element

tokenizeKey

protected static java.lang.String[] tokenizeKey(java.lang.String path)
Tokenizes a key.
Parameters:
path - path to a key
Returns:
array with tokens of the key string

getObject

protected static java.lang.Object getObject(java.lang.String fullPath)
Gets an Object by its key.
Parameters:
fullPath - key path to the object
Returns:
object stored under the given key, null if the key does not exist

getObject

protected static java.lang.Object getObject(java.lang.String nodePath,
                                            java.lang.String key)
Gets an Object by its key.
Parameters:
nodePath - key path to the tree map of the object
key - key of the object
Returns:
object stored under the given key, null if the key does not exist

getObject

protected static java.lang.Object getObject(java.lang.String[] fullPath)
Gets an Object by its key.
Parameters:
fullPath - key path stored in a string array
Returns:
object stored under the given key, null if the key does not exist

getObject

protected static java.lang.Object getObject(java.lang.String[] fullPath,
                                            java.util.TreeMap map)
Gets an Object by its key from the given treemap.
Parameters:
fullPath - key path to the object
map - treemap to look up for the object
Returns:
object stored under the given key, null if the key does not exist

getBoolean

public static boolean getBoolean(java.lang.String key)
Gets a boolean object.
Parameters:
key - key path to the object
Returns:
boolean value stored under the given key

getDouble

public static double getDouble(java.lang.String key)
Gets a double.
Parameters:
key - key path to the object
Returns:
double value stored under the given key

getFloat

public static float getFloat(java.lang.String key)
Gets a float.
Parameters:
key - key path to the object
Returns:
float value stored under the given key

getInteger

public static int getInteger(java.lang.String key)
Gets an integer.
Parameters:
key - key path to the object
Returns:
integer value stored under the given key

getLong

public static long getLong(java.lang.String key)
Gets a long.
Parameters:
key - key path to the object
Returns:
long value stored under the given key

getString

public static java.lang.String getString(java.lang.String key)
Gets a string.
Parameters:
key - key path to the object
Returns:
string value stored under the given key

iterateEntries

public static java.util.Iterator iterateEntries(java.lang.String key)
Iterates over all entries under the given key. The iterator points to objects of type Map.Entry.
Parameters:
key - key path to the object
Returns:
iterator over entries

setKey

protected static void setKey(java.lang.String key,
                             java.lang.String value,
                             java.util.TreeMap map)
Stores a key-value pair in the given treemap.
Parameters:
key - key
value - value
map - treemap for key-value-pair storage

setSystemKey

protected static void setSystemKey(java.lang.String key,
                                   java.lang.String value)
Stores a key-value-pair in the sytem tree.
Parameters:
key - key
value - value

setUserKey

public static void setUserKey(java.lang.String key,
                              java.lang.String value)
Stores a key-value-pair in the user tree.
Parameters:
key - key
value - value

removeKey

protected static void removeKey(java.lang.String key,
                                java.util.TreeMap map)
Removes a key from the given treemap.
Parameters:
key - key to remove
map - treemap to remove key from

removeSystemKey

protected static void removeSystemKey(java.lang.String key)
Removes a key from the system tree.
Parameters:
key - key to remove

removeUserKey

public static void removeUserKey(java.lang.String key)
Removes a key from the user tree.
Parameters:
key - key to remove

printSystemMap

public static void printSystemMap()
Prints the system tree to System.out.

printUserMap

public static void printUserMap()
Prints the user tree to System.out.

printMap

protected static void printMap(java.util.TreeMap map,
                               int level)
Prints the given tree map to System.out.
Parameters:
map - treemap to print
level - level of indentation

getIndent

protected static java.lang.String getIndent(int level)
Gets the number of tabs for indentation.
Parameters:
level - level of indentation
Returns:
string containing a number of tabs

eaLib API Docs
Last Modified : January 7 2002

Copyright © 2000-2001 Technical University of Ilmenau, Department ESS