From: Simon Pepping Date: Sun, 18 Jul 2004 19:51:40 +0000 (+0000) Subject: Implemented the ErrorHandler interface in FOTreeBuilder. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~663 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ff444740eb9e98a09f47084627949ab3bd32d5a0;p=xmlgraphics-fop.git Implemented the ErrorHandler interface in FOTreeBuilder. Created a method in Driver to return FOTreeBuilder as a DefaultHandler. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197799 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/apps/Driver.java b/src/java/org/apache/fop/apps/Driver.java index cda771e7a..353eac05f 100644 --- a/src/java/org/apache/fop/apps/Driver.java +++ b/src/java/org/apache/fop/apps/Driver.java @@ -27,6 +27,7 @@ import org.xml.sax.ContentHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; // FOP import org.apache.fop.fo.Constants; @@ -146,13 +147,17 @@ public class Driver implements Constants { * ContentHandler that directly place data into the output stream. Layout * renderers (e.g. PDF & PostScript) use a ContentHandler that builds an FO * Tree. - * @return a SAX ContentHandler for handling the SAX events. - * @throws FOPException if setting up the ContentHandler fails + * @return a SAX DefaultHandler for handling the SAX events. + * @throws FOPException if setting up the DefaultHandler fails */ - public ContentHandler getContentHandler() throws FOPException { + public DefaultHandler getDefaultHandler() throws FOPException { return new FOTreeBuilder(renderType, foUserAgent, stream); } + public ContentHandler getContentHandler() throws FOPException { + return getDefaultHandler(); + } + /** * Render the FO document read by a SAX Parser from an InputHandler * @param inputHandler the input handler containing the source and diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 5f32eda89..dcb359c24 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -43,6 +43,7 @@ import org.apache.fop.fo.pagination.Root; import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; /** @@ -326,6 +327,28 @@ public class FOTreeBuilder extends DefaultHandler { return fobjMaker; } + /** + * org.xml.sax.ErrorHandler#warning + **/ + public void warning(SAXParseException e) { + log.warn(e.toString()); + } + + /** + * org.xml.sax.ErrorHandler#error + **/ + public void error(SAXParseException e) { + log.error(e.toString()); + } + + /** + * org.xml.sax.ErrorHandler#fatalError + **/ + public void fatalError(SAXParseException e) throws SAXException { + log.error(e.toString()); + throw e; + } + /** * Resets this object for another run. */