gmazza 2003/08/12 15:40:49 Modified: src/java/org/apache/fop/apps CommandLineOptions.java Fop.java Removed: src/java/org/apache/fop/apps CommandLineStarter.java Log: 1.) CommandLineStarter removed, its functionality placed directly into Fop.main(). Fop.main() now responsible for taking command-line input as provided from CommandLineOptions, and activating a Driver instance with that data. 2.) Minor cleanup of error messages in CommandLineOptions. Revision Changes Path 1.12 +5 -5 xml-fop/src/java/org/apache/fop/apps/CommandLineOptions.java Index: CommandLineOptions.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/CommandLineOptions.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- CommandLineOptions.java 12 Aug 2003 21:17:44 -0000 1.11 +++ CommandLineOptions.java 12 Aug 2003 22:40:49 -0000 1.12 @@ -407,10 +407,10 @@ if (inputmode == XSLT_INPUT) { // check whether xml *and* xslt file have been set if (xmlfile == null) { - throw new FOPException("XML file must be specified for the tranform mode"); + throw new FOPException("XML file must be specified for the transform mode"); } if (xsltfile == null) { - throw new FOPException("XSLT file must be specified for the tranform mode"); + throw new FOPException("XSLT file must be specified for the transform mode"); } // warning if fofile has been set in xslt mode @@ -424,12 +424,12 @@ + fofile.getAbsolutePath()); } if (!xmlfile.exists()) { - throw new FileNotFoundException("xml file " + throw new FileNotFoundException("Error: xml file " + xmlfile.getAbsolutePath() + " not found "); } if (!xsltfile.exists()) { - throw new FileNotFoundException("xsl file " + throw new FileNotFoundException("Error: xsl file " + xsltfile.getAbsolutePath() + " not found "); } @@ -441,7 +441,7 @@ log.error("xslt file: " + xsltfile.toString()); } if (!fofile.exists()) { - throw new FileNotFoundException("fo file " + throw new FileNotFoundException("Error: fo file " + fofile.getAbsolutePath() + " not found "); } 1.5 +39 -7 xml-fop/src/java/org/apache/fop/apps/Fop.java Index: Fop.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/Fop.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Fop.java 12 Aug 2003 21:36:43 -0000 1.4 +++ Fop.java 12 Aug 2003 22:40:49 -0000 1.5 @@ -50,8 +50,17 @@ */ package org.apache.fop.apps; +// Java +import java.io.BufferedOutputStream; +import java.io.FileOutputStream; + +// Avalon import org.apache.avalon.framework.logger.ConsoleLogger; +// FOP +import org.apache.fop.render.awt.AWTRenderer; + + /** * The main application class for the FOP command line interface (CLI). */ @@ -63,13 +72,37 @@ */ public static void main(String[] args) { CommandLineOptions options = null; - CommandLineStarter starter = null; + InputHandler inputHandler = null; + BufferedOutputStream bos = null; + String version = Version.getVersion(); try { + Driver driver = new Driver(); + driver.enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_INFO)); + driver.getLogger().info(version); options = new CommandLineOptions(args); - starter = new CommandLineStarter(options); - starter.enableLogging(new ConsoleLogger(ConsoleLogger.LEVEL_INFO)); - starter.run(); + inputHandler = options.getInputHandler(); + + try { + if (options.getOutputMode() == CommandLineOptions.AWT_OUTPUT) { + driver.setRenderer(new AWTRenderer(inputHandler)); + } else { + driver.setRenderer(options.getRenderer()); + + if (options.getOutputFile() != null) { + bos = new BufferedOutputStream(new FileOutputStream( + options.getOutputFile())); + driver.setOutputStream(bos); + } + } + + driver.getRenderer().setOptions(options.getRendererOptions()); + driver.render(inputHandler); + } finally { + if (bos != null) { + bos.close(); + } + } } catch (FOPException e) { if (e.getMessage() == null) { System.err.println("Exception occured with a null error message"); @@ -81,15 +114,14 @@ } else { System.err.println("Turn on debugging for more information"); } - } catch (java.io.FileNotFoundException e) { + } catch (java.io.IOException e) { System.err.println("" + e.getMessage()); if (options != null && options.getLogger().isDebugEnabled()) { e.printStackTrace(); } else { System.err.println("Turn on debugging for more information"); } - } + } } - }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]