From 9c4b78a521ec8754e59eb5d13ecf03eb5479328c Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Mon, 8 Mar 2004 21:02:27 +0000 Subject: [PATCH] Dropped createParser back to super class InputHandler. Changed related methods from call to instance. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197426 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/apps/FOFileHandler.java | 32 ++----------------- .../org/apache/fop/apps/InputHandler.java | 30 +++++++++++++++++ .../org/apache/fop/apps/XSLTInputHandler.java | 4 +-- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/java/org/apache/fop/apps/FOFileHandler.java b/src/java/org/apache/fop/apps/FOFileHandler.java index 3ebe2b7fa..a8a003e6f 100644 --- a/src/java/org/apache/fop/apps/FOFileHandler.java +++ b/src/java/org/apache/fop/apps/FOFileHandler.java @@ -29,7 +29,7 @@ import java.net.URL; * Manages input if it is an XSL-FO file. */ public class FOFileHandler extends InputHandler { - + private File fofile = null; private URL foURL = null; @@ -67,40 +67,12 @@ public class FOFileHandler extends InputHandler { return createParser(); } - /** - * creates a SAX parser, using the value of org.xml.sax.parser - * defaulting to org.apache.xerces.parsers.SAXParser - * - * @return the created SAX parser - */ - protected static XMLReader createParser() throws FOPException { - String parserClassName = System.getProperty("org.xml.sax.parser"); - if (parserClassName == null) { - parserClassName = "org.apache.xerces.parsers.SAXParser"; - } - Fop.logger.config("using SAX parser " + parserClassName); - - try { - return (XMLReader)Class.forName(parserClassName).newInstance(); - } catch (ClassNotFoundException e) { - throw new FOPException(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); - } - } - /** * Returns the fully qualified classname of the standard XML parser for FOP * to use. * @return the XML parser classname */ - public static final String getParserClassName() { + public String getParserClassName() { try { return createParser().getClass().getName(); } catch (FOPException e) { diff --git a/src/java/org/apache/fop/apps/InputHandler.java b/src/java/org/apache/fop/apps/InputHandler.java index 9597ee324..6ace226fd 100644 --- a/src/java/org/apache/fop/apps/InputHandler.java +++ b/src/java/org/apache/fop/apps/InputHandler.java @@ -24,6 +24,7 @@ import org.xml.sax.XMLReader; // Java import java.net.URL; +import java.util.logging.Logger; import java.io.File; /** @@ -33,6 +34,7 @@ import java.io.File; */ public abstract class InputHandler { + protected Logger log = Logger.getLogger(Fop.fopPackage); /** * Get the input source associated with this input handler. * @return the input source @@ -77,5 +79,33 @@ public abstract class InputHandler { } } + /** + * creates a SAX parser, using the value of org.xml.sax.parser + * defaulting to org.apache.xerces.parsers.SAXParser + * + * @return the created SAX parser + */ + protected XMLReader createParser() throws FOPException { + String parserClassName = System.getProperty("org.xml.sax.parser"); + if (parserClassName == null) { + parserClassName = "org.apache.xerces.parsers.SAXParser"; + } + log.config("using SAX parser " + parserClassName); + + try { + return (XMLReader)Class.forName(parserClassName).newInstance(); + } catch (ClassNotFoundException e) { + throw new FOPException(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); + } + } + } diff --git a/src/java/org/apache/fop/apps/XSLTInputHandler.java b/src/java/org/apache/fop/apps/XSLTInputHandler.java index dd2a7e022..882033616 100644 --- a/src/java/org/apache/fop/apps/XSLTInputHandler.java +++ b/src/java/org/apache/fop/apps/XSLTInputHandler.java @@ -122,7 +122,7 @@ public class XSLTInputHandler extends InputHandler { * XMLReaders or XMLFilters * @throws FOPException if setting up the XMLFilter fails */ - public static XMLFilter getXMLFilter(Source xsltSource, Vector inParams) + public XMLFilter getXMLFilter(Source xsltSource, Vector inParams) throws FOPException { try { // Instantiate a TransformerFactory. @@ -150,7 +150,7 @@ public class XSLTInputHandler extends InputHandler { */ // Create an XMLReader. - XMLReader parser = FOFileHandler.createParser(); + XMLReader parser = createParser(); if (parser == null) { throw new FOPException("Unable to create SAX parser"); } -- 2.39.5