/*
* $Id$
- * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
//FOP
/*
* $Id$
- * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
// java
/**
* parses the commandline arguments
- * @return true if parse was successful and processing can continue, false if processing should stop
+ * @return true if parse was successful and processing can continue, false
+ * if processing should stop
* @exception FOPException if there was an error in the format of the options
*/
private boolean parseOptions(String args[]) throws FOPException {
} else if (args[i].equals("-c")) {
if ((i + 1 == args.length)
|| (args[i + 1].charAt(0) == '-')) {
- throw new FOPException("if you use '-c', you must specify the name of the configuration file");
+ throw new FOPException("if you use '-c', you must specify "
+ + "the name of the configuration file");
} else {
userConfigFile = new File(args[i + 1]);
i++;
inputmode = XSLT_INPUT;
if ((i + 1 == args.length)
|| (args[i + 1].charAt(0) == '-')) {
- throw new FOPException("you must specify the stylesheet file for the '-xsl' option");
+ throw new FOPException("you must specify the stylesheet "
+ + "file for the '-xsl' option");
} else {
xsltfile = new File(args[i + 1]);
i++;
inputmode = XSLT_INPUT;
if ((i + 1 == args.length)
|| (args[i + 1].charAt(0) == '-')) {
- throw new FOPException("you must specify the input file for the '-xml' option");
+ throw new FOPException("you must specify the input file "
+ + "for the '-xml' option");
} else {
xmlfile = new File(args[i + 1]);
i++;
setOutputMode(SVG_OUTPUT);
if ((i + 1 == args.length)
|| (args[i + 1].charAt(0) == '-')) {
- throw new FOPException("you must specify the svg output file"); } else {
+ throw new FOPException("you must specify the svg output file");
+ } else {
outfile = new File(args[i + 1]);
i++;
}
/**
* Get the starter for the process.
* @return the starter.
+ * @throws FOPException In case of failure while getting the starter
*/
public Starter getStarter() throws FOPException {
Starter starter = null;
return starter;
}
+ /**
+ * Returns the input mode (type of input data, ex. NOT_SET or FO_INPUT)
+ * @return the input mode
+ */
public int getInputMode() {
return inputmode;
}
+ /**
+ * Returns the output mode (output format, ex. NOT_SET or PDF_OUTPUT)
+ * @return the output mode
+ */
public int getOutputMode() {
return outputmode;
}
+ /**
+ * Returns the XSL-FO file if set.
+ * @return the XSL-FO file, null if not set
+ */
public File getFOFile() {
return fofile;
}
+ /**
+ * Returns the input XML file if set.
+ * @return the input XML file, null if not set
+ */
public File getXMLFile() {
return xmlfile;
}
+ /**
+ * Returns the stylesheet to be used for transformation to XSL-FO.
+ * @return stylesheet
+ */
public File getXSLFile() {
return xsltfile;
}
+ /**
+ * Returns the output file
+ * @return the output file
+ */
public File getOutputFile() {
return outfile;
}
+ /**
+ * Returns the user configuration file to be used.
+ * @return the userconfig.xml file
+ */
public File getUserConfigFile() {
return userConfigFile;
}
+ /**
+ * Returns the default language
+ * @return the default language
+ */
public String getLanguage() {
return language;
}
+ /**
+ * Indicates if FOP should be silent.
+ * @return true if should be silent
+ */
public Boolean isQuiet() {
return quiet;
}
+ /**
+ * Indicates if FOP should dump its configuration during runtime.
+ * @return true if config dump is enabled
+ */
public Boolean dumpConfiguration() {
return dumpConfiguration;
}
+ /**
+ * Indicates whether the XML renderer should generate course area XML
+ * @return true if coarse area XML is desired
+ */
public Boolean isCoarseAreaXml() {
return suppressLowLevelAreas;
}
/**
+ * Returns the input file.
* @return either the fofile or the xmlfile
*/
public File getInputFile() {
* shows the commandline syntax including a summary of all available options and some examples
*/
public static void printUsage() {
- System.err.println("\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-pcl|-ps|-txt|-at|-print] <outfile>\n"
- + " [OPTIONS] \n"
- + " -d debug mode \n"
- + " -x dump configuration settings \n"
- + " -q quiet mode \n"
- + " -c cfg.xml use additional configuration file cfg.xml\n"
- + " -l lang the language to use for user information \n"
- + " -s for area tree XML, down to block areas only\n\n"
- + " [INPUT] \n"
- + " infile xsl:fo input file (the same as the next) \n"
- + " -fo infile xsl:fo input file \n"
- + " -xml infile xml input file, must be used together with -xsl \n"
- + " -xsl stylesheet xslt stylesheet \n \n"
- + " [OUTPUT] \n"
- + " outfile input will be rendered as pdf file into outfile \n"
- + " -pdf outfile input will be rendered as pdf file (outfile req'd) \n"
- + " -awt input will be displayed on screen \n"
- + " -mif outfile input will be rendered as mif file (outfile req'd)\n"
- + " -rtf outfile input will be rendered as rtf file (outfile req'd)\n"
- + " -pcl outfile input will be rendered as pcl file (outfile req'd) \n"
- + " -ps outfile input will be rendered as PostScript file (outfile req'd) \n"
- + " -txt outfile input will be rendered as text file (outfile req'd) \n"
- + " -svg outfile input will be rendered as an svg slides file (outfile req'd) \n"
- + " -at outfile representation of area tree as XML (outfile req'd) \n"
- + " -print input file will be rendered and sent to the printer \n"
- + " see options with \"-print help\" \n\n"
- + " [Examples]\n" + " Fop foo.fo foo.pdf \n"
- + " Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n"
- + " Fop -xsl foo.xsl -xml foo.xml -pdf foo.pdf\n"
- + " Fop foo.fo -mif foo.mif\n"
- + " Fop foo.fo -rtf foo.rtf\n"
- + " Fop foo.fo -print or Fop -print foo.fo \n"
- + " Fop foo.fo -awt \n");
+ System.err.println(
+ "\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] "
+ + "[-awt|-pdf|-mif|-rtf|-pcl|-ps|-txt|-at|-print] <outfile>\n"
+ + " [OPTIONS] \n"
+ + " -d debug mode \n"
+ + " -x dump configuration settings \n"
+ + " -q quiet mode \n"
+ + " -c cfg.xml use additional configuration file cfg.xml\n"
+ + " -l lang the language to use for user information \n"
+ + " -s for area tree XML, down to block areas only\n\n"
+ + " [INPUT] \n"
+ + " infile xsl:fo input file (the same as the next) \n"
+ + " -fo infile xsl:fo input file \n"
+ + " -xml infile xml input file, must be used together with -xsl \n"
+ + " -xsl stylesheet xslt stylesheet \n \n"
+ + " [OUTPUT] \n"
+ + " outfile input will be rendered as pdf file into outfile \n"
+ + " -pdf outfile input will be rendered as pdf file (outfile req'd) \n"
+ + " -awt input will be displayed on screen \n"
+ + " -mif outfile input will be rendered as mif file (outfile req'd)\n"
+ + " -rtf outfile input will be rendered as rtf file (outfile req'd)\n"
+ + " -pcl outfile input will be rendered as pcl file (outfile req'd) \n"
+ + " -ps outfile input will be rendered as PostScript file (outfile req'd) \n"
+ + " -txt outfile input will be rendered as text file (outfile req'd) \n"
+ + " -svg outfile input will be rendered as an svg slides file (outfile req'd) \n"
+ + " -at outfile representation of area tree as XML (outfile req'd) \n"
+ + " -print input file will be rendered and sent to the printer \n"
+ + " see options with \"-print help\" \n\n"
+ + " [Examples]\n" + " Fop foo.fo foo.pdf \n"
+ + " Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n"
+ + " Fop -xsl foo.xsl -xml foo.xml -pdf foo.pdf\n"
+ + " Fop foo.fo -mif foo.mif\n"
+ + " Fop foo.fo -rtf foo.rtf\n"
+ + " Fop foo.fo -print or Fop -print foo.fo \n"
+ + " Fop foo.fo -awt \n");
}
/**
/*
* $Id$
- * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
// SAX
*/
public class CommandLineStarter extends Starter {
+ /** the command-line options associated with this starter */
protected CommandLineOptions commandLineOptions;
+ /**
+ * Main constructor
+ * @param commandLineOptions command-line options to use
+ * @throws FOPException In case of failure
+ */
public CommandLineStarter(CommandLineOptions commandLineOptions)
- throws FOPException {
+ throws FOPException {
this.commandLineOptions = commandLineOptions;
super.setInputHandler(commandLineOptions.getInputHandler());
}
/*
* $Id$
- * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
// FOP
import java.io.OutputStream;
import java.io.Reader;
import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
/**
* Primary class that drives overall FOP process.
private Logger log = null;
private FOUserAgent userAgent = null;
+ /**
+ * 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 javax.xml.parsers.SAXParserFactory.newInstance()
}
/**
- * create a new Driver
+ * Main constructor for the Driver class.
*/
public Driver() {
stream = null;
}
+ /**
+ * Convenience constructor for directly setting input and output.
+ * @param source InputSource to take the XSL-FO input from
+ * @param stream Target output stream
+ */
public Driver(InputSource source, OutputStream stream) {
this();
this.source = source;
this.stream = stream;
}
+ /**
+ * Initializes the Driver object.
+ */
public void initialize() {
stream = null;
treeBuilder = new FOTreeBuilder();
setupDefaultMappings();
}
+ /**
+ * Optionally sets the FOUserAgent instance for FOP to use. The Driver
+ * class sets up its own FOUserAgent if none is set through this method.
+ * @param agent FOUserAgent to use
+ */
public void setUserAgent(FOUserAgent agent) {
userAgent = agent;
}
return userAgent;
}
+ /**
+ * Provide the Driver instance with a logger. More information on Avalon
+ * logging can be found at the
+ * <a href="http://avalon.apache.org">Avalon site</a>.
+ *
+ * @param log the logger. Must not be <code>null</code>.
+ * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(Logger)
+ */
public void enableLogging(Logger log) {
if (this.log == null) {
this.log = log;
}
+ /**
+ * Returns the logger for use by FOP.
+ * @return the logger
+ * @see #enableLogging(Logger)
+ */
protected Logger getLogger() {
if (this.log == null) {
this.log = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
treeBuilder.reset();
}
+ /**
+ * Indicates whether FOP has already received input data.
+ * @return true, if input data was received
+ */
public boolean hasData() {
return (treeBuilder.hasData());
}
* Set the OutputStream to use to output the result of the Renderer
* (if applicable)
* @param stream the stream to output the result of rendering to
- *
*/
public void setOutputStream(OutputStream stream) {
this.stream = stream;
addElementMapping("org.apache.fop.extensions.ExtensionElementMapping");
// add mappings from available services
- Enumeration providers =
+ Iterator providers =
Service.providers(org.apache.fop.fo.ElementMapping.class);
if (providers != null) {
- while (providers.hasMoreElements()) {
- String str = (String)providers.nextElement();
+ while (providers.hasNext()) {
+ String str = (String)providers.next();
try {
addElementMapping(str);
} catch (IllegalArgumentException e) {
+ getLogger().warn("Error while adding element mapping", e);
}
}
this.renderer = renderer;
}
+ /**
+ * Returns the currently active renderer.
+ * @return the renderer
+ */
public Renderer getRenderer() {
return renderer;
}
/**
- * @deprecated use renderer.setProducer(version) + setRenderer(renderer) or just setRenderer(rendererType) which will use the default producer string.
+ * Sets the renderer.
+ * @param rendererClassName the fully qualified classname of the renderer
+ * class to use.
+ * @param version version number
+ * @deprecated use renderer.setProducer(version) + setRenderer(renderer) or
+ * just setRenderer(rendererType) which will use the default producer string.
* @see #setRenderer(int)
* @see #setRenderer(Renderer)
*/
* @see #setRenderer(int)
*/
public void setRenderer(String rendererClassName)
- throws IllegalArgumentException {
+ throws IllegalArgumentException {
try {
renderer =
(Renderer)Class.forName(rendererClassName).newInstance();
/**
* Add the element mapping with the given class name.
- * @param the class name representing the element mapping.
+ * @param mappingClassName the class name representing the element mapping.
* @throws IllegalArgumentException if there was not such element mapping.
*/
public void addElementMapping(String mappingClassName)
- throws IllegalArgumentException {
+ throws IllegalArgumentException {
try {
ElementMapping mapping =
(ElementMapping)Class.forName(mappingClassName).newInstance();
* @return a content handler for handling the SAX events.
*/
public ContentHandler getContentHandler() {
- // TODO - do this stuff in a better way
+ // TODO: - do this stuff in a better way
// PIJ: I guess the structure handler should be created by the renderer.
if (rendererType == RENDER_MIF) {
structHandler = new org.apache.fop.mif.MIFHandler(stream);
structHandler = new org.apache.fop.rtf.renderer.RTFHandler(stream);
} else {
if (renderer == null) {
- throw new Error("Renderer not set when using standard structHandler");
+ throw new IllegalStateException(
+ "Renderer not set when using standard structHandler");
}
structHandler = new LayoutHandler(stream, renderer, true);
}
* @throws FOPException if anything goes wrong.
*/
public synchronized void render(XMLReader parser, InputSource source)
- throws FOPException {
+ throws FOPException {
parser.setContentHandler(getContentHandler());
try {
parser.parse(source);
* @throws FOPException if anything goes wrong.
*/
public synchronized void render(Document document)
- throws FOPException {
+ throws FOPException {
try {
DocumentInputSource source = new DocumentInputSource(document);
DocumentReader reader = new DocumentReader();
* @throws IOException in case of IO errors.
* @throws FOPException if anything else goes wrong.
*/
- public synchronized void run()
- throws IOException, FOPException {
+ public synchronized void run() throws IOException, FOPException {
if (renderer == null) {
setRenderer(RENDER_PDF);
}
*/
class Service {
- static private Hashtable providerMap = new Hashtable();
+ private static Map providerMap = new java.util.Hashtable();
- public static synchronized Enumeration providers(Class cls) {
+ public static synchronized Iterator providers(Class cls) {
ClassLoader cl = cls.getClassLoader();
// null if loaded by bootstrap class loader
if (cl == null) {
// getLogger().debug("File: " + serviceFile);
- Vector v = (Vector)providerMap.get(serviceFile);
- if (v != null) {
- return v.elements();
+ List lst = (List)providerMap.get(serviceFile);
+ if (lst != null) {
+ return lst.iterator();
}
- v = new Vector();
- providerMap.put(serviceFile, v);
+ lst = new java.util.Vector();
+ providerMap.put(serviceFile, lst);
Enumeration e;
try {
e = cl.getResources(serviceFile);
} catch (IOException ioe) {
- return v.elements();
+ return lst.iterator();
}
while (e.hasMoreElements()) {
// Try and load the class
// Object obj = cl.loadClass(line).newInstance();
// stick it into our vector...
- v.add(line);
+ lst.add(line);
} catch (Exception ex) {
// Just try the next line
}
}
}
- return v.elements();
+ return lst.iterator();
}
}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001-2003 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;
-
-/**
- * not implemented yet
- */
-public interface ErrorHandler {
-}
/*
* $Id$
- * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
// Imported SAX classes
import java.net.URL;
/**
- * Manages input if it is an xsl:fo file
+ * 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 file the file to read the FO document.
+ * @param fofile the file to read the FO document.
*/
- public FOInputHandler (File fofile) {
+ public FOInputHandler(File fofile) {
this.fofile = fofile;
}
- /*
+ /**
* Create a FOInputHandler for an URL.
- * @param file the URL to read the FO document.
+ * @param url the URL to read the FO document.
*/
- public FOInputHandler (URL url) {
+ public FOInputHandler(URL url) {
this.foURL = url;
}
- /*
- * Get the input source associated with this input handler.
+ /**
+ * @see org.apache.fop.apps.InputHandler#getInputSource()
*/
public InputSource getInputSource () {
if (fofile != null) {
return super.urlInputSource(foURL);
}
- /*
- * Get the SAX parser associated with this input handler.
+ /**
+ * @see org.apache.fop.apps.InputHandler#getParser()
*/
public XMLReader getParser() throws FOPException {
return super.createParser();
/*
* $Id$
- * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources."
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
import org.xml.sax.SAXException;
-
/**
- * Exception thrown when FOP has a problem
+ * Exception thrown when FOP has a problem.
*/
public class FOPException extends Exception {
/*
* $Id$
- * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
-/*
+/**
* The main application class for the FOP command line interface (CLI).
*/
public class Fop {
- /*
+ /**
* The main routine for the command line interface
* @param args the command line parameters
*/
Starter starter = options.getStarter();
starter.run();
} catch (FOPException e) {
- if (e.getMessage()==null) {
+ if (e.getMessage() == null) {
System.err.println("Exception occured with a null error message");
} else {
System.err.println("" + e.getMessage());
/*
* $Id$
- * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
// SAX
import java.net.URL;
import java.io.File;
-/*
+/**
* Abstract super class for input handlers.
* Should be used to abstract the various possibilities on how input
* can be provided to FOP (but actually isn't).
*/
public abstract class InputHandler {
+ /**
+ * Get the input source associated with this input handler.
+ * @return the input source
+ */
public abstract InputSource getInputSource();
+
+ /**
+ * Get the SAX parser associated with this input handler.
+ * @return the SAX parser
+ * @throws FOPException in case of an error determining the SAX parser
+ */
public abstract XMLReader getParser() throws FOPException;
+ /**
+ * Creates an InputSource from a URL.
+ * @param url URL to use
+ * @return the newly created InputSource
+ */
public static InputSource urlInputSource(URL url) {
return new InputSource(url.toString());
}
/*
* $Id$
- * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
// Java
// TODO: Collecting of statistics should be configurable
private final boolean collectStatistics = true;
- private final boolean MEM_PROFILE_WITH_GC = false;
+ private static final boolean MEM_PROFILE_WITH_GC = false;
/**
- Somewhere to get our stats from.
+ * Somewhere to get our stats from.
*/
private Runtime runtime;
/**
- Keep track of the number of pages rendered.
+ * Keep track of the number of pages rendered.
*/
private int pageCount;
/**
- Keep track of heap memory allocated,
- for statistical purposes.
+ * Keep track of heap memory allocated,
+ * for statistical purposes.
*/
private long initialMemory;
/**
- Keep track of time used by renderer.
+ * Keep track of time used by renderer.
*/
private long startTime;
/**
- The stream to which this rendering is to be
- written to. <B>Note</B> that some renderers
- do not render to a stream, and that this
- member can therefore be null.
+ * The stream to which this rendering is to be
+ * written to. <B>Note</B> that some renderers
+ * do not render to a stream, and that this
+ * member can therefore be null.
*/
private OutputStream outputStream;
/**
- The renderer being used.
+ * The renderer being used.
*/
private Renderer renderer;
/**
- The FontInfo for this renderer.
+ * The FontInfo for this renderer.
*/
private FontInfo fontInfo = new FontInfo();
private AreaTreeModel atModel;
/**
+ * Main constructor
* @param outputStream the stream that the result is rendered to
* @param renderer the renderer to call
* @param store if true then use the store pages model and keep the
*/
public LayoutHandler(OutputStream outputStream, Renderer renderer,
boolean store) {
- if (collectStatistics)
+ if (collectStatistics) {
runtime = Runtime.getRuntime();
+ }
this.outputStream = outputStream;
this.renderer = renderer;
if (MEM_PROFILE_WITH_GC) {
System.gc(); // This takes time but gives better results
}
+
initialMemory = runtime.totalMemory() - runtime.freeMemory();
startTime = System.currentTimeMillis();
}
try {
renderer.setupFontInfo(fontInfo);
// check that the "any,normal,400" font exists
- if(!fontInfo.isSetupValid()) {
- throw new SAXException(new FOPException("no default font defined by OutputConverter"));
+ if (!fontInfo.isSetupValid()) {
+ throw new SAXException(new FOPException(
+ "No default font defined by OutputConverter"));
}
renderer.startRenderer(outputStream);
} catch (IOException e) {
* @param seqTitle the title of the page sequence
* @param lms the layout master set
*/
- public void startPageSequence(PageSequence pageSeq, org.apache.fop.fo.Title seqTitle, LayoutMasterSet lms) {
+ public void startPageSequence(PageSequence pageSeq,
+ org.apache.fop.fo.Title seqTitle,
+ LayoutMasterSet lms) {
Title title = null;
if (seqTitle != null) {
title = seqTitle.getTitleArea();
* @throws FOPException if there is an error formatting the pages
*/
public void endPageSequence(PageSequence pageSequence)
- throws FOPException {
+ throws FOPException {
//areaTree.setFontInfo(fontInfo);
if (collectStatistics) {
count++;
}
List list = model.getEndExtensions();
- for(count = 0; count < list.size(); count++) {
+ for (count = 0; count < list.size(); count++) {
TreeExt ext = (TreeExt)list.get(count);
renderer.renderExtension(ext);
}
/*
* $Id$
- * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
/*
import org.xml.sax.XMLReader;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import java.awt.Graphics;
-import java.awt.print.*;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Vector;
import org.apache.fop.render.awt.AWTRenderer;
/**
- * This class prints a xsl-fo dokument without interaction.
+ * This class prints a XSL-FO dokument without interaction.
* At the moment java has not the possibility to configure the printer and it's
* options without interaction (30.03.2000).
* This class allows to print a set of pages (from-to), even/odd pages and many copies.
* - Print to page xxx: property name - end, value int
* - Print even/odd pages: property name - even, value boolean
* - Print xxx copies: property name - copies, value int
- *
*/
public class PrintStarter extends CommandLineStarter {
+ /**
+ * @see org.apache.fop.apps.CommandLineStarter#CommandLineStarter(CommandLineOptions)
+ */
public PrintStarter(CommandLineOptions options) throws FOPException {
super(options);
}
+ /**
+ * @see org.apache.fop.apps.Starter#run()
+ */
public void run() throws FOPException {
Driver driver = new Driver();
mode = EVEN_AND_ALL;
String str = System.getProperty("even");
if (str != null) {
- try {
- mode = Boolean.valueOf(str).booleanValue() ? EVEN : ODD;
- } catch (Exception e) {}
-
+ mode = Boolean.valueOf(str).booleanValue() ? EVEN : ODD;
}
}
printerJob.print();
} catch (PrinterException e) {
e.printStackTrace();
- throw new IOException(
- "Unable to print: " + e.getClass().getName() +
- ": " + e.getMessage());
+ throw new IOException("Unable to print: "
+ + e.getClass().getName()
+ + ": " + e.getMessage());
}
}
/*
* $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.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
// Avalon
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
-// Java
-import java.io.*;
-import java.net.URL;
-
/**
- * abstract super class
+ * Abstract super class.
* Creates a SAX Parser (defaulting to Xerces).
- *
*/
public abstract class Starter extends AbstractLogEnabled {
- InputHandler inputHandler;
+ /** InputHandler associated with this Starter */
+ protected InputHandler inputHandler;
+ /**
+ * Main constructor
+ * @throws FOPException In case of a problem constructing the Starter
+ */
public Starter() throws FOPException {
}
+ /**
+ * Sets the InputHandler to use.
+ * @param inputHandler input handler
+ */
public void setInputHandler(InputHandler inputHandler) {
this.inputHandler = inputHandler;
}
+ /**
+ * Runs the current setup.
+ * @throws FOPException In case of a problem during the FOP run
+ */
public abstract void run() throws FOPException;
- // setting the parser features
+ /**
+ * Sets the parser features on an XMLReader
+ * @param parser XMLReader to set features on
+ * @throws FOPException if the XMLReader doesn't support the feature that
+ * need to be set
+ */
public void setParserFeatures(XMLReader parser) throws FOPException {
try {
parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
/*
* $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.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
// Java
import org.apache.avalon.framework.logger.AbstractLogEnabled;
// FOP
-import org.apache.fop.fo.pagination.*;
-import org.apache.fop.fo.flow.*;
-import org.apache.fop.fo.*;
+import org.apache.fop.fo.Title;
+import org.apache.fop.fo.flow.Block;
+import org.apache.fop.fo.flow.ExternalGraphic;
+import org.apache.fop.fo.flow.Flow;
+import org.apache.fop.fo.flow.InstreamForeignObject;
+import org.apache.fop.fo.flow.Leader;
+import org.apache.fop.fo.flow.ListBlock;
+import org.apache.fop.fo.flow.ListItem;
+import org.apache.fop.fo.flow.Table;
+import org.apache.fop.fo.flow.TableBody;
+import org.apache.fop.fo.flow.TableCell;
+import org.apache.fop.fo.flow.TableRow;
+import org.apache.fop.fo.pagination.LayoutMasterSet;
+import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.layout.FontInfo;
import org.xml.sax.SAXException;
*/
public class StructureHandler extends AbstractLogEnabled {
/**
- The current set of id's in the FO tree
- This is used so we know if the FO tree contains duplicates
+ * The current set of id's in the FO tree.
+ * This is used so we know if the FO tree contains duplicates.
*/
private Set idReferences = new HashSet();
+ /**
+ * Main constructor
+ */
public StructureHandler() {
}
+ /**
+ * Retuns the set of ID references.
+ * @return the ID references
+ */
public Set getIDReferences() {
return idReferences;
}
+ /**
+ * Returns the FontInfo object associated with this StructureHandler.
+ * @return the FontInof object
+ */
public FontInfo getFontInfo() {
return null;
}
+ /**
+ * This method is called to indicate the start of a new document run.
+ * @throws SAXException In case of a problem
+ */
public void startDocument() throws SAXException {
-
}
+ /**
+ * This method is called to indicate the end of a document run.
+ * @throws SAXException In case of a problem
+ */
public void endDocument() throws SAXException {
-
}
public void startPageSequence(PageSequence pageSeq, Title seqTitle, LayoutMasterSet lms) {
/*
* $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.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
+// Imported java.io classes
+import java.io.File;
// Imported TraX classes
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.sax.SAXTransformerFactory;
-
// Imported SAX classes
import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.XMLFilter;
-
-
-// Imported java.io classes
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.File;
-
/**
- * XSLTInputHandler basically takes an xmlfile and transforms it with an xsltfile
- * and the resulting xsl:fo document is input for Fop.
+ * XSLTInputHandler basically takes an XML file and transforms it with an
+ * XSLT file and the resulting XSL-FO document is input for FOP.
*/
public class TraxInputHandler extends InputHandler {
- File xmlfile, xsltfile;
+ private File xmlfile, xsltfile;
+ /**
+ * Main constructor
+ * @param xmlfile XML file
+ * @param xsltfile XSLT file
+ */
public TraxInputHandler(File xmlfile, File xsltfile) {
this.xmlfile = xmlfile;
this.xsltfile = xsltfile;
}
/**
- * overwrites the method of the super class to return the xmlfile
+ * @see org.apache.fop.apps.InputHandler#getInputSource()
*/
public InputSource getInputSource() {
return fileInputSource(xmlfile);
}
/**
- * overwrites this method of the super class and returns an XMLFilter instead of a
- * simple XMLReader which allows chaining of transformations
- *
+ * Overwrites this method of the super class and returns an XMLFilter
+ * instead of a simple XMLReader which allows chaining of transformations.
+ * @see org.apache.fop.apps.InputHandler#getParser()
*/
public XMLReader getParser() throws FOPException {
return this.getXMLFilter(xmlfile, xsltfile);
* data is fed into Fop. This should help to avoid memory problems
* @param xmlfile The xmlfile containing the text data
* @param xsltfile An xslt stylesheet
- * @return XMLFilter an XMLFilter which can be chained together with other XMLReaders or XMLFilters
+ * @return an XMLFilter which can be chained together with other
+ * XMLReaders or XMLFilters
+ * @throws FOPException if setting up the XMLFilter fails
*/
public static XMLFilter getXMLFilter(File xmlfile,
File xsltfile) throws FOPException {
xmlfilter.setParent(parser);
return xmlfilter;
} else {
- throw new FOPException("Your parser doesn't support the features SAXSource and SAXResult."
- + "\nMake sure you are using a xsl parser which supports TrAX");
+ throw new FOPException("Your parser doesn't support the "
+ + "features SAXSource and SAXResult."
+ + "\nMake sure you are using an XSLT engine which "
+ + "supports TrAX");
}
+ } catch (FOPException fe) {
+ throw fe;
} catch (Exception ex) {
- if (ex instanceof FOPException) {
- throw (FOPException)ex;
- }
throw new FOPException(ex);
}
}
/*
* $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."
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
/**
- * class representing the version of FOP.
+ * Class representing the version of FOP.
*/
public class Version {
/**
- * get the version of FOP
+ * Get the version of FOP
*
* @return the version string
*/
/*
* $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.
- */
-
+ * ============================================================================
+ * 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
package org.apache.fop.apps;
-import java.lang.reflect.*;
-
+// Imported java.io classes
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
// Imported SAX classes
import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
-// Imported java.io classes
-import java.io.*;
-
// FOP
import org.apache.fop.tools.xslt.XSLTransform;
-/*
-add url constructer
-*/
-
/**
- * XSLTInputHandler basically takes an xmlfile and transforms it with an xsltfile
- * and the resulting xsl:fo document is input for Fop.
+ * XSLTInputHandler basically takes an XML file and transforms it with an XSLT
+ * file and the resulting XSL-FO document is input for FOP.
+ * @todo add URL constructor
*/
public class XSLTInputHandler extends InputHandler {
- File xmlfile, xsltfile;
- boolean useOldTransform = false;
- boolean gotParser = false;
+ private File xmlfile, xsltfile;
+ private boolean useOldTransform = false;
+ private boolean gotParser = false;
+ /**
+ * Main constructor
+ * @param xmlfile XML file
+ * @param xsltfile XSLT file
+ */
public XSLTInputHandler(File xmlfile, File xsltfile) {
this.xmlfile = xmlfile;
this.xsltfile = xsltfile;
}
/**
- * overwrites the method of the super class to return the xmlfile
+ * @see org.apache.fop.apps.InputHandler#getInputSource()
*/
public InputSource getInputSource() {
- if(!gotParser) {
- throw new IllegalStateException("The method getParser() must be called and the parser used when using XSLTInputHandler");
+ if (!gotParser) {
+ throw new IllegalStateException("The method getParser() must be "
+ + "called and the parser used when using XSLTInputHandler");
}
if (useOldTransform) {
try {
// if xml file size is larger than 500 kb write the fo:file to disk
if ((xmlfile.length()) > 500000) {
tmpFile = new File(xmlfile.getName() + ".fo.tmp");
- writer = new FileWriter(tmpFile);
+ writer = new java.io.FileWriter(tmpFile);
} else {
- writer = new StringWriter();
+ writer = new java.io.StringWriter();
}
XSLTransform.transform(xmlfile.getCanonicalPath(),
writer.close();
if (tmpFile != null) {
- reader = new FileReader(tmpFile);
+ reader = new java.io.FileReader(tmpFile);
} else {
// create a input source containing the xsl:fo file which can be fed to Fop
- reader = new StringReader(writer.toString());
+ reader = new java.io.StringReader(writer.toString());
}
return new InputSource(reader);
} catch (Exception ex) {
ex.printStackTrace();
+ /**@todo do proper logging of exceptions */
return null;
}
} else {
/**
* This looks to see if the Trax api is supported and uses that to
* get an XMLFilter. Otherwise, it falls back to using DOM documents
- *
+ * @return the created <code>XMLReader</code>
+ * @throws FOPException if getting the parser fails
+ * @see org.apache.fop.apps.InputHandler#getParser()
*/
public XMLReader getParser() throws FOPException {
gotParser = true;