diff options
author | fotis <fotis@unknown> | 2000-12-17 16:27:21 +0000 |
---|---|---|
committer | fotis <fotis@unknown> | 2000-12-17 16:27:21 +0000 |
commit | 8e4e5122ffdd11ddfb42c3ac16984f453b43aa41 (patch) | |
tree | b5fe7a064a963cdb1c665f694937fcb578e155f5 /src/org/apache/fop/configuration | |
parent | 9ac0c7b6cb2f46fcb822de0bfb3e29dbd0db54a3 (diff) | |
download | xmlgraphics-fop-8e4e5122ffdd11ddfb42c3ac16984f453b43aa41.tar.gz xmlgraphics-fop-8e4e5122ffdd11ddfb42c3ac16984f453b43aa41.zip |
changed configuration design following the ideas of Kelly Campbell
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193884 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/configuration')
6 files changed, 375 insertions, 487 deletions
diff --git a/src/org/apache/fop/configuration/AWTConfiguration.java b/src/org/apache/fop/configuration/AWTConfiguration.java deleted file mode 100644 index 330e51979..000000000 --- a/src/org/apache/fop/configuration/AWTConfiguration.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.apache.fop.configuration; - -import java.util.Vector; -import java.util.Hashtable; -import java.util.Enumeration; - -public class AWTConfiguration { - - /** stores the configuration information */ - private static Hashtable configuration; - - - /** - * general access method - * - * @param key a string containing the key value for the configuration value - * @return Object containing the value; normally you would use one of the - * convenience methods, which return the correct form. - * null if the key is not defined. - */ - public static Object getValue (String key){ - return configuration.get(key); - }; - - /** - * convenience methods to access strings values in the configuration - * @param key a string containing the key value for the configuration value - * @return String a string containing the value - * null if the key is not defined. - */ - public static String getStringValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof String) { - return (String) obj; - } else { - return null; - } - }; - - /** - * convenience methods to access int values in the configuration - * @param key a string containing the key value for the configuration value - * @return int a int containing the value - * -1 if the key is not defined. - */ - public static int getIntValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof String) { - return Integer.parseInt((String) obj); - } else { - return -1; - } - }; - - /** - * convenience methods to access list values in the configuration - * @param key a string containing the key value for the configuration value - * @return Vector a Vector containing the values - * null if the key is not defined. - */ - public static Vector getListValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof Vector) { - return (Vector) obj; - } else { - return null; - } - }; - - /** - * convenience methods to access map/hashtable values in the configuration - * @param key a string containing the key value for the configuration value - * @return Hashtable a Hashtable containing the values - * null if the key is not defined. - */ - public static Hashtable getHashtableValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof Hashtable) { - return (Hashtable) obj; - } else { - return null; - } - }; - - /** - * adds information to the configuration map/hashtable in key,value form - * @param key a string containing the key value for the configuration value - * @param value an Object containing the value; can be a String, a Vector or a Hashtable - */ - public static void put(String key,Object value){ - configuration.put(key,value); - }; - - /** - * debug methods, which writes out all information in this configuration - */ - public static void dumpConfiguration() { - String key; - Object value; - Vector list; - Hashtable map; - Enumeration enum; - String tmp; - System.out.println("Dumping standard configuration: "); - Enumeration enumeration = configuration.keys(); - while (enumeration.hasMoreElements()) { - key = (String) enumeration.nextElement(); - System.out.print(" key: " + key); - value = configuration.get(key); - if (value instanceof String) { - System.out.println(" value: " + value); - } else if (value instanceof Vector) { - list = (Vector) value; - enum = list.elements(); - System.out.print(" value: "); - while (enum.hasMoreElements()) { - System.out.print( enum.nextElement() + " - "); - } - System.out.println(""); - } else if (value instanceof Hashtable) { - map = (Hashtable) value; - enum = map.keys(); - while (enum.hasMoreElements()) { - tmp = (String) enum.nextElement(); - System.out.print(" " + tmp + ":" + map.get(tmp)); - } - System.out.println(""); - } - } - - } - - /** - * initializes this configuration - * @param config contains the configuration information - */ - public static void setup(Hashtable config){ - configuration = config; - } - -} diff --git a/src/org/apache/fop/configuration/Configuration.java b/src/org/apache/fop/configuration/Configuration.java new file mode 100644 index 000000000..1bad17965 --- /dev/null +++ b/src/org/apache/fop/configuration/Configuration.java @@ -0,0 +1,313 @@ + +package org.apache.fop.configuration; + +import java.util.Vector; +import java.util.Hashtable; +import java.util.Enumeration; +import org.apache.fop.messaging.MessageHandler; + +/** + * a configuration class for all general configuration aspects except those + * related to specific renderers. All configuration is stored + * in key / value pairs. The value can be a String, a list of Strings + * or a map, containing a list of key / value pairs. + * + */ +public class Configuration { + + /** stores the configuration information */ + private static Hashtable standardConfiguration; + private static Hashtable pdfConfiguration; + private static Hashtable awtConfiguration; + + /** defines role types */ + public final static int STANDARD = 0; + public final static int PDF = 1; + public final static int AWT = 2; + + /** + * general access method + * + * @param key a string containing the key value for the configuration value + * role detemines the configuration target + * @return Object containing the value; normally you would use one of the + * convenience methods, which return the correct form. + * null if the key is not defined. + */ + public static Object getValue (String key, int role) { + switch (role) { + case Configuration.STANDARD: + return standardConfiguration.get(key); + case Configuration.PDF: + return pdfConfiguration.get(key); + case Configuration.AWT: + return awtConfiguration.get(key); + default: + return standardConfiguration.get(key); + } + }; + + /** + * convenience methods to access strings values in the configuration + * @param key a string containing the key value for the configuration value + * role detemines the configuration target + * @return String a string containing the value + * null if the key is not defined. + */ + public static String getStringValue(String key, int role) { + Object obj = Configuration.getValue (key, role); + if (obj instanceof String) { + return (String) obj; + } else { + return null; + } + }; + + /** + * convenience methods to access int values in the configuration + * @param key a string containing the key value for the configuration value + * role detemines the configuration target + * @return int a int containing the value + * -1 if the key is not defined. + */ + public static int getIntValue(String key, int role) { + Object obj = Configuration.getValue (key, role); + if (obj instanceof String) { + return Integer.parseInt((String) obj); + } else { + return -1; + } + }; + + /** + * convenience methods to access boolean values in the configuration + * @param key a string containing the key value for the configuration value + * role detemines the configuration target + * @return boolean true or false as value + * -1 if the key is not defined. + */ + public static Boolean getBooleanValue(String key, int role) { + Object obj = Configuration.getValue (key, role); + if (obj instanceof String) { + String value = (String) obj; + if (value.equals("true")) { + return new Boolean(true); + } else if (value.equals("false")) { + return new Boolean(false); + } else { + return null; + } + } else { + return null; + } + }; + + /** + * convenience methods to access list values in the configuration + * @param key a string containing the key value for the configuration value + * role detemines the configuration target + * @return Vector a Vector containing the values + * null if the key is not defined. + */ + public static Vector getListValue(String key, int role) { + Object obj = Configuration.getValue (key, role); + if (obj instanceof Vector) { + return (Vector) obj; + } else { + return null; + } + }; + + /** + * convenience methods to access map/hashtable values in the configuration + * @param key a string containing the key value for the configuration value + * role detemines the configuration target + * @return Hashtable a Hashtable containing the values + * null if the key is not defined. + */ + public static Hashtable getHashtableValue(String key, int role) { + Object obj = Configuration.getValue (key, role); + if (obj instanceof Hashtable) { + return (Hashtable) obj; + } else { + return null; + } + }; + + + /** + * convenience method which retrieves some configuration information + * from the standard configuration + * + * @param key a string containing the key value for the configuration value + * @return Object containing the value; normally you would use one of the + * convenience methods, which return the correct form. + * null if the key is not defined. + */ + public static Object getValue (String key) { + return Configuration.getValue(key, Configuration.STANDARD); + } + + /** + * convenience methods to access strings values in the standard configuration + * + * @param key a string containing the key value for the configuration value + * @return String a string containing the value + * null if the key is not defined. + */ + public static String getStringValue(String key) { + return Configuration.getStringValue(key, Configuration.STANDARD); + } + + /** + * convenience methods to access int values in the standard configuration + * + * @param key a string containing the key value for the configuration value + * @return int a int containing the value + * -1 if the key is not defined. + */ + public static int getIntValue(String key) { + return Configuration.getIntValue(key, Configuration.STANDARD); + } + + /** + * convenience methods to access boolean values in the configuration + * + * @param key a string containing the key value for the configuration value + * @return boolean true or false as value + * -1 if the key is not defined. + */ + public static Boolean getBooleanValue(String key) { + return Configuration.getBooleanValue(key, Configuration.STANDARD); + } + + /** + * convenience methods to access list values in the standard configuration + * + * @param key a string containing the key value for the configuration value + * @return Vector a Vector containing the values + * null if the key is not defined. + */ + public static Vector getListValue(String key) { + return Configuration.getListValue(key, Configuration.STANDARD); + } + + /** + * convenience methods to access map/hashtable values in the standard configuration + * + * @param key a string containing the key value for the configuration value + * @return Hashtable a Hashtable containing the values + * null if the key is not defined. + */ + public static Hashtable getHashtableValue(String key) { + return Configuration.getHashtableValue(key, Configuration.STANDARD); + } + + + /** + * initializes this configuration + * @param config contains the configuration information + */ + public static void setup(int role, Hashtable config) { + switch (role) { + case Configuration.STANDARD: + standardConfiguration = config; + break; + case Configuration.PDF: + pdfConfiguration = config; + break; + case Configuration.AWT: + awtConfiguration = config; + break; + default: + MessageHandler.errorln("Can't setup configuration. Unknown configuration role/target"); + } + } + + /** + * adds information to the configuration map/hashtable in key,value form + * @param key a string containing the key value for the configuration value + * value the configuration information + * role detemines the configuration target + * @param value an Object containing the value; can be a String, a Vector or a Hashtable + */ + public static void put(String key, Object value, int role) { + switch (role) { + case Configuration.STANDARD: + standardConfiguration.put(key, value); + break; + case Configuration.PDF: + pdfConfiguration.put(key, value); + break; + case Configuration.AWT: + awtConfiguration.put(key, value); + break; + default: + standardConfiguration.put(key, value); + MessageHandler.errorln( + "Unknown role for new configuration entry. " + + "Putting key:" + key + " - value:" + value + " into standard configuration."); + } + }; + + /** + * adds information to the standard configuration map/hashtable in key,value form + * @param key a string containing the key value for the configuration value + * value the configuration information + * role detemines the configuration target + * @param value an Object containing the value; can be a String, a Vector or a Hashtable + */ + + public static void put(String key, Object value) { + Configuration.put(key, value, Configuration.STANDARD); + } + + /** + * debug methods, which writes out all information in this configuration + */ + public static void dumpConfiguration() { + String key; + Object value; + Vector list; + Hashtable map, configuration; + Enumeration enum; + String tmp; + System.out.println("Dumping configuration: "); + Hashtable [] configs = {standardConfiguration, + pdfConfiguration, awtConfiguration}; + for (int i = 0; i < configs.length ; i++) { + MessageHandler.logln("----------------------"); + configuration = configs[i]; + Enumeration enumeration = configuration.keys(); + while (enumeration.hasMoreElements()) { + key = (String) enumeration.nextElement(); + MessageHandler.logln("key: " + key); + value = configuration.get(key); + if (value instanceof String) { + MessageHandler.logln(" value: " + value); + } else if (value instanceof Vector) { + list = (Vector) value; + enum = list.elements(); + MessageHandler.log(" values: "); + while (enum.hasMoreElements()) { + MessageHandler.log(enum.nextElement() + " - "); + } + MessageHandler.logln(""); + } else if (value instanceof Hashtable) { + map = (Hashtable) value; + enum = map.keys(); + MessageHandler.log(" values: "); + while (enum.hasMoreElements()) { + tmp = (String) enum.nextElement(); + MessageHandler.log(" " + tmp + ":" + map.get(tmp)); + } + MessageHandler.logln(""); + } + } + } + } + + + +} + diff --git a/src/org/apache/fop/configuration/ConfigurationParser.java b/src/org/apache/fop/configuration/ConfigurationParser.java index e99a6cd45..e6f6ffd9c 100644 --- a/src/org/apache/fop/configuration/ConfigurationParser.java +++ b/src/org/apache/fop/configuration/ConfigurationParser.java @@ -81,8 +81,10 @@ public class ConfigurationParser extends DefaultHandler { private int status = OUT; private int datatype = -1; - //stores the result configuration - private static Hashtable configuration = new Hashtable(20); + //store the result configuration + private static Hashtable standardConfiguration = new Hashtable(30); + private static Hashtable pdfConfiguration = new Hashtable(20); + private static Hashtable awtConfiguration = new Hashtable(20); //stores key for new config entry private String key = ""; @@ -102,6 +104,8 @@ public class ConfigurationParser extends DefaultHandler { /** locator for line number information */ private Locator locator; + /** determines role / target of configuration information, default is standard */ + private int role = Configuration.STANDARD; /** get locator for position information */ public void setDocumentLocator(Locator locator) { @@ -121,8 +125,24 @@ public class ConfigurationParser extends DefaultHandler { status += IN_LIST; } else if (localName.equals("subentry")) { status += IN_SUBENTRY; - } else if (localName.equals("configuration") || - localName.equals("entry") || localName.equals("datatype")) { + } else if (localName.equals("entry")) { + if (attributes.getLength() == 0) { + role = Configuration.STANDARD; + } else { + //retrieve attribute value for "role" which determines configuration target + String rolen = attributes.getValue("role"); + if (rolen.equalsIgnoreCase("pdf")) { + role = Configuration.PDF; + } else if (rolen.equalsIgnoreCase("awt")) { + role = Configuration.AWT; + } else if (rolen.equalsIgnoreCase("standard")) { + role = Configuration.STANDARD; + } else { + MessageHandler.errorln("unknown role: " + rolen + ". Using standard."); + } + } + //role=standard as default + } else if (localName.equals("configuration") ) { } else { //to make sure that user knows about false tag MessageHandler.errorln( @@ -135,18 +155,18 @@ public class ConfigurationParser extends DefaultHandler { */ public void endElement(String uri, String localName, String qName) { if (localName.equals("entry")) { - int tek = 0; switch (datatype) { case STRING: - configuration.put(key, value); + this.store(role, key, value); break; case LIST: - configuration.put(key, list); + this.store(role, key, list); break; case MAP: - configuration.put(key, map); + this.store(role, key, map); } status = OUT; + role = Configuration.STANDARD; } else if (localName.equals("subentry")) { map.put(subkey, value); status -= IN_SUBENTRY; @@ -157,7 +177,23 @@ public class ConfigurationParser extends DefaultHandler { } else if (localName.equals("value")) { status -= IN_VALUE; } + } + private void store (int role, String key, Object value) { + switch (role) { + case Configuration.STANDARD: + standardConfiguration.put(key,value); + break; + case Configuration.PDF: + pdfConfiguration.put(key,value); + break; + case Configuration.AWT: + awtConfiguration.put(key,value); + break; + default: + MessageHandler.errorln("Unknown role for new configuration entry. " + +"Putting key:" + key + " - value:" + value +" into standard configuration."); + } } /** @@ -195,8 +231,18 @@ public class ConfigurationParser extends DefaultHandler { * returns the parsed configuration information * @return Hashtable containing the configuration information as key/value pairs */ - public Hashtable getConfiguration() { - return configuration; + public Hashtable getConfiguration(int role) { + switch (role) { + case Configuration.STANDARD: + return standardConfiguration; + case Configuration.PDF: + return pdfConfiguration; + case Configuration.AWT: + return awtConfiguration; + default: + MessageHandler.errorln("Can't return asked for configuration. Unknown role " ); + return null; + } } } diff --git a/src/org/apache/fop/configuration/ConfigurationReader.java b/src/org/apache/fop/configuration/ConfigurationReader.java index 798a35698..d012d3d80 100644 --- a/src/org/apache/fop/configuration/ConfigurationReader.java +++ b/src/org/apache/fop/configuration/ConfigurationReader.java @@ -61,9 +61,7 @@ import org.xml.sax.InputSource; //fop import org.apache.fop.messaging.MessageHandler; import org.apache.fop.apps.FOPException; -import org.apache.fop.configuration.AWTConfiguration; -import org.apache.fop.configuration.PDFConfiguration; -import org.apache.fop.configuration.StandardConfiguration; +import org.apache.fop.configuration.Configuration; /** * entry class for reading configuration from file and creating a configuration @@ -87,16 +85,13 @@ public class ConfigurationReader { /** inputsource for configuration file */ private InputSource filename; - private String role ; /** * creates a configuration reader * @param filename the file which contains the configuration information - * @param role three values are recognized: awt, pdf, standard */ - public ConfigurationReader (InputSource filename, String role) { + public ConfigurationReader (InputSource filename) { this.filename = filename; - this.role = role; } @@ -127,16 +122,9 @@ public class ConfigurationReader { try { parser.parse(filename); - if (role.equalsIgnoreCase("standard")) { - StandardConfiguration.setup( - configurationParser.getConfiguration()); - } else if (role.equalsIgnoreCase("pdf")) { - PDFConfiguration.setup( - configurationParser.getConfiguration()); - } else if (role.equalsIgnoreCase("awt")) { - AWTConfiguration.setup( - configurationParser.getConfiguration()); - } + Configuration.setup(Configuration.STANDARD, configurationParser.getConfiguration(Configuration.STANDARD)); + Configuration.setup(Configuration.PDF, configurationParser.getConfiguration(Configuration.PDF)); + Configuration.setup(Configuration.AWT, configurationParser.getConfiguration(Configuration.AWT)); } catch (SAXException e) { if (e.getException() instanceof FOPException) { dumpError(e.getException()); @@ -221,7 +209,7 @@ public class ConfigurationReader { * */ public void setDumpError(boolean dumpError) { - this.errorDump = errorDump; + errorDump = dumpError; } } diff --git a/src/org/apache/fop/configuration/PDFConfiguration.java b/src/org/apache/fop/configuration/PDFConfiguration.java deleted file mode 100644 index ae62719bc..000000000 --- a/src/org/apache/fop/configuration/PDFConfiguration.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.apache.fop.configuration; - -import java.util.Vector; -import java.util.Hashtable; -import java.util.Enumeration; - -/** - * a configuration class for information related to the pdf renderer. All configuration is stored - * in key / value pairs. The value can be a String, a list of Strings - * or a map, containing a list of key / value pairs. - * - */ - -public class PDFConfiguration { - - /** stores the configuration information */ - private static Hashtable configuration; - - /** - * general access method - * - * @param key a string containing the key value for the configuration value - * @return Object containing the value; normally you would use one of the - * convenience methods, which return the correct form. - * null if the key is not defined. - */ - public static Object getValue (String key){ - return configuration.get(key); - }; - - /** - * convenience methods to access strings values in the configuration - * @param key a string containing the key value for the configuration value - * @return String a string containing the value - * null if the key is not defined. - */ - public static String getStringValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof String) { - return (String) obj; - } else { - return null; - } - }; - - /** - * convenience methods to access int values in the configuration - * @param key a string containing the key value for the configuration value - * @return int a int containing the value - * -1 if the key is not defined. - */ - public static int getIntValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof String) { - return Integer.parseInt((String) obj); - } else { - return -1; - } - }; - - /** - * convenience methods to access list values in the configuration - * @param key a string containing the key value for the configuration value - * @return Vector a Vector containing the values - * null if the key is not defined. - */ - public static Vector getListValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof Vector) { - return (Vector) obj; - } else { - return null; - } - }; - - /** - * convenience methods to access map/hashtable values in the configuration - * @param key a string containing the key value for the configuration value - * @return Hashtable a Hashtable containing the values - * null if the key is not defined. - */ - public static Hashtable getHashtableValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof Hashtable) { - return (Hashtable) obj; - } else { - return null; - } - }; - - /** - * adds information to the configuration map/hashtable in key,value form - * @param key a string containing the key value for the configuration value - * @param value an Object containing the value; can be a String, a Vector or a Hashtable - */ - public static void put(String key,Object value){ - configuration.put(key,value); - }; - - /** - * debug methods, which writes out all information in this configuration - */ - public static void dumpConfiguration() { - String key; - Object value; - Vector list; - Hashtable map; - Enumeration enum; - String tmp; - System.out.println("Dumping standard configuration: "); - Enumeration enumeration = configuration.keys(); - while (enumeration.hasMoreElements()) { - key = (String) enumeration.nextElement(); - System.out.print(" key: " + key); - value = configuration.get(key); - if (value instanceof String) { - System.out.println(" value: " + value); - } else if (value instanceof Vector) { - list = (Vector) value; - enum = list.elements(); - System.out.print(" value: "); - while (enum.hasMoreElements()) { - System.out.print( enum.nextElement() + " - "); - } - System.out.println(""); - } else if (value instanceof Hashtable) { - map = (Hashtable) value; - enum = map.keys(); - while (enum.hasMoreElements()) { - tmp = (String) enum.nextElement(); - System.out.print(" " + tmp + ":" + map.get(tmp)); - } - System.out.println(""); - } - } - - } - - /** - * initializes this configuration - * @param config contains the configuration information - */ - public static void setup(Hashtable config){ - configuration = config; - } - -} diff --git a/src/org/apache/fop/configuration/StandardConfiguration.java b/src/org/apache/fop/configuration/StandardConfiguration.java deleted file mode 100644 index 98a0cf845..000000000 --- a/src/org/apache/fop/configuration/StandardConfiguration.java +++ /dev/null @@ -1,171 +0,0 @@ - -package org.apache.fop.configuration; - -import java.util.Vector; -import java.util.Hashtable; -import java.util.Enumeration; - -/** - * a configuration class for all general configuration aspects except those - * related to specific renderers. All configuration is stored - * in key / value pairs. The value can be a String, a list of Strings - * or a map, containing a list of key / value pairs. - * - */ -public class StandardConfiguration { - - /** stores the configuration information */ - private static Hashtable configuration; - - /** - * general access method - * - * @param key a string containing the key value for the configuration value - * @return Object containing the value; normally you would use one of the - * convenience methods, which return the correct form. - * null if the key is not defined. - */ - public static Object getValue (String key){ - return configuration.get(key); - }; - - /** - * convenience methods to access strings values in the configuration - * @param key a string containing the key value for the configuration value - * @return String a string containing the value - * null if the key is not defined. - */ - public static String getStringValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof String) { - return (String) obj; - } else { - return null; - } - }; - - /** - * convenience methods to access int values in the configuration - * @param key a string containing the key value for the configuration value - * @return int a int containing the value - * -1 if the key is not defined. - */ - public static int getIntValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof String) { - return Integer.parseInt((String) obj); - } else { - return -1; - } - }; - - /** - * convenience methods to access boolean values in the configuration - * @param key a string containing the key value for the configuration value - * @return boolean true or false as value - * -1 if the key is not defined. - */ - public static Boolean getBooleanValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof String) { - String value = (String) obj; - if (value.equals("true")) { - return new Boolean(true); - } else if (value.equals("false")) { - return new Boolean(false); - } else { - return null; - } - } else { - return null; - } - }; - - /** - * convenience methods to access list values in the configuration - * @param key a string containing the key value for the configuration value - * @return Vector a Vector containing the values - * null if the key is not defined. - */ - public static Vector getListValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof Vector) { - return (Vector) obj; - } else { - return null; - } - }; - - /** - * convenience methods to access map/hashtable values in the configuration - * @param key a string containing the key value for the configuration value - * @return Hashtable a Hashtable containing the values - * null if the key is not defined. - */ - public static Hashtable getHashtableValue(String key){ - Object obj = configuration.get(key); - if (obj instanceof Hashtable) { - return (Hashtable) obj; - } else { - return null; - } - }; - - /** - * adds information to the configuration map/hashtable in key,value form - * @param key a string containing the key value for the configuration value - * @param value an Object containing the value; can be a String, a Vector or a Hashtable - */ - public static void put(String key,Object value){ - configuration.put(key,value); - }; - - /** - * debug methods, which writes out all information in this configuration - */ - public static void dumpConfiguration() { - String key; - Object value; - Vector list; - Hashtable map; - Enumeration enum; - String tmp; - System.out.println("Dumping standard configuration: "); - Enumeration enumeration = configuration.keys(); - while (enumeration.hasMoreElements()) { - key = (String) enumeration.nextElement(); - System.out.print(" key: " + key); - value = configuration.get(key); - if (value instanceof String) { - System.out.println(" value: " + value); - } else if (value instanceof Vector) { - list = (Vector) value; - enum = list.elements(); - System.out.print(" value: "); - while (enum.hasMoreElements()) { - System.out.print( enum.nextElement() + " - "); - } - System.out.println(""); - } else if (value instanceof Hashtable) { - map = (Hashtable) value; - enum = map.keys(); - while (enum.hasMoreElements()) { - tmp = (String) enum.nextElement(); - System.out.print(" " + tmp + ":" + map.get(tmp)); - } - System.out.println(""); - } - } - - } - - /** - * initializes this configuration - * @param config contains the configuration information - */ - public static void setup(Hashtable config){ - configuration = config; - } - -} - |