From c0a432e3aea3fcfcafd06642d2e419fb9de90cc3 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Wed, 4 Sep 2002 08:36:37 +0000 Subject: [PATCH] removed old configuration git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195149 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 8 +- conf/config.dtd | 6 - conf/config.xml | 55 --- conf/userconfig.xml | 75 ---- src/org/apache/fop/apps/AWTStarter.java | 3 - .../apache/fop/apps/CommandLineOptions.java | 20 +- .../apache/fop/apps/CommandLineStarter.java | 11 - src/org/apache/fop/apps/Driver.java | 45 +-- src/org/apache/fop/apps/Fop.java | 4 +- src/org/apache/fop/apps/Options.java | 172 --------- src/org/apache/fop/apps/PrintStarter.java | 3 - src/org/apache/fop/apps/Starter.java | 2 - src/org/apache/fop/apps/Version.java | 4 +- .../fop/configuration/Configuration.java | 345 ------------------ .../configuration/ConfigurationParser.java | 261 ------------- .../configuration/ConfigurationReader.java | 139 ------- .../fop/layout/hyphenation/Hyphenator.java | 4 +- src/org/apache/fop/mif/MIFHandler.java | 2 +- src/org/apache/fop/render/PrintRenderer.java | 2 +- src/org/apache/fop/render/pdf/FontReader.java | 16 +- src/org/apache/fop/render/ps/PSRenderer.java | 2 +- .../apache/fop/render/xml/XMLRenderer.java | 2 +- src/org/apache/fop/tools/AreaTreeBuilder.java | 1 - src/org/apache/fop/tools/TestConverter.java | 10 +- src/org/apache/fop/tools/anttasks/Fop.java | 28 +- 25 files changed, 47 insertions(+), 1173 deletions(-) delete mode 100644 conf/config.dtd delete mode 100644 conf/config.xml delete mode 100644 conf/userconfig.xml delete mode 100644 src/org/apache/fop/apps/Options.java delete mode 100644 src/org/apache/fop/configuration/Configuration.java delete mode 100644 src/org/apache/fop/configuration/ConfigurationParser.java delete mode 100644 src/org/apache/fop/configuration/ConfigurationReader.java diff --git a/build.xml b/build.xml index 8e665fa1b..f2de78ff4 100644 --- a/build.xml +++ b/build.xml @@ -186,7 +186,7 @@ Sometimes ant gives out this warnings, but the build is finished without any pro - + @@ -308,11 +308,7 @@ Sometimes ant gives out this warnings, but the build is finished without any pro - - - - @@ -548,7 +544,7 @@ Sometimes ant gives out this warnings, but the build is finished without any pro + includes="org/**,hyph/**"> diff --git a/conf/config.dtd b/conf/config.dtd deleted file mode 100644 index d51a1a96c..000000000 --- a/conf/config.dtd +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/conf/config.xml b/conf/config.xml deleted file mode 100644 index 6d75a5859..000000000 --- a/conf/config.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - version - FOP @version@ - - - - - - quiet - false - - - - debugMode - false - - - - dumpConfiguration - false - - - - debugMode - false - - - - - - stream-filter-list - - - flate - - - ascii-85 - - - - - - - - diff --git a/conf/userconfig.xml b/conf/userconfig.xml deleted file mode 100644 index 0ccc6e01a..000000000 --- a/conf/userconfig.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/org/apache/fop/apps/AWTStarter.java b/src/org/apache/fop/apps/AWTStarter.java index 6f2bc3c21..3b661f2e7 100644 --- a/src/org/apache/fop/apps/AWTStarter.java +++ b/src/org/apache/fop/apps/AWTStarter.java @@ -95,9 +95,6 @@ public class AWTStarter extends CommandLineStarter { public void run() throws FOPException { Driver driver = new Driver(); setupLogger(driver); - if (errorDump) { - driver.setErrorDump(true); - } // init parser frame.progress(resource.getString("Init parser") + " ..."); diff --git a/src/org/apache/fop/apps/CommandLineOptions.java b/src/org/apache/fop/apps/CommandLineOptions.java index 0dc4d3990..764424308 100644 --- a/src/org/apache/fop/apps/CommandLineOptions.java +++ b/src/org/apache/fop/apps/CommandLineOptions.java @@ -13,7 +13,6 @@ import java.io.File; import java.io.FileNotFoundException; // FOP -import org.apache.fop.configuration.Configuration; import org.apache.fop.apps.FOPException; // Avalon @@ -52,8 +51,6 @@ public class CommandLineOptions { /* output: XML area tree */ private static final int AREA_OUTPUT = 9; - /* use debug mode */ - Boolean errorDump = Boolean.FALSE; /* show configuration information */ Boolean dumpConfiguration = Boolean.FALSE; /* suppress any progress information */ @@ -92,9 +89,6 @@ public class CommandLineOptions { optionsParsed = parseOptions(args); if (optionsParsed) { checkSettings(); - if (errorDump != null && errorDump.booleanValue()) { - debug(); - } } } catch (FOPException e) { printUsage(); @@ -106,6 +100,10 @@ public class CommandLineOptions { } + public Logger getLogger() { + return log; + } + /** * parses the commandline arguments * @return true if parse was successful and procesing can continue, false if processing should stop @@ -114,7 +112,6 @@ public class CommandLineOptions { private boolean parseOptions(String args[]) throws FOPException { for (int i = 0; i < args.length; i++) { if (args[i].equals("-d") || args[i].equals("--full-error-dump")) { - errorDump = Boolean.TRUE; log = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG); } else if (args[i].equals("-x") || args[i].equals("--dump-config")) { @@ -452,10 +449,6 @@ public class CommandLineOptions { return dumpConfiguration; } - public Boolean isDebugMode() { - return errorDump; - } - public Boolean isCoarseAreaXml() { return suppressLowLevelAreas; } @@ -598,11 +591,6 @@ public class CommandLineOptions { } else { log.debug("no user configuration file is used [default]"); } - if (errorDump != null) { - log.debug("debug mode on"); - } else { - log.debug("debug mode off [default]"); - } if (dumpConfiguration != null) { log.debug("dump configuration"); } else { diff --git a/src/org/apache/fop/apps/CommandLineStarter.java b/src/org/apache/fop/apps/CommandLineStarter.java index 9a2543842..46cd0cf36 100644 --- a/src/org/apache/fop/apps/CommandLineStarter.java +++ b/src/org/apache/fop/apps/CommandLineStarter.java @@ -18,9 +18,6 @@ import java.io.*; import java.net.URL; -// FOP -import org.apache.fop.configuration.Configuration; - /** * super class for all classes which start Fop from the commandline * @@ -29,14 +26,10 @@ import org.apache.fop.configuration.Configuration; public class CommandLineStarter extends Starter { CommandLineOptions commandLineOptions; - boolean errorDump; public CommandLineStarter(CommandLineOptions commandLineOptions) throws FOPException { this.commandLineOptions = commandLineOptions; - options.setCommandLineOptions(commandLineOptions); - errorDump = - Configuration.getBooleanValue("debugMode").booleanValue(); super.setInputHandler(commandLineOptions.getInputHandler()); } @@ -56,10 +49,6 @@ public class CommandLineStarter extends Starter { setupLogger(driver); driver.initialize(); - if (errorDump) { - driver.setErrorDump(true); - } - try { driver.setRenderer(commandLineOptions.getRenderer()); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream( diff --git a/src/org/apache/fop/apps/Driver.java b/src/org/apache/fop/apps/Driver.java index 772703088..5424bd715 100644 --- a/src/org/apache/fop/apps/Driver.java +++ b/src/org/apache/fop/apps/Driver.java @@ -12,8 +12,6 @@ import org.apache.fop.fo.FOUserAgent; import org.apache.fop.fo.FOTreeBuilder; import org.apache.fop.fo.ElementMapping; import org.apache.fop.render.Renderer; -import org.apache.fop.configuration.ConfigurationReader; -import org.apache.fop.configuration.Configuration; import org.apache.fop.tools.DocumentInputSource; import org.apache.fop.tools.DocumentReader; @@ -166,11 +164,6 @@ public class Driver implements LogEnabled { */ private XMLReader _reader; - /** - * If true, full error stacks are reported - */ - private boolean _errorDump = false; - /** * the system resources that FOP will use */ @@ -215,8 +208,7 @@ public class Driver implements LogEnabled { if(userAgent == null) { userAgent = new FOUserAgent(); userAgent.enableLogging(getLogger()); - String base = org.apache.fop.configuration.Configuration.getStringValue("baseDir"); - userAgent.setBaseURL(base); + userAgent.setBaseURL("file:/."); } return userAgent; } @@ -255,14 +247,6 @@ public class Driver implements LogEnabled { return (_treeBuilder.hasData()); } - /** - * Set the error dump option - * @param dump if true, full stacks will be reported to the error log - */ - public void setErrorDump(boolean dump) { - _errorDump = dump; - } - /** * Set the OutputStream to use to output the result of the Renderer * (if applicable) @@ -517,27 +501,6 @@ public class Driver implements LogEnabled { } - /** - * Dumps an error - */ - public void dumpError(Exception e) { - if (_errorDump) { - if (e instanceof SAXException) { - getLogger().error("", e); - if (((SAXException)e).getException() != null) { - getLogger().error("", ((SAXException)e).getException()); - } - } else if (e instanceof FOPException) { - e.printStackTrace(); - if (((FOPException)e).getException() != null) { - getLogger().error("", ((FOPException)e).getException()); - } - } else { - getLogger().error("", e); - } - } - } - /** * Runs the formatting and renderering process using the previously set * inputsource and outputstream @@ -553,7 +516,11 @@ public class Driver implements LogEnabled { if (_reader == null) { if (!(_source instanceof DocumentInputSource)) { - _reader = ConfigurationReader.createParser(); + try { + _reader = javax.xml.parsers.SAXParserFactory.newInstance().newSAXParser().getXMLReader(); + } catch(Exception e) { + throw new FOPException(e); + } } } diff --git a/src/org/apache/fop/apps/Fop.java b/src/org/apache/fop/apps/Fop.java index 4a2352d51..91399e53a 100644 --- a/src/org/apache/fop/apps/Fop.java +++ b/src/org/apache/fop/apps/Fop.java @@ -21,14 +21,14 @@ public class Fop { } else { System.err.println("" + e.getMessage()); } - if (options != null && options.isDebugMode().booleanValue()) { + if (options != null && options.getLogger().isDebugEnabled()) { e.printStackTrace(); } else { System.err.println("Turn on debugging for more information"); } } catch (java.io.FileNotFoundException e) { System.err.println("" + e.getMessage()); - if (options != null && options.isDebugMode().booleanValue()) { + if (options != null && options.getLogger().isDebugEnabled()) { e.printStackTrace(); } else { System.err.println("Turn on debugging for more information"); diff --git a/src/org/apache/fop/apps/Options.java b/src/org/apache/fop/apps/Options.java deleted file mode 100644 index bdccd96c1..000000000 --- a/src/org/apache/fop/apps/Options.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.apps; - -// sax -import org.xml.sax.InputSource; - -// java -import java.io.File; -import java.io.InputStream; - -// fop -import org.apache.fop.configuration.Configuration; -import org.apache.fop.configuration.ConfigurationReader; - -/** - * Options handles loading of configuration files and - * additional setting of commandline options - */ -public class Options { - boolean errorDump = false; - - public Options() throws FOPException { - this.loadStandardConfiguration(); - initOptions(); - } - - public Options(File userConfigFile) throws FOPException { - this(); - this.loadUserconfiguration(userConfigFile); - } - - public Options(CommandLineOptions clOptions) throws FOPException { - this(); - this.setCommandLineOptions(clOptions); - } - - // initializing option settings - void initOptions() { - if (Configuration.getBooleanValue("quiet").booleanValue()) { - //MessageHandler.setQuiet(true); - } - if (Configuration.getBooleanValue("debugMode").booleanValue()) { - errorDump = true; - } - if (Configuration.getBooleanValue("dumpConfiguration").booleanValue()) { - Configuration.put("dumpConfiguration", "true"); - Configuration.dumpConfiguration(); - } - } - - // setting clOptions - void setCommandLineOptions(CommandLineOptions clOptions) { - // load user configuration file,if there is one - File userConfigFile = clOptions.getUserConfigFile(); - if (userConfigFile != null) { - this.loadUserconfiguration(userConfigFile); - } - - // debug mode - if (clOptions.isDebugMode() != null) { - errorDump = clOptions.isDebugMode().booleanValue(); - Configuration.put("debugMode", new Boolean(errorDump)); - } - - // show configuration settings - boolean dumpConfiguration; - if (clOptions.dumpConfiguration() != null) { - dumpConfiguration = clOptions.dumpConfiguration().booleanValue(); - } else { - dumpConfiguration = - Configuration.getBooleanValue("dumpConfiguration").booleanValue(); - } - if (dumpConfiguration) { - Configuration.put("dumpConfiguration", "true"); - Configuration.dumpConfiguration(); - } - - // quiet mode - if (clOptions.isQuiet() != null) { - //MessageHandler.setQuiet(clOptions.isQuiet().booleanValue()); - } - - // set base directory - String baseDir = Configuration.getStringValue("baseDir"); - if (baseDir == null) { - try { - baseDir = - new File(clOptions.getInputFile().getAbsolutePath()).getParentFile().toURL().toExternalForm(); - Configuration.put("baseDir", baseDir); - } catch (Exception e) {} - } - if (errorDump) { - //log.debug("base directory: " + baseDir); - } - } - - /** - * loads standard configuration file and a user file, if it has been specified - */ - public void loadStandardConfiguration() throws FOPException { - String file = "config.xml"; - InputStream configfile = null; - - // Try to use Context Class Loader to load the properties file. - try { - java.lang.reflect.Method getCCL = - Thread.class.getMethod("getContextClassLoader", new Class[0]); - if (getCCL != null) { - ClassLoader contextClassLoader = - (ClassLoader)getCCL.invoke(Thread.currentThread(), - new Object[0]); - configfile = contextClassLoader.getResourceAsStream("conf/" - + file); - } - } catch (Exception e) {} - - // the entry /conf/config.xml refers to a directory conf which is a sibling of org - if (configfile == null) - configfile = - ConfigurationReader.class.getResourceAsStream("/conf/" - + file); - if (configfile == null) { - throw new FOPException("can't find default configuration file"); - } - if (errorDump) { - //log.error("reading default configuration file"); - } - ConfigurationReader reader = - new ConfigurationReader(new InputSource(configfile)); - if (errorDump) { - reader.setDumpError(true); - } - reader.start(); - - } - - public void loadUserconfiguration(String userConfigFile) { - loadUserconfiguration(new File(userConfigFile)); - } - - public void loadUserconfiguration(File userConfigFile) { - // read user configuration file - if (userConfigFile != null) { - //log.debug("reading user configuration file"); - ConfigurationReader reader = - new ConfigurationReader(InputHandler.fileInputSource(userConfigFile)); - if (errorDump) { - reader.setDumpError(true); - } - try { - reader.start(); - } catch (org.apache.fop.apps.FOPException error) { - //log.error("Could not load user configuration file " - // + userConfigFile + " - error: " - // + error.getMessage()); - //log.error("using default values"); - if (errorDump) { - reader.dumpError(error); - } - } - } - } - -} - - diff --git a/src/org/apache/fop/apps/PrintStarter.java b/src/org/apache/fop/apps/PrintStarter.java index 11154f1e6..cb80c3210 100644 --- a/src/org/apache/fop/apps/PrintStarter.java +++ b/src/org/apache/fop/apps/PrintStarter.java @@ -51,9 +51,6 @@ public class PrintStarter extends CommandLineStarter { public void run() throws FOPException { Driver driver = new Driver(); - if (errorDump) { - driver.setErrorDump(true); - } String version = Version.getVersion(); //log.debug(version); diff --git a/src/org/apache/fop/apps/Starter.java b/src/org/apache/fop/apps/Starter.java index 3c280b274..9538cee29 100644 --- a/src/org/apache/fop/apps/Starter.java +++ b/src/org/apache/fop/apps/Starter.java @@ -25,11 +25,9 @@ import java.net.URL; */ public abstract class Starter extends AbstractLogEnabled { - Options options; InputHandler inputHandler; public Starter() throws FOPException { - options = new Options(); } public void setInputHandler(InputHandler inputHandler) { diff --git a/src/org/apache/fop/apps/Version.java b/src/org/apache/fop/apps/Version.java index a7d64534b..885012c9e 100644 --- a/src/org/apache/fop/apps/Version.java +++ b/src/org/apache/fop/apps/Version.java @@ -7,8 +7,6 @@ package org.apache.fop.apps; -import org.apache.fop.configuration.Configuration; - /** * class representing the version of FOP. */ @@ -20,7 +18,7 @@ public class Version { * @return the version string */ public static String getVersion() { - return Configuration.getStringValue("version"); + return "1.0dev"; } } diff --git a/src/org/apache/fop/configuration/Configuration.java b/src/org/apache/fop/configuration/Configuration.java deleted file mode 100644 index 002e7952b..000000000 --- a/src/org/apache/fop/configuration/Configuration.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.configuration; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; - -/** - * 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 { - - /** - * defines role types - */ - public final static int STANDARD = 0; - public final static int PDF = 1; - public final static int AWT = 2; - - /** - * stores the configuration information - */ - private static HashMap standardConfiguration = new HashMap(30); - private static HashMap pdfConfiguration = new HashMap(20); - private static HashMap awtConfiguration = new HashMap(20); - - /** - * contains a HashMap of existing HashMaps - */ - private static HashMap configuration = new HashMap(3); - - /** - * loads the configuration types into the configuration HashMap - */ - static { - configuration.put("standard", standardConfiguration); - configuration.put("pdf", pdfConfiguration); - configuration.put("awt", awtConfiguration); - } - - public static HashMap getConfiguration() { - return configuration; - } - - /** - * 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 - * null if the key is not defined. - */ - public static Boolean getBooleanValue(String key, int role) { - Object obj = Configuration.getValue(key, role); - if (obj instanceof String) { - return new Boolean((String)obj); - } else if (obj instanceof Boolean) { - return (Boolean)obj; - } 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 ArrayList a ArrayList containing the values - * null if the key is not defined. - */ - public static ArrayList getListValue(String key, int role) { - Object obj = Configuration.getValue(key, role); - if (obj instanceof ArrayList) { - return (ArrayList)obj; - } else { - return null; - } - } - - /** - * convenience methods to access hashmap values in the configuration - * @param key a string containing the key value for the configuration value - * role detemines the configuration target - * @return HashMap a HashMap containing the values - * null if the key is not defined. - */ - public static HashMap getHashMapValue(String key, int role) { - Object obj = Configuration.getValue(key, role); - if (obj instanceof HashMap) { - return (HashMap)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 - * null 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 ArrayList a ArrayList containing the values - * null if the key is not defined. - */ - public static ArrayList getListValue(String key) { - return Configuration.getListValue(key, Configuration.STANDARD); - } - - /** - * convenience methods to access hashmap values in the standard configuration - * - * @param key a string containing the key value for the configuration value - * @return HashMap a HashMap containing the values - * null if the key is not defined. - */ - public static HashMap getHashMapValue(String key) { - return Configuration.getHashMapValue(key, Configuration.STANDARD); - } - - - /** - * method to access fonts values in the standard configuration - * - * @param key a string containing the key value for the configuration value - * @return HashMap a HashMap containing the values - * null if the key is not defined. - */ - public static ArrayList getFonts() { - return (ArrayList)Configuration.getValue("fonts", - Configuration.STANDARD); - } - - /** - * initializes this configuration - * @param config contains the configuration information - */ - public static void setup(int role, HashMap config) { - switch (role) { - case Configuration.STANDARD: - standardConfiguration = config; - break; - case Configuration.PDF: - pdfConfiguration = config; - break; - case Configuration.AWT: - awtConfiguration = config; - break; - default: - //log.error("Can't setup configuration. Unknown configuration role/target"); - } - } - - /** - * adds information to the configuration hashmap 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 ArrayList or a HashMap - */ - 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); - //log.error("Unknown role for new configuration entry. " - // + "Putting key:" + key + " - value:" - // + value + " into standard configuration."); - } - } - - ; - - /** - * adds information to the standard configuration hashmap 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 ArrayList or a HashMap - */ - - 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; - ArrayList list; - HashMap map, configuration; - String tmp; - System.out.println("Dumping configuration: "); - HashMap[] configs = { - standardConfiguration, pdfConfiguration, awtConfiguration - }; - for (int i = 0; i < configs.length; i++) { - //log.debug("----------------------"); - configuration = configs[i]; - Iterator iterator = configuration.keySet().iterator(); - while (iterator.hasNext()) { - key = (String)iterator.next(); - //log.debug("key: " + key); - value = configuration.get(key); - if (value instanceof String) { - //log.debug(" value: " + value); - } else if (value instanceof ArrayList) { - list = (ArrayList)value; - //log.debug(" values: "); - for (int count = 0; count < list.size(); count++) { - //log.debug(list.get(count) + " - "); - } - } else if (value instanceof HashMap) { - map = (HashMap)value; - Iterator iter = map.keySet().iterator(); - //log.debug(" values: "); - while (iter.hasNext()) { - tmp = (String)iter.next(); - //log.debug(" " + tmp + ":" + map.get(tmp)); - } - } - } - } - } - - - -} - diff --git a/src/org/apache/fop/configuration/ConfigurationParser.java b/src/org/apache/fop/configuration/ConfigurationParser.java deleted file mode 100644 index 9d60352ac..000000000 --- a/src/org/apache/fop/configuration/ConfigurationParser.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - - -package org.apache.fop.configuration; - -import org.apache.fop.render.pdf.EmbedFontInfo; -import org.apache.fop.render.pdf.FontTriplet; - -// sax -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.Attributes; -import org.xml.sax.Locator; - -// java -import java.util.HashMap; -import java.util.ArrayList; - -/** - * SAX2 Handler which retrieves the configuration information and stores them in Configuration. - * Normally this class doesn't need to be accessed directly. - */ -public class ConfigurationParser extends DefaultHandler { - private final int OUT = 0; - private final int IN_ENTRY = 1; - private final int IN_KEY = 2; - private final int IN_VALUE = 4; - private final int IN_LIST = 8; - private final int IN_SUBENTRY = 16; - private final int IN_SUBKEY = 32; - private final int IN_FONTS = 64; - private final int IN_FONT = 128; - - private final int STRING = 0; - private final int LIST = 1; - private final int MAP = 2; - - // state of parser - private int status = OUT; - private int datatype = -1; - - // store the result configuration - private static HashMap configuration; - private static HashMap activeConfiguration; - - // stores key for new config entry - private String key = ""; - private ArrayList keyStack = new ArrayList(); - - // stores string value - private String value = ""; - - // stores key for new config entry - private String subkey = ""; - - // stores list value - private ArrayList list = new ArrayList(15); - - // stores hashtable value - private HashMap map = new HashMap(15); - - /** - * locator for line number information - */ - private Locator locator; - - /** - * determines role / target of configuration information, default is standard - */ - private String role = "standard"; - - // stores fonts - private ArrayList fontList = null; - - // stores information on one font - private EmbedFontInfo fontInfo = null; - - // stores information on a font triplet - private FontTriplet fontTriplet = null; - - // information on a font - private String fontName, metricsFile, embedFile, kerningAsString; - private boolean kerning; - private ArrayList fontTriplets; - - // information on a font triplet - private String fontTripletName, weight, style; - - public void startDocument() { - configuration = Configuration.getConfiguration(); - } - - /** - * get locator for position information - */ - public void setDocumentLocator(Locator locator) { - this.locator = locator; - } - - /** - * extracts the element and attribute name and sets the fitting status and datatype values - */ - public void startElement(String uri, String localName, String qName, - Attributes attributes) { - if (localName.equals("key")) { - status += IN_KEY; - } else if (localName.equals("value")) { - status += IN_VALUE; - } else if (localName.equals("list")) { - status += IN_LIST; - } else if (localName.equals("subentry")) { - status += IN_SUBENTRY; - } else if (localName.equals("entry")) { - // role=standard as default - if (attributes.getLength() == 0) { - role = "standard"; - // retrieve attribute value for "role" which determines configuration target - } else { - role = attributes.getValue("role"); - } - } else if (localName.equals("configuration")) {} - else if (localName.equals("fonts")) { // list of fonts starts - fontList = new ArrayList(10); - } else if (localName.equals("font")) { - kerningAsString = attributes.getValue("kerning"); - if (kerningAsString.equalsIgnoreCase("yes")) { - kerning = true; - } else { - kerning = false; - } - metricsFile = attributes.getValue("metrics-file"); - embedFile = attributes.getValue("embed-file"); - fontName = attributes.getValue("name"); - fontTriplets = new ArrayList(5); - } else if (localName.equals("font-triplet")) { - fontTripletName = attributes.getValue("name"); - weight = attributes.getValue("weight"); - style = attributes.getValue("style"); - fontTriplet = new FontTriplet(fontTripletName, weight, style); - fontTriplets.add(fontTriplet); - } else { - // to make sure that user knows about false tag - //log.error("Unknown tag in configuration file: " - // + localName); - } - } // end startElement - - /** - * stores subentries or entries into their hashes (map for subentries, configuration for entry) - */ - public void endElement(String uri, String localName, String qName) { - if (localName.equals("entry")) { - switch (datatype) { - case STRING: - this.store(role, key, value); - break; - case LIST: - this.store(role, key, list); - break; - case MAP: - this.store(role, key, map); - } - status = OUT; - role = "standard"; - if (keyStack.size() > 0) { - keyStack.remove(keyStack.size() - 1); - } - if (keyStack.size() > 0) { - key = (String)keyStack.get(keyStack.size() - 1); - } else { - key = ""; - } - value = ""; - } else if (localName.equals("subentry")) { - map.put(subkey, value); - status -= IN_SUBENTRY; - if (keyStack.size() > 0) { - keyStack.remove(keyStack.size() - 1); - } - if (keyStack.size() > 0) { - key = (String)keyStack.get(keyStack.size() - 1); - } else { - key = ""; - } - value = ""; - } else if (localName.equals("key")) { - status -= IN_KEY; - keyStack.add(key); - } else if (localName.equals("list")) { - status -= IN_LIST; - value = ""; - } else if (localName.equals("value")) { - status -= IN_VALUE; - } else if (localName.equals("fonts")) { - this.store("standard", "fonts", fontList); - } else if (localName.equals("font")) { - fontInfo = new EmbedFontInfo(fontName, metricsFile, kerning, - fontTriplets, embedFile); - fontList.add(fontInfo); - fontTriplets = null; - metricsFile = null; - embedFile = null; - fontName = null; - kerningAsString = ""; - } else if (localName.equals("font-triplet")) {} - } - - /** - * extracts characters from text nodes and puts them into their respective - * variables - */ - public void characters(char[] ch, int start, int length) { - char characters[] = new char[length]; - System.arraycopy(ch, start, characters, 0, length); - String text = new String(characters); - switch (status) { - case IN_KEY: - key = text; - break; - case IN_LIST + IN_SUBENTRY + IN_KEY: - subkey = text; - break; - case IN_VALUE: - value = text; - datatype = STRING; - break; - case IN_LIST + IN_VALUE: - list.add(text); - datatype = LIST; - break; - case IN_LIST + IN_SUBENTRY + IN_VALUE: - value = text; - datatype = MAP; - break; - } - } // end characters - - /** - * stores configuration entry into configuration hashtable according to the role - * - * @param role a string containing the role / target for this configuration information - * @param key a string containing the key value for the configuration - * @param value a string containing the value for the configuration - */ - private void store(String role, String key, Object value) { - activeConfiguration = (HashMap)configuration.get(role); - if (activeConfiguration != null) { - activeConfiguration.put(key, value); - } else { - //log.error("Unknown role >" + role - // + "< for new configuration entry. \n" - // + "Putting configuration with key:" + key - // + " into standard configuration."); - } - } - -} diff --git a/src/org/apache/fop/configuration/ConfigurationReader.java b/src/org/apache/fop/configuration/ConfigurationReader.java deleted file mode 100644 index 2f7d882a4..000000000 --- a/src/org/apache/fop/configuration/ConfigurationReader.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.configuration; - -// sax -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.XMLReader; -import org.xml.sax.SAXException; -import java.io.IOException; -import org.xml.sax.InputSource; - -// fop -import org.apache.fop.apps.Driver; -import org.apache.fop.apps.FOPException; -import org.apache.fop.configuration.Configuration; - -/** - * entry class for reading configuration from file and creating a configuration - * class. typical use looks like that:
- * - * ConfigurationReader reader = new ConfigurationReader ("config.xml","standard"); - * try { - * reader.start(); - * } catch (org.apache.fop.apps.FOPException error) { - * reader.dumpError(error); - * } - * - * Once the configuration has been setup, the information can be accessed with - * the methods of StandardConfiguration. - */ -public class ConfigurationReader { - - /** - * show a full dump on error - */ - private static boolean errorDump = false; - - /** - * inputsource for configuration file - */ - private InputSource filename; - - - /** - * creates a configuration reader - * @param filename the file which contains the configuration information - */ - public ConfigurationReader(InputSource filename) { - this.filename = filename; - } - - /** - * intantiates parser and starts parsing of config file - */ - public void start() throws FOPException { - XMLReader parser = createParser(); - - // setting the parser features - try { - parser.setFeature("http://xml.org/sax/features/namespace-prefixes", - false); - } catch (SAXException e) { - throw new FOPException("You need a parser which supports SAX version 2", - e); - } - ConfigurationParser configurationParser = new ConfigurationParser(); - parser.setContentHandler(configurationParser); - - try { - parser.parse(filename); - } catch (SAXException e) { - if (e.getException() instanceof FOPException) { - throw (FOPException)e.getException(); - } else { - throw new FOPException(e); - } - } catch (IOException e) { - throw new FOPException(e); - } - } - - /** - * creates a SAX parser, using the value of org.xml.sax.parser - * defaulting to org.apache.xerces.parsers.SAXParser - * - * @return the created SAX parser - */ - public static XMLReader createParser() throws FOPException { - String parserClassName = Driver.getParserClassName(); - if (errorDump) { - //log.debug("configuration reader using SAX parser " - // + parserClassName); - } - - try { - return (XMLReader)Class.forName(parserClassName).newInstance(); - } catch (ClassNotFoundException e) { - throw new FOPException("Could not find " + parserClassName, e); - } catch (InstantiationException e) { - throw new FOPException("Could not instantiate " - + parserClassName, e); - } catch (IllegalAccessException e) { - throw new FOPException("Could not access " + parserClassName, e); - } catch (ClassCastException e) { - throw new FOPException(parserClassName + " is not a SAX driver", - e); - } - } - - /** - * Dumps an error - */ - public void dumpError(Exception e) { - if (errorDump) { - if (e instanceof SAXException) { - e.printStackTrace(); - if (((SAXException)e).getException() != null) { - ((SAXException)e).getException().printStackTrace(); - } - } else { - e.printStackTrace(); - } - } - } - - /** - * long or short error messages - * - */ - public void setDumpError(boolean dumpError) { - errorDump = dumpError; - } - -} diff --git a/src/org/apache/fop/layout/hyphenation/Hyphenator.java b/src/org/apache/fop/layout/hyphenation/Hyphenator.java index 23fe67337..3b6b540b5 100644 --- a/src/org/apache/fop/layout/hyphenation/Hyphenator.java +++ b/src/org/apache/fop/layout/hyphenation/Hyphenator.java @@ -9,7 +9,6 @@ package org.apache.fop.layout.hyphenation; import java.io.*; import java.util.Hashtable; -import org.apache.fop.configuration.*; /** * This class is the main entry point to the hyphenation package. @@ -46,8 +45,7 @@ public class Hyphenator { HyphenationTree hTree = getFopHyphenationTree(key); if (hTree == null) { - String hyphenDir = - Configuration.getStringValue("hyphenation-dir"); + String hyphenDir = "/hyph"; if (hyphenDir != null) { hTree = getUserHyphenationTree(key, hyphenDir); } diff --git a/src/org/apache/fop/mif/MIFHandler.java b/src/org/apache/fop/mif/MIFHandler.java index a71fa304e..99e4333a3 100644 --- a/src/org/apache/fop/mif/MIFHandler.java +++ b/src/org/apache/fop/mif/MIFHandler.java @@ -42,7 +42,7 @@ public class MIFHandler extends StructureHandler { public MIFHandler(OutputStream os) { outStream = os; // use pdf fonts for now, this is only for resolving names - org.apache.fop.render.pdf.FontSetup.setup(fontInfo, org.apache.fop.configuration.Configuration.getFonts()); + org.apache.fop.render.pdf.FontSetup.setup(fontInfo, null); } public FontInfo getFontInfo() { diff --git a/src/org/apache/fop/render/PrintRenderer.java b/src/org/apache/fop/render/PrintRenderer.java index ca0c6238c..153ccc89b 100644 --- a/src/org/apache/fop/render/PrintRenderer.java +++ b/src/org/apache/fop/render/PrintRenderer.java @@ -35,7 +35,7 @@ public abstract class PrintRenderer extends AbstractRenderer { */ public void setupFontInfo(FontInfo fontInfo) { this.fontInfo = fontInfo; - FontSetup.setup(fontInfo, org.apache.fop.configuration.Configuration.getFonts()); + FontSetup.setup(fontInfo, null); } /** diff --git a/src/org/apache/fop/render/pdf/FontReader.java b/src/org/apache/fop/render/pdf/FontReader.java index 31cfdb2e9..52e6452c4 100644 --- a/src/org/apache/fop/render/pdf/FontReader.java +++ b/src/org/apache/fop/render/pdf/FontReader.java @@ -16,10 +16,9 @@ import org.xml.sax.Attributes; import java.io.IOException; import java.util.Enumeration; import java.util.ArrayList; -import java.util.Hashtable; +import java.util.HashMap; import org.apache.fop.pdf.PDFWArray; import org.apache.fop.pdf.PDFCIDFont; -import org.apache.fop.configuration.ConfigurationReader; import org.apache.fop.apps.FOPException; /** @@ -38,18 +37,23 @@ public class FontReader extends DefaultHandler { private MultiByteFont multiFont = null; private SingleByteFont singleFont = null; private Font returnFont = null; - // private SingleByteFont singleFont = null; private String text = null; private ArrayList cidWidths = null; private int cidWidthIndex = 0; - private Hashtable currentKerning = null; + private HashMap currentKerning = null; private ArrayList bfranges = null; private void createFont(String path) throws FOPException { - XMLReader parser = ConfigurationReader.createParser(); + XMLReader parser = null; + + try { + parser = javax.xml.parsers.SAXParserFactory.newInstance().newSAXParser().getXMLReader(); + } catch (Exception e) { + throw new FOPException(e); + } if (parser == null) throw new FOPException("Unable to create SAX parser"); @@ -147,7 +151,7 @@ public class FontReader extends DefaultHandler { cidWidthIndex = getInt(attributes.getValue("start-index")); cidWidths = new ArrayList(); } else if ("kerning".equals(localName)) { - currentKerning = new Hashtable(); + currentKerning = new HashMap(); if (isCID) multiFont.kerning.put(new Integer(attributes.getValue("kpx1")), currentKerning); diff --git a/src/org/apache/fop/render/ps/PSRenderer.java b/src/org/apache/fop/render/ps/PSRenderer.java index 0fbc27347..3234bba2d 100644 --- a/src/org/apache/fop/render/ps/PSRenderer.java +++ b/src/org/apache/fop/render/ps/PSRenderer.java @@ -229,7 +229,7 @@ public class PSRenderer extends AbstractRenderer { */ public void setupFontInfo(FontInfo fontInfo) { /* use PDF's font setup to get PDF metrics */ - org.apache.fop.render.pdf.FontSetup.setup(fontInfo, org.apache.fop.configuration.Configuration.getFonts()); + org.apache.fop.render.pdf.FontSetup.setup(fontInfo, null); this.fontInfo = fontInfo; } diff --git a/src/org/apache/fop/render/xml/XMLRenderer.java b/src/org/apache/fop/render/xml/XMLRenderer.java index 15ba3c66d..1571fc825 100644 --- a/src/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/org/apache/fop/render/xml/XMLRenderer.java @@ -149,7 +149,7 @@ public class XMLRenderer extends AbstractRenderer { public void setupFontInfo(FontInfo fontInfo) { /* use PDF's font setup to get PDF metrics */ - org.apache.fop.render.pdf.FontSetup.setup(fontInfo, org.apache.fop.configuration.Configuration.getFonts()); + org.apache.fop.render.pdf.FontSetup.setup(fontInfo, null); } private boolean isCoarseXml() { diff --git a/src/org/apache/fop/tools/AreaTreeBuilder.java b/src/org/apache/fop/tools/AreaTreeBuilder.java index 03e863d1f..467c40b0a 100644 --- a/src/org/apache/fop/tools/AreaTreeBuilder.java +++ b/src/org/apache/fop/tools/AreaTreeBuilder.java @@ -8,7 +8,6 @@ package org.apache.fop.tools; import org.apache.fop.apps.*; -import org.apache.fop.configuration.*; import org.apache.fop.area.*; import org.apache.fop.area.inline.*; import org.apache.fop.area.inline.Character; diff --git a/src/org/apache/fop/tools/TestConverter.java b/src/org/apache/fop/tools/TestConverter.java index 792f1bfd2..fac914a3f 100644 --- a/src/org/apache/fop/tools/TestConverter.java +++ b/src/org/apache/fop/tools/TestConverter.java @@ -8,7 +8,7 @@ package org.apache.fop.tools; import org.apache.fop.apps.*; -import org.apache.fop.configuration.*; +import org.apache.fop.fo.FOUserAgent; import org.apache.avalon.framework.logger.ConsoleLogger; import org.apache.avalon.framework.logger.AbstractLogEnabled; @@ -198,10 +198,9 @@ public class TestConverter extends AbstractLogEnabled { try { File xmlFile = new File(baseDir + "/" + xml); - + String baseURL = null; try { - Configuration.put("baseDir", - xmlFile.getParentFile().toURL().toExternalForm()); + baseURL = xmlFile.getParentFile().toURL().toExternalForm(); } catch (Exception e) { getLogger().error("Error setting base directory"); } @@ -221,6 +220,9 @@ public class TestConverter extends AbstractLogEnabled { Driver driver = new Driver(); setupLogger(driver, "fop"); driver.initialize(); + FOUserAgent userAgent = new FOUserAgent(); + userAgent.setBaseURL(baseURL); + driver.setUserAgent(userAgent); if (outputPDF) { driver.setRenderer(Driver.RENDER_PDF); } else { diff --git a/src/org/apache/fop/tools/anttasks/Fop.java b/src/org/apache/fop/tools/anttasks/Fop.java index 09ccbbb90..9fbf81b47 100644 --- a/src/org/apache/fop/tools/anttasks/Fop.java +++ b/src/org/apache/fop/tools/anttasks/Fop.java @@ -22,13 +22,12 @@ import java.io.*; import java.util.*; // FOP -import org.apache.fop.apps.Options; import org.apache.fop.apps.Starter; import org.apache.fop.apps.InputHandler; import org.apache.fop.apps.FOInputHandler; import org.apache.fop.apps.Driver; import org.apache.fop.apps.FOPException; -import org.apache.fop.configuration.Configuration; +import org.apache.fop.fo.FOUserAgent; // Avalon import org.apache.avalon.framework.logger.ConsoleLogger; @@ -189,6 +188,7 @@ public class Fop extends Task { class FOPTaskStarter extends Starter { Fop task; + String baseURL = null; FOPTaskStarter(Fop task) throws FOPException { this.task = task; @@ -255,21 +255,18 @@ class FOPTaskStarter extends Starter { public void run() throws FOPException { if (task.userConfig != null) { - new Options (task.userConfig); } try { if (task.getFofile() != null) { - Configuration.put("baseDir", - task.getFofile().getParentFile().toURL(). - toExternalForm()); + baseURL = task.getFofile().getParentFile().toURL(). + toExternalForm(); } } catch (Exception e) { getLogger().error("Error setting base directory", e); } - task.log("Using base directory: " + - Configuration.getValue("baseDir"), Project.MSG_DEBUG); + task.log("Using base URL: " + baseURL, Project.MSG_DEBUG); int rint = determineRenderer(task.getFormat()); String newExtension = determineExtension(rint); @@ -304,12 +301,11 @@ class FOPTaskStarter extends Starter { outf = new File(task.getOutdir(), outf.getName()); } try { - Configuration.put("baseDir", - fs.getDir(task.getProject()).toURL(). - toExternalForm()); + baseURL = fs.getDir(task.getProject()).toURL(). + toExternalForm(); } catch (Exception e) { - task.log("Error setting base directory", + task.log("Error setting base URL", Project.MSG_DEBUG); } @@ -344,12 +340,10 @@ class FOPTaskStarter extends Starter { try { Driver driver = new Driver(inputHandler.getInputSource(), out); setupLogger(driver); + FOUserAgent userAgent = new FOUserAgent(); + userAgent.setBaseURL(baseURL); + driver.setUserAgent(userAgent); driver.setRenderer(renderer); - if (renderer == Driver.RENDER_XML) { - HashMap rendererOptions = new HashMap(); - rendererOptions.put("fineDetail", new Boolean(true)); - driver.getRenderer().setOptions(rendererOptions); - } driver.setXMLReader(parser); driver.run(); out.close(); -- 2.39.5