From: Glen Mazza Date: Tue, 12 Aug 2003 21:17:44 +0000 (+0000) Subject: Renamed apps.FOInputHandler to apps.FOFileHandler to reduce confusion with the new... X-Git-Tag: Root_Temp_KnuthStylePageBreaking~1210 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=69eea3085a1f66ae40adff60745dc66426eee65e;p=xmlgraphics-fop.git Renamed apps.FOInputHandler to apps.FOFileHandler to reduce confusion with the new FOInputHandler in the fo package. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196792 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/apps/CommandLineOptions.java b/src/java/org/apache/fop/apps/CommandLineOptions.java index 264b6dd38..646ba1022 100644 --- a/src/java/org/apache/fop/apps/CommandLineOptions.java +++ b/src/java/org/apache/fop/apps/CommandLineOptions.java @@ -491,7 +491,7 @@ public class CommandLineOptions { public InputHandler getInputHandler() throws FOPException { switch (inputmode) { case FO_INPUT: - return new FOInputHandler(fofile); + return new FOFileHandler(fofile); case XSLT_INPUT: return new XSLTInputHandler(xmlfile, xsltfile); default: diff --git a/src/java/org/apache/fop/apps/Driver.java b/src/java/org/apache/fop/apps/Driver.java index 129ab8e8e..e21624c27 100644 --- a/src/java/org/apache/fop/apps/Driver.java +++ b/src/java/org/apache/fop/apps/Driver.java @@ -648,8 +648,7 @@ public class Driver implements LogEnabled, FOTreeListener { if (reader == null) { if (!(source instanceof DocumentInputSource)) { - //TODO: (gm) rename to FOFileHandler or similar - reader = org.apache.fop.apps.FOInputHandler.createParser(); + reader = FOFileHandler.createParser(); } } diff --git a/src/java/org/apache/fop/apps/FOFileHandler.java b/src/java/org/apache/fop/apps/FOFileHandler.java new file mode 100644 index 000000000..82de09940 --- /dev/null +++ b/src/java/org/apache/fop/apps/FOFileHandler.java @@ -0,0 +1,145 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.apps; + +// Imported SAX classes +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotSupportedException; + +// java +import javax.xml.parsers.SAXParserFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +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; + + /** + * Create a FOFileHandler for a file. + * @param fofile the file to read the FO document. + */ + public FOFileHandler(File fofile) { + this.fofile = fofile; + } + + /** + * Create a FOFileHandler for an URL. + * @param url the URL to read the FO document. + */ + public FOFileHandler(URL url) { + this.foURL = url; + } + + + /** + * @see org.apache.fop.apps.InputHandler#getInputSource() + */ + public InputSource getInputSource () { + if (fofile != null) { + return super.fileInputSource(fofile); + } + return super.urlInputSource(foURL); + } + + /** + * @see org.apache.fop.apps.InputHandler#getParser() + */ + public XMLReader getParser() throws FOPException { + return createParser(); + } + + /** + * Creates XMLReader object using default + * SAXParserFactory + * @return the created XMLReader + * @throws FOPException if the parser couldn't be created or configured for proper operation. + */ + protected static XMLReader createParser() throws FOPException { + try { + SAXParserFactory factory = SAXParserFactory.newInstance(); + factory.setNamespaceAware(true); + factory.setFeature( + "http://xml.org/sax/features/namespace-prefixes", true); + return factory.newSAXParser().getXMLReader(); + } catch (SAXNotSupportedException se) { + throw new FOPException("Error: You need a parser which allows the" + + " http://xml.org/sax/features/namespace-prefixes" + + " feature to be set to true to support namespaces", se); + } catch (SAXException se) { + throw new FOPException("Couldn't create XMLReader", se); + } catch (ParserConfigurationException pce) { + throw new FOPException("Couldn't create XMLReader", pce); + } + } + + /** + * Returns the fully qualified classname of the standard XML parser for FOP + * to use. + * @return the XML parser classname + */ + public static final String getParserClassName() { + try { + return createParser().getClass().getName(); + } catch (FOPException e) { + return null; + } + } +} + diff --git a/src/java/org/apache/fop/apps/FOInputHandler.java b/src/java/org/apache/fop/apps/FOInputHandler.java deleted file mode 100644 index f2696f889..000000000 --- a/src/java/org/apache/fop/apps/FOInputHandler.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * $Id$ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The end-user documentation included with the redistribution, if any, must - * include the following acknowledgment: "This product includes software - * developed by the Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, if - * and wherever such third-party acknowledgments normally appear. - * - * 4. The names "FOP" and "Apache Software Foundation" must not be used to - * endorse or promote products derived from this software without prior - * written permission. For written permission, please contact - * apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", nor may - * "Apache" appear in their name, without prior written permission of the - * Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ============================================================================ - * - * This software consists of voluntary contributions made by many individuals - * on behalf of the Apache Software Foundation and was originally created by - * James Tauber . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.apps; - -// Imported SAX classes -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotSupportedException; - -// java -import javax.xml.parsers.SAXParserFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.File; -import java.net.URL; - - -/** - * Manages input if it is an XSL-FO file. - */ -public class FOInputHandler extends InputHandler { - - private File fofile = null; - private URL foURL = null; - - /** - * Create a FOInputHandler for a file. - * @param fofile the file to read the FO document. - */ - public FOInputHandler(File fofile) { - this.fofile = fofile; - } - - /** - * Create a FOInputHandler for an URL. - * @param url the URL to read the FO document. - */ - public FOInputHandler(URL url) { - this.foURL = url; - } - - - /** - * @see org.apache.fop.apps.InputHandler#getInputSource() - */ - public InputSource getInputSource () { - if (fofile != null) { - return super.fileInputSource(fofile); - } - return super.urlInputSource(foURL); - } - - /** - * @see org.apache.fop.apps.InputHandler#getParser() - */ - public XMLReader getParser() throws FOPException { - return createParser(); - } - - /** - * Creates XMLReader object using default - * SAXParserFactory - * @return the created XMLReader - * @throws FOPException if the parser couldn't be created or configured for proper operation. - */ - protected static XMLReader createParser() throws FOPException { - try { - SAXParserFactory factory = SAXParserFactory.newInstance(); - factory.setNamespaceAware(true); - factory.setFeature( - "http://xml.org/sax/features/namespace-prefixes", true); - return factory.newSAXParser().getXMLReader(); - } catch (SAXNotSupportedException se) { - throw new FOPException("Error: You need a parser which allows the" - + " http://xml.org/sax/features/namespace-prefixes" - + " feature to be set to true to support namespaces", se); - } catch (SAXException se) { - throw new FOPException("Couldn't create XMLReader", se); - } catch (ParserConfigurationException pce) { - throw new FOPException("Couldn't create XMLReader", pce); - } - } - - /** - * Returns the fully qualified classname of the standard XML parser for FOP - * to use. - * @return the XML parser classname - */ - public static final String getParserClassName() { - try { - return createParser().getClass().getName(); - } catch (FOPException e) { - return null; - } - } -} - diff --git a/src/java/org/apache/fop/apps/XSLTInputHandler.java b/src/java/org/apache/fop/apps/XSLTInputHandler.java index 990e683e8..66cd536fa 100644 --- a/src/java/org/apache/fop/apps/XSLTInputHandler.java +++ b/src/java/org/apache/fop/apps/XSLTInputHandler.java @@ -170,7 +170,7 @@ public class XSLTInputHandler extends InputHandler { saxTFactory.newXMLFilter(xsltSource); // Create an XMLReader. - XMLReader parser = FOInputHandler.createParser(); + XMLReader parser = FOFileHandler.createParser(); if (parser == null) { throw new FOPException("Unable to create SAX parser"); } diff --git a/src/java/org/apache/fop/image/XMLImage.java b/src/java/org/apache/fop/image/XMLImage.java index 8b97a2cc8..50733beb4 100644 --- a/src/java/org/apache/fop/image/XMLImage.java +++ b/src/java/org/apache/fop/image/XMLImage.java @@ -54,7 +54,7 @@ package org.apache.fop.image; import org.w3c.dom.Document; // FOP -import org.apache.fop.apps.FOInputHandler; +import org.apache.fop.apps.FOFileHandler; /** * This is an implementation for XML-based images such as SVG. @@ -86,7 +86,7 @@ public class XMLImage extends AbstractFopImage { * @return the created SAX parser */ public static String getParserName() { - String parserClassName = FOInputHandler.getParserClassName(); + String parserClassName = FOFileHandler.getParserClassName(); return parserClassName; } diff --git a/src/java/org/apache/fop/svg/SVGElementMapping.java b/src/java/org/apache/fop/svg/SVGElementMapping.java index 982737eae..3c958527f 100644 --- a/src/java/org/apache/fop/svg/SVGElementMapping.java +++ b/src/java/org/apache/fop/svg/SVGElementMapping.java @@ -54,7 +54,7 @@ import java.util.HashMap; import org.apache.fop.fo.FONode; import org.apache.fop.fo.ElementMapping; -import org.apache.fop.apps.FOInputHandler; +import org.apache.fop.apps.FOFileHandler; import org.apache.batik.util.XMLResourceDescriptor; import org.apache.batik.dom.svg.SVGDOMImplementation; @@ -78,7 +78,7 @@ public class SVGElementMapping extends ElementMapping { // normally the user agent value is used try { XMLResourceDescriptor.setXMLParserClassName( - FOInputHandler.getParserClassName()); + FOFileHandler.getParserClassName()); foObjs = new HashMap(); foObjs.put("svg", new SE()); diff --git a/src/java/org/apache/fop/svg/SVGUserAgent.java b/src/java/org/apache/fop/svg/SVGUserAgent.java index 5711df3c0..5c5dd481c 100644 --- a/src/java/org/apache/fop/svg/SVGUserAgent.java +++ b/src/java/org/apache/fop/svg/SVGUserAgent.java @@ -158,7 +158,7 @@ public class SVGUserAgent extends UserAgentAdapter { * @return the XML parser class name */ public String getXMLParserClassName() { - return org.apache.fop.apps.FOInputHandler.getParserClassName(); + return org.apache.fop.apps.FOFileHandler.getParserClassName(); } /** diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java index bbe5cb709..d7fb0f697 100644 --- a/src/java/org/apache/fop/tools/TestConverter.java +++ b/src/java/org/apache/fop/tools/TestConverter.java @@ -51,7 +51,7 @@ package org.apache.fop.tools; import org.apache.fop.apps.Driver; -import org.apache.fop.apps.FOInputHandler; +import org.apache.fop.apps.FOFileHandler; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.InputHandler; import org.apache.fop.apps.XSLTInputHandler; @@ -278,7 +278,7 @@ public class TestConverter extends AbstractLogEnabled { InputHandler inputHandler = null; if (xsl == null) { - inputHandler = new FOInputHandler(xmlFile); + inputHandler = new FOFileHandler(xmlFile); } else { inputHandler = new XSLTInputHandler(xmlFile, new File(baseDir + "/" diff --git a/src/java/org/apache/fop/tools/anttasks/Fop.java b/src/java/org/apache/fop/tools/anttasks/Fop.java index a54d07558..db388f461 100644 --- a/src/java/org/apache/fop/tools/anttasks/Fop.java +++ b/src/java/org/apache/fop/tools/anttasks/Fop.java @@ -68,7 +68,7 @@ import java.util.List; // FOP import org.apache.fop.apps.Starter; import org.apache.fop.apps.InputHandler; -import org.apache.fop.apps.FOInputHandler; +import org.apache.fop.apps.FOFileHandler; import org.apache.fop.apps.Driver; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FOUserAgent; @@ -502,7 +502,7 @@ class FOPTaskStarter extends Starter { private void render(File foFile, File outFile, int renderer) throws FOPException { - InputHandler inputHandler = new FOInputHandler(foFile); + InputHandler inputHandler = new FOFileHandler(foFile); OutputStream out = null; try {