gmazza 2004/07/23 22:47:45
Modified: examples/embedding/java/embedding ExampleDOM2PDF.java
ExampleFO2PDF.java ExampleFO2PDFUsingSAXParser.java
ExampleObj2PDF.java ExampleXML2PDF.java
src/java/org/apache/fop/apps CommandLineOptions.java
FOFileHandler.java Fop.java InputHandler.java
XSLTInputHandler.java
src/java/org/apache/fop/fo Constants.java
src/java/org/apache/fop/render/awt/viewer PreviewDialog.java
src/java/org/apache/fop/servlet FopPrintServlet.java
FopServlet.java
src/java/org/apache/fop/tools TestConverter.java
src/java/org/apache/fop/tools/anttasks Fop.java
test/java/org/apache/fop BasicDriverTestCase.java
GenericFOPTestCase.java
Removed: src/java/org/apache/fop/apps Driver.java
Log:
Combined the apps.Driver class into apps.Fop. (195 LOC total.) Primary
benefit is to make Fop self-documenting in external code, also none of the
API ideas called for retention of the Driver class (even if there were
different ideas for its replacement).
Let's try this for a few weeks, if it confuses people too much (or when
the API starts to grow again) we can bring back Driver, possibly under
a different name, apps.FopProcess, perhaps.
See also:
http://marc.theaimsgroup.com/?l=fop-dev&m=108947697611032&w=2
http://marc.theaimsgroup.com/?l=fop-dev&m=108966015504506&w=2
http://marc.theaimsgroup.com/?l=fop-dev&m=108942673103344&w=2
http://marc.theaimsgroup.com/?l=fop-dev&m=108958756030147&w=2
Revision Changes Path
1.12 +6 -6 xml-fop/examples/embedding/java/embedding/ExampleDOM2PDF.java
Index: ExampleDOM2PDF.java
===================================================================
RCS file: /home/cvs/xml-fop/examples/embedding/java/embedding/ExampleDOM2PDF.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ExampleDOM2PDF.java 19 Jul 2004 22:46:14 -0000 1.11
+++ ExampleDOM2PDF.java 24 Jul 2004 05:47:44 -0000 1.12
@@ -40,7 +40,7 @@
import org.w3c.dom.Text;
// FOP
-import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.Fop;
/**
@@ -61,15 +61,15 @@
*/
public void convertDOM2PDF(Document xslfoDoc, File pdf) {
try {
- // Construct driver with desired output format
- Driver driver = new Driver(Driver.RENDER_PDF);
+ // Construct fop with desired output format
+ Fop fop = new Fop(Fop.RENDER_PDF);
// Setup output
OutputStream out = new java.io.FileOutputStream(pdf);
out = new java.io.BufferedOutputStream(out);
try {
- driver.setOutputStream(out);
+ fop.setOutputStream(out);
// Setup Identity Transformer
TransformerFactory factory = TransformerFactory.newInstance();
@@ -79,7 +79,7 @@
Source src = new DOMSource(xslfoDoc);
// Resulting SAX events (the generated FO) must be piped through to
FOP
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
1.15 +5 -5 xml-fop/examples/embedding/java/embedding/ExampleFO2PDF.java
Index: ExampleFO2PDF.java
===================================================================
RCS file: /home/cvs/xml-fop/examples/embedding/java/embedding/ExampleFO2PDF.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ExampleFO2PDF.java 19 Jul 2004 22:46:14 -0000 1.14
+++ ExampleFO2PDF.java 24 Jul 2004 05:47:44 -0000 1.15
@@ -35,7 +35,7 @@
// FOP
-import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
/**
@@ -55,14 +55,14 @@
OutputStream out = null;
try {
- // Construct driver with desired output format
- Driver driver = new Driver(Driver.RENDER_PDF);
+ // Construct fop with desired output format
+ Fop fop = new Fop(Fop.RENDER_PDF);
// Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams).
out = new FileOutputStream(pdf);
out = new BufferedOutputStream(out);
- driver.setOutputStream(out);
+ fop.setOutputStream(out);
// Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
@@ -72,7 +72,7 @@
Source src = new StreamSource(fo);
// Resulting SAX events (the generated FO) must be piped through to FOP
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
1.2 +6 -6
xml-fop/examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java
Index: ExampleFO2PDFUsingSAXParser.java
===================================================================
RCS file:
/home/cvs/xml-fop/examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExampleFO2PDFUsingSAXParser.java 19 Jul 2004 22:46:14 -0000 1.1
+++ ExampleFO2PDFUsingSAXParser.java 24 Jul 2004 05:47:44 -0000 1.2
@@ -36,7 +36,7 @@
import org.xml.sax.SAXException;
// FOP
-import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
/**
@@ -63,14 +63,14 @@
OutputStream out = null;
try {
- // Construct driver and setup output format
- Driver driver = new Driver(Driver.RENDER_PDF);
+ // Construct fop and setup output format
+ Fop fop = new Fop(Fop.RENDER_PDF);
// Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams).
out = new FileOutputStream(pdf);
out = new BufferedOutputStream(out);
- driver.setOutputStream(out);
+ fop.setOutputStream(out);
// Setup SAX parser
// throws FactoryConfigurationError
@@ -81,7 +81,7 @@
// Obtain FOP's DefaultHandler
// throws FOPException
- DefaultHandler dh = driver.getDefaultHandler();
+ DefaultHandler dh = fop.getDefaultHandler();
// Start parsing and FOP processing
// throws SAXException, IOException
1.11 +5 -5 xml-fop/examples/embedding/java/embedding/ExampleObj2PDF.java
Index: ExampleObj2PDF.java
===================================================================
RCS file: /home/cvs/xml-fop/examples/embedding/java/embedding/ExampleObj2PDF.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ExampleObj2PDF.java 19 Jul 2004 22:46:14 -0000 1.10
+++ ExampleObj2PDF.java 24 Jul 2004 05:47:44 -0000 1.11
@@ -33,7 +33,7 @@
import javax.xml.transform.sax.SAXResult;
// FOP
-import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
import embedding.model.ProjectTeam;
@@ -55,14 +55,14 @@
public void convertProjectTeam2PDF(ProjectTeam team, File xslt, File pdf)
throws IOException, FOPException, TransformerException {
- // Construct driver with desired output format
- Driver driver = new Driver(Driver.RENDER_PDF);
+ // Construct fop with desired output format
+ Fop fop = new Fop(Fop.RENDER_PDF);
// Setup output
OutputStream out = new java.io.FileOutputStream(pdf);
out = new java.io.BufferedOutputStream(out);
try {
- driver.setOutputStream(out);
+ fop.setOutputStream(out);
// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
@@ -72,7 +72,7 @@
Source src = team.getSourceForProjectTeam();
// Resulting SAX events (the generated FO) must be piped through to FOP
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
1.13 +5 -5 xml-fop/examples/embedding/java/embedding/ExampleXML2PDF.java
Index: ExampleXML2PDF.java
===================================================================
RCS file: /home/cvs/xml-fop/examples/embedding/java/embedding/ExampleXML2PDF.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ExampleXML2PDF.java 19 Jul 2004 22:46:14 -0000 1.12
+++ ExampleXML2PDF.java 24 Jul 2004 05:47:44 -0000 1.13
@@ -32,7 +32,7 @@
import javax.xml.transform.sax.SAXResult;
//FOP
-import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
/**
@@ -66,15 +66,15 @@
System.out.println();
System.out.println("Transforming...");
- // Construct driver with desired output format
- Driver driver = new Driver(Driver.RENDER_PDF);
+ // Construct fop with desired output format
+ Fop fop = new Fop(Fop.RENDER_PDF);
// Setup output
OutputStream out = new java.io.FileOutputStream(pdffile);
out = new java.io.BufferedOutputStream(out);
try {
- driver.setOutputStream(out);
+ fop.setOutputStream(out);
// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
@@ -87,7 +87,7 @@
Source src = new StreamSource(xmlfile);
// Resulting SAX events (the generated FO) must be piped through to
FOP
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
1.26 +6 -14 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.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- CommandLineOptions.java 20 Jul 2004 21:28:50 -0000 1.25
+++ CommandLineOptions.java 24 Jul 2004 05:47:44 -0000 1.26
@@ -453,31 +453,23 @@
* @return the type chosen renderer
* @throws FOPException for invalid output modes
*/
- public int getRenderer() throws FOPException {
+ protected int getRenderer() throws FOPException {
switch (outputmode) {
- case NOT_SET:
- throw new FOPException("Renderer has not been set!");
case RENDER_PDF:
- return Driver.RENDER_PDF;
case RENDER_AWT:
- return Driver.RENDER_AWT;
case RENDER_MIF:
- return Driver.RENDER_MIF;
case RENDER_PRINT:
- return Driver.RENDER_PRINT;
case RENDER_PCL:
- return Driver.RENDER_PCL;
case RENDER_PS:
- return Driver.RENDER_PS;
case RENDER_TXT:
- return Driver.RENDER_TXT;
case RENDER_SVG:
- return Driver.RENDER_SVG;
+ case RENDER_RTF:
+ return outputmode;
case RENDER_XML:
foUserAgent.getRendererOptions().put("fineDetail", isCoarseAreaXml());
- return Driver.RENDER_XML;
- case RENDER_RTF:
- return Driver.RENDER_RTF;
+ return RENDER_XML;
+ case NOT_SET:
+ throw new FOPException("Renderer has not been set!");
default:
throw new FOPException("Invalid Renderer setting!");
}
1.7 +6 -6 xml-fop/src/java/org/apache/fop/apps/FOFileHandler.java
Index: FOFileHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/FOFileHandler.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FOFileHandler.java 20 Jul 2004 21:28:50 -0000 1.6
+++ FOFileHandler.java 24 Jul 2004 05:47:44 -0000 1.7
@@ -76,13 +76,13 @@
}
/**
- * @see org.apache.fop.apps.InputHandler#render(Driver)
+ * @see org.apache.fop.apps.InputHandler#render(Fop)
*/
- public void render(Driver driver) throws FOPException {
+ public void render(Fop fop) throws FOPException {
// temporary until baseURL removed from inputHandler objects
- if (driver.getUserAgent().getBaseURL() == null) {
- driver.getUserAgent().setBaseURL(getBaseURL());
+ if (fop.getUserAgent().getBaseURL() == null) {
+ fop.getUserAgent().setBaseURL(getBaseURL());
}
try {
@@ -94,7 +94,7 @@
Source src = new SAXSource(getInputSource());
// Resulting SAX events (the generated FO) must be piped through to FOP
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
1.19 +105 -9 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.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Fop.java 20 Jul 2004 03:39:24 -0000 1.18
+++ Fop.java 24 Jul 2004 05:47:45 -0000 1.19
@@ -21,15 +21,112 @@
// Java
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
+import java.io.OutputStream;
-// FOP
-import org.apache.fop.render.awt.AWTRenderer;
+// XML
+import org.xml.sax.helpers.DefaultHandler;
+// FOP
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FOTreeBuilder;
/**
- * The main application class for the FOP command line interface (CLI).
+ * Primary class that activates the FOP process for both command line
+ * and embedded usage.
+ * <P>
+ * JAXP is the standard method of embedding FOP in Java programs.
+ * Please check our embedding page (http://xml.apache.org/fop/embedding.html)
+ * for samples (these are also available within the distribution in
+ * FOP_DIR\examples\embedding)
+ * <P>
+ * Methods within FOUserAgent are available to customize portions of the
+ * process. For example, a specific Renderer object can be specified,
+ * also ElementMappings which determine elements in the FO that can be
+ * processed) can be added.
*/
-public class Fop {
+public class Fop implements Constants {
+
+ // desired output type: RENDER_PDF, RENDER_PS, etc.
+ private int renderType = NOT_SET;
+
+ // output stream to send results to
+ private OutputStream stream = null;
+
+ // FOUserAgent object to set processing options
+ private FOUserAgent foUserAgent = null;
+
+ /**
+ * Constructor for use with already-created FOUserAgents
+ * @param renderType the type of renderer to use. Must be one of
+ * <ul>
+ * <li>Fop.RENDER_PDF</li>
+ * <li>Fop.RENDER_AWT</li>
+ * <li>Fop.RENDER_PRINT</li>
+ * <li>Fop.RENDER_MIF</li>
+ * <li>Fop.RENDER_XML</li>
+ * <li>Fop.RENDER_PCL</li>
+ * <li>Fop.RENDER_PS</li>
+ * <li>Fop.RENDER_TXT</li>
+ * <li>Fop.RENDER_SVG</li>
+ * <li>Fop.RENDER_RTF</li>
+ * </ul>
+ * @param ua FOUserAgent object
+ * @throws IllegalArgumentException if an unsupported renderer type was
requested.
+ */
+ public Fop(int renderType, FOUserAgent ua) {
+ if (renderType < Constants.RENDER_MIN_CONST
+ || renderType > Constants.RENDER_MAX_CONST) {
+ throw new IllegalArgumentException(
+ "Invalid render type #" + renderType);
+ }
+
+ this.renderType = renderType;
+
+ foUserAgent = ua;
+ if (foUserAgent == null) {
+ foUserAgent = new FOUserAgent();
+ }
+ }
+
+ /**
+ * Constructor that creates a default FOUserAgent
+ * @see org.apache.fop.apps.Fop#(int, FOUserAgent)
+ */
+ public Fop(int renderType) {
+ this(renderType, new FOUserAgent());
+ }
+
+ /**
+ * Get the FOUserAgent instance for this process
+ * @return the user agent
+ */
+ public FOUserAgent getUserAgent() {
+ return foUserAgent;
+ }
+
+ /**
+ * Set the OutputStream to use to output the result of the Render
+ * (if applicable)
+ * @param stream the stream to output the result of rendering to
+ */
+ public void setOutputStream(OutputStream stream) {
+ this.stream = stream;
+ }
+
+ /**
+ * Returns a DefaultHandler object used to generate the document.
+ * Note this object implements the ContentHandler interface.
+ * For processing with a Transformer object, this DefaultHandler object
+ * can be used in the SAXResult constructor.
+ * Alternatively, for processing with a SAXParser, this object can be
+ * used as the DefaultHandler argument to its parse() methods.
+ *
+ * @return a SAX DefaultHandler for handling the SAX events.
+ * @throws FOPException if setting up the DefaultHandler fails
+ */
+ public DefaultHandler getDefaultHandler() throws FOPException {
+ return new FOTreeBuilder(renderType, foUserAgent, stream);
+ }
/**
* The main routine for the command line interface
@@ -44,15 +141,15 @@
options = new CommandLineOptions(args);
foUserAgent = options.getFOUserAgent();
- Driver driver = new Driver(options.getRenderer(), foUserAgent);
+ Fop fop = new Fop(options.getRenderer(), foUserAgent);
try {
if (options.getOutputFile() != null) {
bos = new BufferedOutputStream(new FileOutputStream(
options.getOutputFile()));
- driver.setOutputStream(bos);
+ fop.setOutputStream(bos);
}
- foUserAgent.getInputHandler().render(driver);
+ foUserAgent.getInputHandler().render(fop);
} finally {
if (bos != null) {
bos.close();
@@ -96,4 +193,3 @@
return "1.0dev";
}
}
-
1.13 +4 -4 xml-fop/src/java/org/apache/fop/apps/InputHandler.java
Index: InputHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/InputHandler.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- InputHandler.java 20 Jul 2004 03:39:24 -0000 1.12
+++ InputHandler.java 24 Jul 2004 05:47:45 -0000 1.13
@@ -44,11 +44,11 @@
}
/**
- * Generate a document, given an initialized Driver object
- * @param driver -- Driver object
+ * Generate a document, given an initialized Fop object
+ * @param fop -- Fop object
* @throws FOPException in case of an error during processing
*/
- public void render(Driver driver) throws FOPException {}
+ public void render(Fop fop) throws FOPException {}
/**
* Creates an InputSource from a URL.
1.16 +5 -5 xml-fop/src/java/org/apache/fop/apps/XSLTInputHandler.java
Index: XSLTInputHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/XSLTInputHandler.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- XSLTInputHandler.java 20 Jul 2004 03:39:24 -0000 1.15
+++ XSLTInputHandler.java 24 Jul 2004 05:47:45 -0000 1.16
@@ -105,14 +105,14 @@
}
/**
- * @see org.apache.fop.apps.InputHandler#render(Driver)
+ * @see org.apache.fop.apps.InputHandler#render(Fop)
*/
- public void render(Driver driver)
+ public void render(Fop fop)
throws FOPException {
// temporary until baseURL removed from inputHandler objects
- if (driver.getUserAgent().getBaseURL() == null) {
- driver.getUserAgent().setBaseURL(getBaseURL());
+ if (fop.getUserAgent().getBaseURL() == null) {
+ fop.getUserAgent().setBaseURL(getBaseURL());
}
try {
@@ -129,7 +129,7 @@
}
// Resulting SAX events (the generated FO) must be piped through to FOP
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(xmlSource, res);
1.9 +2 -2 xml-fop/src/java/org/apache/fop/fo/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/Constants.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Constants.java 27 Jun 2004 13:29:32 -0000 1.8
+++ Constants.java 24 Jul 2004 05:47:45 -0000 1.9
@@ -22,7 +22,7 @@
public interface Constants {
/* These constants are used by apps.CommandLineOptions and
- apps.Driver to describe the input (either .FO or .XML/.XSL)
+ apps.Fop to describe the input (either .FO or .XML/.XSL)
and desired output (PDF, PS, AWT, etc.) of the document */
/** render constants for bounds checking */
1.7 +7 -7
xml-fop/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
Index: PreviewDialog.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- PreviewDialog.java 20 Jul 2004 03:39:24 -0000 1.6
+++ PreviewDialog.java 24 Jul 2004 05:47:45 -0000 1.7
@@ -48,7 +48,7 @@
import java.awt.print.PrinterException;
//FOP
-import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
@@ -69,8 +69,8 @@
protected AWTRenderer renderer;
/** The FOUserAgent associated with this window */
protected FOUserAgent foUserAgent;
- /** The Driver used for refreshing/reloading the view */
- protected Driver driver;
+ /** The Fop object used for refreshing/reloading the view */
+ protected Fop fop;
private int currentPage = 0;
private int pageCount = 0;
@@ -384,8 +384,8 @@
*/
private class Reloader extends Thread {
public void run() {
- if (driver == null) {
- driver = new Driver(Constants.RENDER_AWT, foUserAgent);
+ if (fop == null) {
+ fop = new Fop(Constants.RENDER_AWT, foUserAgent);
}
pageLabel.setIcon(null);
@@ -394,7 +394,7 @@
try {
setStatus(translator.getString("Status.Build.FO.tree"));
- foUserAgent.getInputHandler().render(driver);
+ foUserAgent.getInputHandler().render(fop);
setStatus(translator.getString("Status.Show"));
} catch (FOPException e) {
reportException(e);
1.18 +5 -5 xml-fop/src/java/org/apache/fop/servlet/FopPrintServlet.java
Index: FopPrintServlet.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/servlet/FopPrintServlet.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- FopPrintServlet.java 19 Jul 2004 22:46:14 -0000 1.17
+++ FopPrintServlet.java 24 Jul 2004 05:47:45 -0000 1.18
@@ -37,7 +37,7 @@
// XML
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.commons.logging.Log;
-import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.Fop;
import org.xml.sax.InputSource;
//Java
@@ -138,7 +138,7 @@
public void renderFO(InputStream foFile,
HttpServletResponse response) throws ServletException {
try {
- Driver driver = new Driver(Driver.RENDER_PRINT);
+ Fop fop = new Fop(Fop.RENDER_PRINT);
// Setup JAXP
TransformerFactory factory = TransformerFactory.newInstance();
@@ -148,7 +148,7 @@
Source src = new StreamSource(foFile);
// Resulting SAX events (the generated FO) must be piped through to FOP
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
@@ -169,7 +169,7 @@
public void renderXML(File xmlfile, File xsltfile,
HttpServletResponse response) throws ServletException {
try {
- Driver driver = new Driver(Driver.RENDER_PRINT);
+ Fop fop = new Fop(Fop.RENDER_PRINT);
// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
@@ -179,7 +179,7 @@
Source src = new StreamSource(xmlfile);
// Resulting SAX events (the generated FO) must be piped through to FOP
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
1.11 +4 -4 xml-fop/src/java/org/apache/fop/servlet/FopServlet.java
Index: FopServlet.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/servlet/FopServlet.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- FopServlet.java 19 Jul 2004 22:46:14 -0000 1.10
+++ FopServlet.java 24 Jul 2004 05:47:45 -0000 1.11
@@ -38,7 +38,7 @@
import org.apache.commons.logging.Log;
//FOP
-import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
/**
@@ -201,14 +201,14 @@
throws FOPException, TransformerException {
//Setup FOP
- Driver driver = new Driver(Driver.RENDER_PDF);
+ Fop fop = new Fop(Fop.RENDER_PDF);
//Setup output
ByteArrayOutputStream out = new ByteArrayOutputStream();
- driver.setOutputStream(out);
+ fop.setOutputStream(out);
//Make sure the XSL transformation's result is piped through to FOP
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
//Start the transformation and rendering process
transformer.transform(src, res);
1.19 +7 -9 xml-fop/src/java/org/apache/fop/tools/TestConverter.java
Index: TestConverter.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/tools/TestConverter.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- TestConverter.java 20 Jul 2004 03:39:24 -0000 1.18
+++ TestConverter.java 24 Jul 2004 05:47:45 -0000 1.19
@@ -26,7 +26,7 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOFileHandler;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.InputHandler;
@@ -49,13 +49,11 @@
* versions of FOP or the pdf can be view for manual checking and
* pdf rendering.
*
- * Modified by Mark Lillywhite [EMAIL PROTECTED] to use the new Driver
- * interface.
*/
public class TestConverter {
private boolean failOnly = false;
- private int renderType = Driver.RENDER_XML;
+ private int renderType = Fop.RENDER_XML;
private File destdir;
private File compare = null;
private String baseDir = "./";
@@ -106,7 +104,7 @@
if (args[count].equals("-failOnly")) {
tc.setFailOnly(true);
} else if (args[count].equals("-pdf")) {
- tc.setRenderType(Driver.RENDER_PDF);
+ tc.setRenderType(Fop.RENDER_PDF);
} else if (args[count].equals("-d")) {
tc.setDebug(true);
} else if (args[count].equals("-b")) {
@@ -307,7 +305,7 @@
FOUserAgent userAgent = new FOUserAgent();
userAgent.setBaseURL(baseURL);
- Driver driver = new Driver(renderType, userAgent);
+ Fop fop = new Fop(renderType, userAgent);
userAgent.getRendererOptions().put("fineDetail", new Boolean(false));
userAgent.getRendererOptions().put("consistentOutput", new
Boolean(true));
@@ -318,15 +316,15 @@
outname = outname.substring(0, outname.length() - 4);
}
File outputFile = new File(destdir, // assuming only RENDER_PDF or
RENDER_XML here
- outname + ((renderType==Driver.RENDER_PDF) ?
".pdf" : ".at.xml"));
+ outname + ((renderType==Fop.RENDER_PDF) ? ".pdf" :
".at.xml"));
outputFile.getParentFile().mkdirs();
OutputStream outStream = new java.io.BufferedOutputStream(
new java.io.FileOutputStream(outputFile));
- driver.setOutputStream(outStream);
+ fop.setOutputStream(outStream);
logger.debug("ddir:" + destdir + " on:" +
outputFile.getName());
- inputHandler.render(driver);
+ inputHandler.render(fop);
outStream.close();
// check difference
1.18 +19 -18 xml-fop/src/java/org/apache/fop/tools/anttasks/Fop.java
Index: Fop.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/tools/anttasks/Fop.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Fop.java 20 Jul 2004 03:39:24 -0000 1.17
+++ Fop.java 24 Jul 2004 05:47:45 -0000 1.18
@@ -36,7 +36,7 @@
// FOP
import org.apache.fop.apps.InputHandler;
import org.apache.fop.apps.FOFileHandler;
-import org.apache.fop.apps.Driver;
+import org.apache.fop.fo.Constants;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
@@ -334,27 +334,27 @@
if ((format == null)
|| format.equalsIgnoreCase("application/pdf")
|| format.equalsIgnoreCase("pdf")) {
- return Driver.RENDER_PDF;
+ return Constants.RENDER_PDF;
} else if (format.equalsIgnoreCase("application/postscript")
|| format.equalsIgnoreCase("ps")) {
- return Driver.RENDER_PS;
+ return Constants.RENDER_PS;
} else if (format.equalsIgnoreCase("application/vnd.mif")
|| format.equalsIgnoreCase("mif")) {
- return Driver.RENDER_MIF;
+ return Constants.RENDER_MIF;
} else if (format.equalsIgnoreCase("application/msword")
|| format.equalsIgnoreCase("application/rtf")
|| format.equalsIgnoreCase("rtf")) {
- return Driver.RENDER_RTF;
+ return Constants.RENDER_RTF;
} else if (format.equalsIgnoreCase("application/vnd.hp-PCL")
|| format.equalsIgnoreCase("pcl")) {
- return Driver.RENDER_PCL;
+ return Constants.RENDER_PCL;
} else if (format.equalsIgnoreCase("text/plain")
|| format.equalsIgnoreCase("txt")) {
- return Driver.RENDER_TXT;
+ return Constants.RENDER_TXT;
} else if (format.equalsIgnoreCase("text/xml")
|| format.equalsIgnoreCase("at")
|| format.equalsIgnoreCase("xml")) {
- return Driver.RENDER_XML;
+ return Constants.RENDER_XML;
} else {
String err = "Couldn't determine renderer to use: " + format;
throw new BuildException(err);
@@ -363,19 +363,19 @@
private String determineExtension(int renderer) {
switch (renderer) {
- case Driver.RENDER_PDF:
+ case Constants.RENDER_PDF:
return ".pdf";
- case Driver.RENDER_PS:
+ case Constants.RENDER_PS:
return ".ps";
- case Driver.RENDER_MIF:
+ case Constants.RENDER_MIF:
return ".mif";
- case Driver.RENDER_RTF:
+ case Constants.RENDER_RTF:
return ".rtf";
- case Driver.RENDER_PCL:
+ case Constants.RENDER_PCL:
return ".pcl";
- case Driver.RENDER_TXT:
+ case Constants.RENDER_TXT:
return ".txt";
- case Driver.RENDER_XML:
+ case Constants.RENDER_XML:
return ".xml";
default:
String err = "Unknown renderer: " + renderer;
@@ -533,9 +533,10 @@
try {
FOUserAgent userAgent = new FOUserAgent();
userAgent.setBaseURL(this.baseURL);
- Driver driver = new Driver(renderer, userAgent);
- driver.setOutputStream(out);
- inputHandler.render(driver);
+ org.apache.fop.apps.Fop fop =
+ new org.apache.fop.apps.Fop(renderer, userAgent);
+ fop.setOutputStream(out);
+ inputHandler.render(fop);
} catch (Exception ex) {
throw new BuildException(ex);
} finally {
1.12 +22 -22 xml-fop/test/java/org/apache/fop/BasicDriverTestCase.java
Index: BasicDriverTestCase.java
===================================================================
RCS file: /home/cvs/xml-fop/test/java/org/apache/fop/BasicDriverTestCase.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- BasicDriverTestCase.java 20 Jul 2004 03:39:24 -0000 1.11
+++ BasicDriverTestCase.java 24 Jul 2004 05:47:45 -0000 1.12
@@ -35,13 +35,13 @@
import org.xml.sax.InputSource;
import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.Fop;
import org.apache.fop.apps.InputHandler;
import org.apache.fop.apps.XSLTInputHandler;
import org.w3c.dom.Document;
/**
- * Basic runtime test for the old Driver class. It is used to verify that
+ * Basic runtime test for the old Fop class. It is used to verify that
* nothing obvious is broken after compiling.
* @author <a href="mailto:[EMAIL PROTECTED]">Jeremias Maerki</a>
*/
@@ -71,88 +71,88 @@
public void testFO2PDFWithDOM() throws Exception {
File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
ByteArrayOutputStream baout = new ByteArrayOutputStream();
- Driver driver = new Driver(Driver.RENDER_PDF);
- driver.setOutputStream(baout);
+ Fop fop = new Fop(Fop.RENDER_PDF);
+ fop.setOutputStream(baout);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); //Identity transf.
Source src = new DOMSource(loadDocument(foFile));
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
assertTrue("Generated PostScript has zero length", baout.size() > 0);
}
/**
- * Tests Driver with JAXP and OutputStream generating PDF.
+ * Tests Fop with JAXP and OutputStream generating PDF.
* @throws Exception if anything fails
*/
public void testFO2PDFWithJAXP() throws Exception {
File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
ByteArrayOutputStream baout = new ByteArrayOutputStream();
- Driver driver = new Driver(Driver.RENDER_PDF);
- driver.setOutputStream(baout);
+ Fop fop = new Fop(Fop.RENDER_PDF);
+ fop.setOutputStream(baout);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); //Identity transf.
Source src = new StreamSource(foFile);
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
assertTrue("Generated PDF has zero length", baout.size() > 0);
}
/**
- * Tests Driver with JAXP and OutputStream generating PostScript.
+ * Tests Fop with JAXP and OutputStream generating PostScript.
* @throws Exception if anything fails
*/
public void testFO2PSWithJAXP() throws Exception {
File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
ByteArrayOutputStream baout = new ByteArrayOutputStream();
- Driver driver = new Driver(Driver.RENDER_PS);
- driver.setOutputStream(baout);
+ Fop fop = new Fop(Fop.RENDER_PS);
+ fop.setOutputStream(baout);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); //Identity transf.
Source src = new StreamSource(foFile);
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
assertTrue("Generated PostScript has zero length", baout.size() > 0);
}
/**
- * Tests Driver with JAXP and OutputStream generating RTF.
+ * Tests Fop with JAXP and OutputStream generating RTF.
* @throws Exception if anything fails
*/
public void testFO2RTFWithJAXP() throws Exception {
File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
ByteArrayOutputStream baout = new ByteArrayOutputStream();
- Driver driver = new Driver(Driver.RENDER_RTF);
- driver.setOutputStream(baout);
+ Fop fop = new Fop(Fop.RENDER_RTF);
+ fop.setOutputStream(baout);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); //Identity transf.
Source src = new StreamSource(foFile);
- Result res = new SAXResult(driver.getDefaultHandler());
+ Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
assertTrue("Generated RTF has zero length", baout.size() > 0);
}
/**
- * Tests Driver with XsltInputHandler and OutputStream.
+ * Tests Fop with XsltInputHandler and OutputStream.
* @throws Exception if anything fails
*/
public void testFO2PDFWithXSLTInputHandler() throws Exception {
File xmlFile = new File(getBaseDir(), "test/xml/1.xml");
File xsltFile = new File(getBaseDir(), "test/xsl/doc.xsl");
ByteArrayOutputStream baout = new ByteArrayOutputStream();
- Driver driver = new Driver(Driver.RENDER_PDF);
- driver.setOutputStream(baout);
+ Fop fop = new Fop(Fop.RENDER_PDF);
+ fop.setOutputStream(baout);
InputHandler handler = new XSLTInputHandler(xmlFile, xsltFile);
- handler.render(driver);
+ handler.render(fop);
assertTrue("Generated PDF has zero length", baout.size() > 0);
}
1.7 +5 -5 xml-fop/test/java/org/apache/fop/GenericFOPTestCase.java
Index: GenericFOPTestCase.java
===================================================================
RCS file: /home/cvs/xml-fop/test/java/org/apache/fop/GenericFOPTestCase.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GenericFOPTestCase.java 20 Jul 2004 03:39:24 -0000 1.6
+++ GenericFOPTestCase.java 24 Jul 2004 05:47:45 -0000 1.7
@@ -30,7 +30,7 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.render.pdf.PDFRenderer;
import org.apache.fop.util.DigestFilter;
@@ -118,12 +118,12 @@
ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
DigestOutputStream out =
new DigestOutputStream(new ByteArrayOutputStream(), outDigest);
- Driver driver = new Driver(Driver.RENDER_PDF, foUserAgent);
- driver.setOutputStream(out);
+ Fop fop = new Fop(Fop.RENDER_PDF, foUserAgent);
+ fop.setOutputStream(out);
InputSource source = new InputSource(new StringReader(fo));
DigestFilter filter = new DigestFilter("MD5");
filter.setParent(parserFactory.newSAXParser().getXMLReader());
- filter.setContentHandler(driver.getDefaultHandler());
+ filter.setContentHandler(fop.getDefaultHandler());
filter.parse(source);
String digestInActual = digestToString(filter.getDigestValue());
if (!digestIn.equals(digestInActual)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]