-/*
+/* $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."
+ * LICENSE file included with these sources.
*/
-
package org.apache.fop.apps;
//java
/**
* Options parses the commandline arguments
*/
-
public class CommandLineOptions {
/* input / output not set */
private static final int PRINT_OUTPUT = 4;
/* output: pcl file */
private static final int PCL_OUTPUT = 5;
+ /* output: postscript file */
+ private static final int PS_OUTPUT = 6;
/* output: text file */
- private static final int TXT_OUTPUT = 6;
-
- /* System buffers */
- private static final int BUFFER_FILE = 7;
-
- /* System buffers */
- private static final int AREA_OUTPUT = 8;
-
+ private static final int TXT_OUTPUT = 7;
+
+ /* System buffers */
+ private static final int BUFFER_FILE = 8;
+
+ /* System buffers */
+ private static final int AREA_OUTPUT = 9;
+
/* use debug mode*/
Boolean errorDump = new Boolean(false);
/* show configuration information */
Boolean dumpConfiguration = new Boolean(false);
/*suppress any progress information */
Boolean quiet = new Boolean(false);
- /* for area tree XML output, only down to block area level */
- Boolean suppressLowLevelAreas = new Boolean(false);
+ /* for area tree XML output, only down to block area level */
+ Boolean suppressLowLevelAreas = new Boolean(false);
/* name of user configuration file*/
File userConfigFile = null;
/* name of input fo file */
/* language for user information */
String language = null;
- private java.util.Hashtable rendererOptions;
-
- public CommandLineOptions (String [] args)
- throws FOPException, FileNotFoundException
- {
- boolean optionsParsed = true;
- rendererOptions = new java.util.Hashtable();
- try {
- optionsParsed = parseOptions(args);
- if (optionsParsed) {
- checkSettings ();
- if (errorDump != null && errorDump.booleanValue()) {
- debug();
- }
- }
- }
- catch (FOPException e) {
- printUsage();
- throw e;
- }
- catch (java.io.FileNotFoundException e) {
- printUsage();
- throw e;
- }
-
+ private java.util.Hashtable rendererOptions;
+
+ public CommandLineOptions (String [] args) throws FOPException,
+ FileNotFoundException {
+ boolean optionsParsed = true;
+ rendererOptions = new java.util.Hashtable();
+ try {
+ optionsParsed = parseOptions(args);
+ if (optionsParsed) {
+ checkSettings ();
+ if (errorDump != null && errorDump.booleanValue()) {
+ debug();
+ }
+ }
+ } catch (FOPException e) {
+ printUsage();
+ throw e;
+ }
+ catch (java.io.FileNotFoundException e) {
+ printUsage();
+ throw e;
+ }
+
}
-
/**
* parses the commandline arguments
* @return true if parse was successful and procesing 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
- {
+ private boolean parseOptions (String args[]) throws FOPException {
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-d") || args[i].equals("--full-error-dump")) {
errorDump = new Boolean(true);
} 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++;
}
} else if (args[i].equals("-s")) {
suppressLowLevelAreas = new Boolean(true);
- } else if (args[i].equals("-fo")) {
+ } else if (args[i].equals("-fo")) {
inputmode = FO_INPUT;
if ((i + 1 == args.length) ||
(args[i + 1].charAt(0) == '-')) {
i++;
}
} else if (args[i].equals("-awt")) {
- setOutputMode(AWT_OUTPUT);
- } else if (args[i].equals("-pdf")) {
- setOutputMode(PDF_OUTPUT);
- if ((i + 1 == args.length) ||
- (args[i + 1].charAt(0) == '-')) {
+ setOutputMode(AWT_OUTPUT);
+ } else if (args[i].equals("-pdf")) {
+ setOutputMode(PDF_OUTPUT);
+ if ((i + 1 == args.length) ||
+ (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the pdf output file");
} else {
outfile = new File (args[i + 1]);
i++;
}
} else if (args[i].equals("-mif")) {
- setOutputMode(MIF_OUTPUT);
+ setOutputMode(MIF_OUTPUT);
if ((i + 1 == args.length) ||
(args[i + 1].charAt(0) == '-')) {
- throw new FOPException("you must specify the mif output file");
+ throw new FOPException("you must specify the mif output file");
} else {
outfile = new File(args[i + 1]);
i++;
}
} else if (args[i].equals("-print")) {
- setOutputMode(PRINT_OUTPUT);
+ setOutputMode(PRINT_OUTPUT);
//show print help
if (i + 1 < args.length) {
if (args[i + 1].equals("help")) {
printUsagePrintOutput();
- return false;
- }
+ return false;
+ }
}
} else if (args[i].equals("-pcl")) {
- setOutputMode(PCL_OUTPUT);
+ setOutputMode(PCL_OUTPUT);
if ((i + 1 == args.length) ||
(args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the pdf output file");
outfile = new File (args[i + 1]);
i++;
}
+ } else if (args[i].equals("-ps")) {
+ setOutputMode(PS_OUTPUT);
+ if ((i + 1 == args.length) ||
+ (args[i + 1].charAt(0) == '-')) {
+ throw new FOPException("you must specify the PostScript output file");
+ } else {
+ outfile = new File (args[i + 1]);
+ i++;
+ }
} else if (args[i].equals("-txt")) {
- setOutputMode(TXT_OUTPUT);
+ setOutputMode(TXT_OUTPUT);
if ((i + 1 == args.length) ||
(args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the text output file");
outputmode = PDF_OUTPUT;
outfile = new File(args[i]);
} else {
- throw new FOPException("Don't know what to do with " + args[i]);
+ throw new FOPException(
+ "Don't know what to do with " + args[i]);
}
- } else if (args[i].equals("-buf")) {
+ } else if (args[i].equals("-buf")) {
if (buffermode == NOT_SET) {
buffermode = BUFFER_FILE;
} else {
i++;
}
} else if (args[i].equals("-at")) {
- setOutputMode(AREA_OUTPUT);
+ setOutputMode(AREA_OUTPUT);
if ((i + 1 == args.length) ||
(args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the area-tree output file");
}
} else {
printUsage();
- return false;
- }
+ return false;
+ }
}
- return true;
+ return true;
} //end parseOptions
- private void setOutputMode(int mode)
- throws FOPException
- {
- if (outputmode == NOT_SET) {
- outputmode = mode;
- } else {
- throw new FOPException("you can only set one output method");
- }
+ private void setOutputMode(int mode) throws FOPException {
+ if (outputmode == NOT_SET) {
+ outputmode = mode;
+ } else {
+ throw new FOPException("you can only set one output method");
+ }
}
-
/**
* checks whether all necessary information has been given in a consistent way
*/
- private void checkSettings ()
- throws FOPException, FileNotFoundException
- {
+ private void checkSettings () throws FOPException,
+ FileNotFoundException {
if (inputmode == NOT_SET) {
- throw new FOPException("No input file specified");
- }
+ throw new FOPException("No input file specified");
+ }
if (outputmode == NOT_SET) {
- throw new FOPException("No output file specified");
- }
+ throw new FOPException("No output file specified");
+ }
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");
- }
- if (xsltfile == null) {
- throw new FOPException("XSLT file must be specified for the tranform mode");
- }
+ if (xmlfile == null) {
+ throw new FOPException("XML file must be specified for the tranform mode");
+ }
+ if (xsltfile == null) {
+ throw new FOPException("XSLT file must be specified for the tranform mode");
+ }
//warning if fofile has been set in xslt mode
if (fofile != null) {
MessageHandler.errorln(
"WARNING: Can't use fo file with transform mode! Ignoring.\n" +
- "Your input is "+
- "\n xmlfile: " + xmlfile.getAbsolutePath() +
- "\nxsltfile: " + xsltfile.getAbsolutePath() +
- "\n fofile: " + fofile.getAbsolutePath());
+ "Your input is "+ "\n xmlfile: " +
+ xmlfile.getAbsolutePath() + "\nxsltfile: " +
+ xsltfile.getAbsolutePath() + "\n fofile: " +
+ fofile.getAbsolutePath());
}
if (!xmlfile.exists()) {
- throw new FileNotFoundException("xml file " +
- xmlfile.getAbsolutePath() + " not found ");
+ throw new FileNotFoundException("xml file " +
+ xmlfile.getAbsolutePath() + " not found ");
}
if (!xsltfile.exists()) {
throw new FileNotFoundException("xsl file " +
- xsltfile.getAbsolutePath() + " not found ");
+ xsltfile.getAbsolutePath() + " not found ");
}
} else if (inputmode == FO_INPUT) {
MessageHandler.errorln("xslt file: " + xsltfile.toString());
}
if (!fofile.exists()) {
- throw new FileNotFoundException("fo file " +
- fofile.getAbsolutePath() + " not found ");
+ throw new FileNotFoundException("fo file " +
+ fofile.getAbsolutePath() + " not found ");
}
}
}// end checkSettings
-
/**
* returns the chosen renderer, throws FOPException
*/
return Driver.RENDER_PRINT;
case PCL_OUTPUT:
return Driver.RENDER_PCL;
+ case PS_OUTPUT:
+ return Driver.RENDER_PS;
case TXT_OUTPUT:
return Driver.RENDER_TXT;
- case AREA_OUTPUT:
- rendererOptions.put("fineDetail", isCoarseAreaXml());
- return Driver.RENDER_XML;
+ case AREA_OUTPUT:
+ rendererOptions.put("fineDetail", isCoarseAreaXml());
+ return Driver.RENDER_XML;
default:
throw new FOPException("Invalid Renderer setting!");
}
}
/**
- *
- **/
+ *
+ **/
public InputHandler getInputHandler () {
switch (inputmode) {
case FO_INPUT:
}
}
- public java.util.Hashtable getRendererOptions() {
- return rendererOptions;
- }
-
- public Starter getStarter()
- throws FOPException
- {
+ public java.util.Hashtable getRendererOptions() {
+ return rendererOptions;
+ }
+
+ public Starter getStarter() throws FOPException {
switch (outputmode) {
- case PDF_OUTPUT:
- return new CommandLineStarter(this);
case AWT_OUTPUT:
try {
return((Starter) Class.forName(
new Class[]{CommandLineOptions.class}).
newInstance(new Object[]{this}));
} catch (Exception e) {
- if (e instanceof FOPException) {
- throw (FOPException)e;
- }
- throw new FOPException("AWTStarter could not be loaded.",e);
+ if (e instanceof FOPException) {
+ throw (FOPException) e;
+ }
+ throw new FOPException("AWTStarter could not be loaded.",e);
}
- case MIF_OUTPUT:
- return new CommandLineStarter(this);
case PRINT_OUTPUT:
try {
return((Starter) Class.forName(
new Class[]{CommandLineOptions.class}).
newInstance(new Object[]{this}));
} catch (Exception e) {
- if (e instanceof FOPException) {
- throw (FOPException)e;
- }
- throw new FOPException("PrintStarter could not be loaded.",e);
+ if (e instanceof FOPException) {
+ throw (FOPException) e;
+ }
+ throw new FOPException("PrintStarter could not be loaded.",e);
}
- case AREA_OUTPUT:
- return new CommandLineStarter(this);
default:
return new CommandLineStarter(this);
}
return language;
}
- public File getBufferFile() {
- return bufferFile;
- }
-
+ public File getBufferFile() {
+ return bufferFile;
+ }
+
public Boolean isQuiet() {
return quiet;
}
return errorDump;
}
- public Boolean isCoarseAreaXml() {
- return suppressLowLevelAreas;
- }
-
+ public Boolean isCoarseAreaXml() {
+ return suppressLowLevelAreas;
+ }
+
/**
- * return either the fofile or the xmlfile
- */
+ * return either the fofile or the xmlfile
+ */
public File getInputFile() {
switch (inputmode) {
case FO_INPUT:
}
}
-
/**
- * shows the commandline syntax including a summary of all available options and some examples
- */
+ * shows the commandline syntax including a summary of all available options and some examples
+ */
public static void printUsage() {
MessageHandler.errorln(
- "\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-pcl|-txt|-at|-print] <outfile>\n" +
+ "\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-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" +
+ " -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" +
" -awt input will be displayed on screen \n" +
" -mif outfile input will be rendered as mif 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" +
" -at outfile representation of area tree as XML (outfile req'd) \n" +
" -print input file will be rendered and sent to the printer \n" +
}
/**
- * shows the options for print output
- */
+ * shows the options for print output
+ */
public void printUsagePrintOutput() {
MessageHandler.errorln(
"USAGE: -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false] " +
/**
- * debug mode. outputs all commandline settings
- */
+ * debug mode. outputs all commandline settings
+ */
private void debug () {
System.out.print("Input mode: ");
switch (inputmode) {
MessageHandler.logln("pcl");
MessageHandler.logln("output file: " + outfile.toString());
break;
+ case PS_OUTPUT:
+ MessageHandler.logln("PostScript");
+ MessageHandler.logln("output file: " + outfile.toString());
+ break;
case TXT_OUTPUT:
MessageHandler.logln("txt");
MessageHandler.logln("output file: " + outfile.toString());
//debug: create class and output all settings
public static void main (String args[]) {
/*
- for (int i = 0; i < args.length; i++) {
- MessageHandler.logln(">"+args[i]+"<");
- }*/
- try {
- CommandLineOptions options = new CommandLineOptions (args);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
-
+ for (int i = 0; i < args.length; i++) {
+ MessageHandler.logln(">"+args[i]+"<");
+ }*/
+ try {
+ CommandLineOptions options = new CommandLineOptions (args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
//options.debug();
}
}
/* $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."
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
-
package org.apache.fop.apps;
// FOP
* Here is an example use of Driver which outputs PDF:
*
* <PRE>
- * Driver driver = new Driver(new InputSource (args[0]),
+ * Driver driver = new Driver(new InputSource (args[0]),
* new FileOutputStream(args[1]));
* driver.setRenderer(RENDER_PDF);
* driver.run();
* </PRE>
*/
public class Driver {
-
+
/** Render to PDF. OutputStream must be set */
public static final int RENDER_PDF = 1;
-
+
/** Render to a GUI window. No OutputStream neccessary */
public static final int RENDER_AWT = 2;
/** Render to XML. OutputStream must be set */
public static final int RENDER_XML = 4;
-
+
/** Render to PRINT. No OutputStream neccessary */
public static final int RENDER_PRINT = 5;
/** Render to PCL. OutputStream must be set */
public static final int RENDER_PCL = 6;
+ /** Render to Postscript. OutputStream must be set */
+ public static final int RENDER_PS = 7;
+
/** Render to Text. OutputStream must be set */
- public static final int RENDER_TXT = 7;
+ public static final int RENDER_TXT = 8;
/** the FO tree builder */
private FOTreeBuilder _treeBuilder;
/** the source of the FO file */
private InputSource _source;
-
+
/** the stream to use to output the results of the renderer */
private OutputStream _stream;
/** The XML parser to use when building the FO tree */
private XMLReader _reader;
-
+
/** If true, full error stacks are reported */
private boolean _errorDump = false;
/** create a new Driver */
public Driver() {
- _stream = null;
- _bufferManager = new BufferManager();
- _treeBuilder = new FOTreeBuilder();
- _treeBuilder.setBufferManager(_bufferManager);
- setupDefaultMappings();
+ _stream = null;
+ _bufferManager = new BufferManager();
+ _treeBuilder = new FOTreeBuilder();
+ _treeBuilder.setBufferManager(_bufferManager);
+ setupDefaultMappings();
}
public Driver(InputSource source, OutputStream stream) {
- this();
- _source = source;
- _stream = stream;
+ this();
+ _source = source;
+ _stream = stream;
}
/**
- * Resets the Driver so it can be reused. Property and element
+ * Resets the Driver so it can be reused. Property and element
* mappings are reset to defaults.
* The output stream is cleared. The renderer is cleared.
*/
- public synchronized void reset()
- {
- _areaTree = null;
- _treeBuilder.reset();
+ public synchronized void reset() {
+ _areaTree = null;
+ _treeBuilder.reset();
}
-
- public boolean hasData()
- {
- return(_treeBuilder.hasData());
+
+ public boolean hasData() {
+ return(_treeBuilder.hasData());
}
-
- /**
+
+ /**
* Set the error dump option
* @param dump if true, full stacks will be reported to the error log
*/
}
/**
- * Set the source for the FO document. This can be a normal SAX
+ * Set the source for the FO document. This can be a normal SAX
* InputSource, or an DocumentInputSource containing a DOM document.
* @see DocumentInputSource
*/
- public void setInputSource(InputSource source)
- {
- _source = source;
+ public void setInputSource(InputSource source) {
+ _source = source;
}
-
+
/**
* Sets the reader used when reading in the source. If not set,
* this defaults to a basic SAX parser.
*/
- public void setXMLReader(XMLReader reader)
- {
- _reader = reader;
+ public void setXMLReader(XMLReader reader) {
+ _reader = reader;
}
-
+
/**
* Sets all the element and property list mappings to their default values.
*
*/
- public void setupDefaultMappings()
- {
- addElementMapping("org.apache.fop.fo.StandardElementMapping");
- addPropertyList ("org.apache.fop.fo.StandardPropertyListMapping");
+ public void setupDefaultMappings() {
+ addElementMapping("org.apache.fop.fo.StandardElementMapping");
+ addPropertyList ("org.apache.fop.fo.StandardPropertyListMapping");
- addElementMapping("org.apache.fop.svg.SVGElementMapping");
- addPropertyList ("org.apache.fop.svg.SVGPropertyListMapping");
+ addElementMapping("org.apache.fop.svg.SVGElementMapping");
+ addPropertyList ("org.apache.fop.svg.SVGPropertyListMapping");
addElementMapping("org.apache.fop.extensions.ExtensionElementMapping");
- addPropertyList ("org.apache.fop.extensions.ExtensionPropertyListMapping");
+ addPropertyList ("org.apache.fop.extensions.ExtensionPropertyListMapping");
}
/**
- * Set the rendering type to use. Must be one of
+ * Set the rendering type to use. Must be one of
* <ul>
* <li>RENDER_PDF
* <li>RENDER_AWT
* <li>RENDER_MIF
* <li>RENDER_XML
* <li>RENDER_PCL
+ * <li>RENDER_PS
* <li>RENDER_TXT
* </ul>
* @param renderer the type of renderer to use
*/
- public void setRenderer(int renderer)
- throws IllegalArgumentException
- {
- switch (renderer) {
- case RENDER_PDF:
- setRenderer(new org.apache.fop.render.pdf.PDFRenderer());
- break;
- case RENDER_AWT:
- throw new IllegalArgumentException("Use renderer form of setRenderer() for AWT");
- case RENDER_PRINT:
- throw new IllegalArgumentException("Use renderer form of setRenderer() for PRINT");
- case RENDER_PCL:
- setRenderer(new org.apache.fop.render.pcl.PCLRenderer());
- break;
- case RENDER_TXT:
- setRenderer(new org.apache.fop.render.txt.TXTRenderer());
- break;
- case RENDER_MIF:
- setRenderer(new org.apache.fop.render.mif.MIFRenderer());
- break;
- case RENDER_XML:
- setRenderer(new org.apache.fop.render.xml.XMLRenderer());
- break;
- default:
- throw new IllegalArgumentException("Unknown renderer type");
- }
-
+ public void setRenderer(int renderer) throws IllegalArgumentException {
+ switch (renderer) {
+ case RENDER_PDF:
+ setRenderer(new org.apache.fop.render.pdf.PDFRenderer());
+ break;
+ case RENDER_AWT:
+ throw new IllegalArgumentException("Use renderer form of setRenderer() for AWT");
+ case RENDER_PRINT:
+ throw new IllegalArgumentException("Use renderer form of setRenderer() for PRINT");
+ case RENDER_PCL:
+ setRenderer(new org.apache.fop.render.pcl.PCLRenderer());
+ break;
+ case RENDER_PS:
+ setRenderer(new org.apache.fop.render.ps.PSRenderer());
+ break;
+ case RENDER_TXT:
+ setRenderer(new org.apache.fop.render.txt.TXTRenderer());
+ break;
+ case RENDER_MIF:
+ setRenderer(new org.apache.fop.render.mif.MIFRenderer());
+ break;
+ case RENDER_XML:
+ setRenderer(new org.apache.fop.render.xml.XMLRenderer());
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown renderer type");
+ }
+
}
-
- /**
- * Set the Renderer to use
+
+ /**
+ * Set the Renderer to use
* @param renderer the renderer instance to use
*/
public void setRenderer(Renderer renderer) {
* @see #setRenderer(int)
* @see #setRenderer(Renderer)
*/
- public void setRenderer(String rendererClassName, String version)
- {
- setRenderer(rendererClassName);
+ public void setRenderer(String rendererClassName, String version) {
+ setRenderer(rendererClassName);
}
-
+
/**
* Set the class name of the Renderer to use as well as the
* producer string for those renderers that can make use of it.
- * @param rendererClassName classname of the renderer to use such as
+ * @param rendererClassName classname of the renderer to use such as
* "org.apache.fop.render.pdf.PDFRenderer"
* @exception IllegalArgumentException if the classname was invalid.
* @see #setRenderer(int)
*/
- public void setRenderer(String rendererClassName)
- throws IllegalArgumentException
- {
- try {
- _renderer = (Renderer) Class.forName(rendererClassName).newInstance();
- _renderer.setProducer(Version.getVersion());
- }
- catch (ClassNotFoundException e) {
- throw new IllegalArgumentException("Could not find " +
- rendererClassName);
+ public void setRenderer(String rendererClassName)
+ throws IllegalArgumentException {
+ try {
+ _renderer = (Renderer) Class.forName(
+ rendererClassName).newInstance();
+ _renderer.setProducer(Version.getVersion());
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException("Could not find " +
+ rendererClassName);
}
catch (InstantiationException e) {
- throw new IllegalArgumentException("Could not instantiate " +
- rendererClassName);
+ throw new IllegalArgumentException(
+ "Could not instantiate " + rendererClassName);
}
catch (IllegalAccessException e) {
- throw new IllegalArgumentException("Could not access " + rendererClassName);
+ throw new IllegalArgumentException("Could not access " +
+ rendererClassName);
}
catch (ClassCastException e) {
throw new IllegalArgumentException(rendererClassName + " is not a renderer");
* @param mapping the element mappingto add
*/
public void addElementMapping(ElementMapping mapping) {
- mapping.addToBuilder(_treeBuilder);
+ mapping.addToBuilder(_treeBuilder);
}
/**
* add the element mapping with the given class name
*/
- public void addElementMapping(String mappingClassName)
- throws IllegalArgumentException
- {
- try {
+ public void addElementMapping(String mappingClassName)
+ throws IllegalArgumentException {
+ try {
ElementMapping mapping = (ElementMapping) Class.forName(
- mappingClassName).newInstance();
- addElementMapping(mapping);
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException("Could not find " + mappingClassName);
- }
+ mappingClassName).newInstance();
+ addElementMapping(mapping);
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException("Could not find " +
+ mappingClassName);
+ }
catch (InstantiationException e) {
- throw new IllegalArgumentException("Could not instantiate " +
- mappingClassName);
- }
+ throw new IllegalArgumentException(
+ "Could not instantiate " + mappingClassName);
+ }
catch (IllegalAccessException e) {
- throw new IllegalArgumentException("Could not access " + mappingClassName);
- }
+ throw new IllegalArgumentException("Could not access " +
+ mappingClassName);
+ }
catch (ClassCastException e) {
throw new IllegalArgumentException(mappingClassName + " is not an ElementMapping");
- }
+ }
}
/**
* Add the PropertyListMapping.
*/
- public void addPropertyList(PropertyListMapping mapping)
- {
- mapping.addToBuilder(_treeBuilder);
+ public void addPropertyList(PropertyListMapping mapping) {
+ mapping.addToBuilder(_treeBuilder);
}
-
/**
* Add the PropertyListMapping with the given class name.
*/
- public void addPropertyList(String listClassName)
- throws IllegalArgumentException
- {
- try {
- PropertyListMapping mapping = (PropertyListMapping) Class.forName(
- listClassName).newInstance();
- addPropertyList(mapping);
-
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException("Could not find " + listClassName);
- }
+ public void addPropertyList(String listClassName)
+ throws IllegalArgumentException {
+ try {
+ PropertyListMapping mapping =
+ (PropertyListMapping) Class.forName(
+ listClassName).newInstance();
+ addPropertyList(mapping);
+
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException("Could not find " +
+ listClassName);
+ }
catch (InstantiationException e) {
- throw new IllegalArgumentException("Could not instantiate " +
- listClassName);
- }
+ throw new IllegalArgumentException(
+ "Could not instantiate " + listClassName);
+ }
catch (IllegalAccessException e) {
- throw new IllegalArgumentException("Could not access " + listClassName);
- }
+ throw new IllegalArgumentException("Could not access " +
+ listClassName);
+ }
catch (ClassCastException e) {
throw new IllegalArgumentException(listClassName + " is not an ElementMapping");
- }
+ }
}
/**
* SAX InputSource
*/
public synchronized void buildFOTree(XMLReader parser,
- InputSource source)
- throws FOPException
- {
+ InputSource source)
+ throws FOPException {
parser.setContentHandler(_treeBuilder);
try {
/**
* Build the formatting object tree using the given DOM Document
*/
- public synchronized void buildFOTree(Document document)
- throws FOPException
- {
- try {
- DocumentInputSource source = new DocumentInputSource(document);
- DocumentReader reader = new DocumentReader();
- reader.setContentHandler(_treeBuilder);
- reader.parse(source);
- } catch (SAXException e) {
+ public synchronized void buildFOTree(Document document)
+ throws FOPException {
+ try {
+ DocumentInputSource source = new DocumentInputSource(document);
+ DocumentReader reader = new DocumentReader();
+ reader.setContentHandler(_treeBuilder);
+ reader.parse(source);
+ } catch (SAXException e) {
throw new FOPException(e);
- } catch (IOException e) {
+ }
+ catch (IOException e) {
throw new FOPException(e);
- }
-
- }
+ }
+
+ }
/**
* Dumps an error
if (((SAXException) e).getException() != null) {
((SAXException) e).getException().printStackTrace();
}
- }
- else if (e instanceof FOPException) {
+ } else if (e instanceof FOPException) {
e.printStackTrace();
if (((FOPException) e).getException() != null) {
((FOPException) e).getException().printStackTrace();
}
- }
- else {
+ } else {
e.printStackTrace();
}
}
}
/* Set up the system buffers */
-
+
public void setBufferFile(File bufferFile) {
- this._bufferManager.addBufferFile(bufferFile);
+ this._bufferManager.addBufferFile(bufferFile);
}
-
+
/**
* format the formatting object tree into an area tree
*/
- public synchronized void format() throws FOPException {
+ public synchronized void format()
+ throws FOPException {
FontInfo fontInfo = new FontInfo();
_renderer.setupFontInfo(fontInfo);
/**
* render the area tree to the output form
*/
- public synchronized void render() throws IOException, FOPException {
+ public synchronized void render()
+ throws IOException, FOPException {
_renderer.render(_areaTree, _stream);
}
* inputsource and outputstream
*/
public synchronized void run()
- throws IOException, FOPException
- {
- if (_renderer == null) {
- setRenderer(RENDER_PDF);
- }
- if (_source == null) {
- throw new FOPException("InputSource is not set.");
- }
- if (_reader == null) {
- if (!(_source instanceof DocumentInputSource)) {
- _reader = ConfigurationReader.createParser();
- }
- }
- if (_source instanceof DocumentInputSource) {
- buildFOTree(((DocumentInputSource)_source).getDocument());
- }
- else {
- buildFOTree(_reader, _source);
- }
- format();
- render();
+ throws IOException, FOPException {
+ if (_renderer == null) {
+ setRenderer(RENDER_PDF);
+ }
+ if (_source == null) {
+ throw new FOPException("InputSource is not set.");
+ }
+ if (_reader == null) {
+ if (!(_source instanceof DocumentInputSource)) {
+ _reader = ConfigurationReader.createParser();
+ }
+ }
+ if (_source instanceof DocumentInputSource) {
+ buildFOTree(((DocumentInputSource)_source).getDocument());
+ } else {
+ buildFOTree(_reader, _source);
+ }
+ format();
+ render();
}
-
+
}