From 4d59e568a0d1906bb7830199012a5d475e3e077a Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Thu, 28 Feb 2008 21:29:04 +0000 Subject: [PATCH] Minor tweaks/updates: - change toString() to getLocalizedMessage() for exceptions passed to warning() - removed deprecated method isLocatorDisabled() - removed superfluous try-catch block - some javadoc changes git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@632121 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/FOTreeBuilder.java | 99 +++++++------------ 1 file changed, 35 insertions(+), 64 deletions(-) diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 63fc5cb5b..c12a20afe 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -57,9 +57,7 @@ public class FOTreeBuilder extends DefaultHandler { /** The registry for ElementMapping instances */ protected ElementMappingRegistry elementMappingRegistry; - /** - * The root of the formatting object tree - */ + /** The root of the formatting object tree */ protected Root rootFObj = null; /** Main DefaultHandler that handles the FO namespace. */ @@ -68,10 +66,7 @@ public class FOTreeBuilder extends DefaultHandler { /** Current delegate ContentHandler to receive the SAX events */ protected ContentHandler delegate; - /** - * The class that handles formatting and rendering to a stream - * (mark-fop@inomial.com) - */ + /** The object that handles formatting and rendering to a stream */ private FOEventHandler foEventHandler; /** The SAX locator object managing the line and column counters */ @@ -86,14 +81,18 @@ public class FOTreeBuilder extends DefaultHandler { private int depth; /** - * FOTreeBuilder constructor + * FOTreeBuilder constructor + * * @param outputFormat the MIME type of the output format to use (ex. "application/pdf"). - * @param foUserAgent in effect for this process - * @param stream OutputStream to direct results - * @throws FOPException if the FOTreeBuilder cannot be properly created + * @param foUserAgent the {@link FOUserAgent} in effect for this process + * @param stream the OutputStream to direct the results to + * @throws FOPException if the FOTreeBuilder cannot be properly created */ - public FOTreeBuilder(String outputFormat, FOUserAgent foUserAgent, - OutputStream stream) throws FOPException { + public FOTreeBuilder( + String outputFormat, + FOUserAgent foUserAgent, + OutputStream stream) + throws FOPException { this.userAgent = foUserAgent; this.elementMappingRegistry = userAgent.getFactory().getElementMappingRegistry(); @@ -108,40 +107,25 @@ public class FOTreeBuilder extends DefaultHandler { }); } - /** - * This method enables to reduce memory consumption of the FO tree slightly. When it returns - * true no Locator is passed to the FO tree nodes which would copy the information into - * a SAX LocatorImpl instance. - * @return true if no context information should be stored on each node in the FO tree. - * @deprecated Use FOUserAgent.isLocatorEnabled() instead. - */ - protected boolean isLocatorDisabled() { - return !userAgent.isLocatorEnabled(); - } - - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void setDocumentLocator(Locator locator) { this.locator = locator; } - /** @return a Locator instance if it is available and not disabled */ + /** + * @return a {@link Locator} instance if it is available and not disabled + */ protected Locator getEffectiveLocator() { return (userAgent.isLocatorEnabled() ? this.locator : null); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void characters(char[] data, int start, int length) throws SAXException { delegate.characters(data, start, length); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startDocument() throws SAXException { if (used) { throw new IllegalStateException("FOTreeBuilder (and the Fop class) cannot be reused." @@ -159,9 +143,7 @@ public class FOTreeBuilder extends DefaultHandler { this.delegate = this.mainFOHandler; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endDocument() throws SAXException { this.delegate.endDocument(); if (this.rootFObj == null && empty) { @@ -179,18 +161,14 @@ public class FOTreeBuilder extends DefaultHandler { imageFactory.removeContext(this.userAgent); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startElement(String namespaceURI, String localName, String rawName, Attributes attlist) throws SAXException { this.depth++; delegate.startElement(namespaceURI, localName, rawName, attlist); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endElement(String uri, String localName, String rawName) throws SAXException { this.delegate.endElement(uri, localName, rawName); @@ -206,7 +184,8 @@ public class FOTreeBuilder extends DefaultHandler { } /** - * Finds the Maker used to create node objects of a particular type + * Finds the {@link Maker} used to create {@link FONode} objects of a particular type + * * @param namespaceURI URI for the namespace of the element * @param localName name of the Element * @return the ElementMapping.Maker that can create an FO object for this element @@ -218,7 +197,7 @@ public class FOTreeBuilder extends DefaultHandler { /** {@inheritDoc} */ public void warning(SAXParseException e) { - log.warn(e.toString()); + log.warn(e.getLocalizedMessage()); } /** {@inheritDoc} */ @@ -233,7 +212,8 @@ public class FOTreeBuilder extends DefaultHandler { } /** - * Provides access to the underlying FOEventHandler object. + * Provides access to the underlying {@link FOEventHandler} object. + * * @return the FOEventHandler object */ public FOEventHandler getEventHandler() { @@ -244,6 +224,7 @@ public class FOTreeBuilder extends DefaultHandler { * Returns the results of the rendering process. Information includes * the total number of pages generated and the number of pages per * page-sequence. + * * @return the results of the rendering process. */ public FormattingResults getResults() { @@ -257,23 +238,17 @@ public class FOTreeBuilder extends DefaultHandler { } /** - * Main DefaultHandler implementation which builds the FO tree. + * Main DefaultHandler implementation which builds the FO tree. */ private class MainFOHandler extends DefaultHandler { - /** - * Current formatting object being handled - */ + /** Current formatting object being handled */ protected FONode currentFObj = null; - /** - * Current propertyList for the node being handled. - */ + /** Current propertyList for the node being handled */ protected PropertyList currentPropertyList; - /** - * Current marker nesting-depth - */ + /** Current marker nesting-depth */ private int nestedMarkerDepth = 0; /** {@inheritDoc} */ @@ -298,11 +273,7 @@ public class FOTreeBuilder extends DefaultHandler { } else { // check that incoming node is valid for currentFObj if (namespaceURI.equals(FOElementMapping.URI) || namespaceURI.equals(ExtensionElementMapping.URI)) { - try { - currentFObj.validateChildNode(locator, namespaceURI, localName); - } catch (ValidationException e) { - throw e; - } + currentFObj.validateChildNode(locator, namespaceURI, localName); } } @@ -391,12 +362,11 @@ public class FOTreeBuilder extends DefaultHandler { if (currentFObj.getParent() == null) { log.debug("endElement for top-level " + currentFObj.getName()); } + currentFObj = currentFObj.getParent(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void characters(char[] data, int start, int length) throws FOPException { if (currentFObj != null) { @@ -405,6 +375,7 @@ public class FOTreeBuilder extends DefaultHandler { } } + /** {@inheritDoc} */ public void endDocument() throws SAXException { currentFObj = null; } -- 2.39.5