You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ol...@apache.org on 2002/12/17 00:27:15 UTC

cvs commit: xml-fop/src/org/apache/fop/fo FOTreeBuilder.java

olegt       2002/12/16 15:27:15

  Modified:    src/org/apache/fop/fo FOTreeBuilder.java
  Log:
  Removed unused imports, cleaned up style, logging and javadoc. Removed redundant unknown fo collection.
  
  Revision  Changes    Path
  1.41      +26 -39    xml-fop/src/org/apache/fop/fo/FOTreeBuilder.java
  
  Index: FOTreeBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FOTreeBuilder.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- FOTreeBuilder.java	14 Aug 2002 14:25:18 -0000	1.40
  +++ FOTreeBuilder.java	16 Dec 2002 23:27:15 -0000	1.41
  @@ -10,9 +10,6 @@
   // FOP
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.apps.StructureHandler;
  -import org.apache.fop.fo.pagination.Root;
  -import org.apache.fop.fo.pagination.PageSequence;
  -import org.apache.fop.extensions.ExtensionObj;
   
   // Avalon
   import org.apache.avalon.framework.logger.Logger;
  @@ -20,13 +17,10 @@
   // SAX
   import org.xml.sax.helpers.DefaultHandler;
   import org.xml.sax.SAXException;
  -import org.xml.sax.InputSource;
   import org.xml.sax.Attributes;
   
   // Java
  -import java.util.HashMap;
  -import java.util.ArrayList;
  -import java.io.IOException;
  +import java.util.*;
   
   /**
    * SAX Handler that builds the formatting object tree.
  @@ -42,34 +36,32 @@
   public class FOTreeBuilder extends DefaultHandler {
   
       /**
  -     * table mapping element names to the makers of objects
  -     * representing formatting objects
  +     * Table mapping element names to the makers of objects
  +     * representing formatting objects.
        */
  -    protected HashMap fobjTable = new HashMap();
  -
  -    protected ArrayList namespaces = new ArrayList();
  +    protected Map fobjTable = new HashMap();
   
       /**
  -     * current formatting object being handled
  +     * Set of mapped namespaces.
        */
  -    protected FONode currentFObj = null;
  +    protected Set namespaces = new HashSet();
   
       /**
  -     * the root of the formatting object tree
  +     * Current formatting object being handled
        */
  -    protected FObj rootFObj = null;
  +    protected FONode currentFObj = null;
   
       /**
  -     * set of names of formatting objects encountered but unknown
  +     * The root of the formatting object tree
        */
  -    protected HashMap unknownFOs = new HashMap();
  +    protected FONode rootFObj = null;
   
       /**
  -     *
        * The class that handles formatting and rendering to a stream
        * (mark-fop@inomial.com)
        */
       private StructureHandler structHandler;
  +
       private FOUserAgent userAgent;
   
       public FOTreeBuilder() {}
  @@ -86,17 +78,15 @@
           return userAgent;
       }
   
  -
       public void setStructHandler(StructureHandler sh) {
           this.structHandler = sh;
       }
   
       /**
  -     * add a mapping from element name to maker.
  +     * Adds a mapping from a namespace to a table of makers.
        *
  -     * @param namespaceURI namespace URI of formatting object element
  -     * @param localName local name of formatting object element
  -     * @param maker Maker for class representing formatting object
  +     * @param namespaceURI namespace URI of formatting object elements
  +     * @param table table of makers
        */
       public void addMapping(String namespaceURI, HashMap table) {
           this.fobjTable.put(namespaceURI, table);
  @@ -118,7 +108,6 @@
       public void endElement(String uri, String localName, String rawName)
       throws SAXException {
           currentFObj.end();
  -
           currentFObj = currentFObj.getParent();
       }
   
  @@ -128,13 +117,18 @@
       public void startDocument()
       throws SAXException {
           rootFObj = null;    // allows FOTreeBuilder to be reused
  -        getLogger().debug("building formatting object tree");
  +        if (getLogger().isDebugEnabled())
  +            getLogger().debug("Building formatting object tree");
           structHandler.startDocument();
       }
   
  +    /**
  +     * SAX Handler for the end of the document
  +     */
       public void endDocument()
       throws SAXException {
  -        getLogger().debug("Parsing of document complete");
  +        if (getLogger().isDebugEnabled())
  +            getLogger().debug("Parsing of document complete");
           structHandler.endDocument();
       }
   
  @@ -149,7 +143,7 @@
           /* the maker for the formatting object started */
           ElementMapping.Maker fobjMaker = null;
   
  -        HashMap table = (HashMap)fobjTable.get(uri);
  +        Map table = (Map)fobjTable.get(uri);
           if(table != null) {
               fobjMaker = (ElementMapping.Maker)table.get(localName);
               // try default
  @@ -158,20 +152,14 @@
               }
           }
   
  -        boolean foreignXML = false;
           if (fobjMaker == null) {
  -            String fullName = uri + "^" + localName;
  -            if (!this.unknownFOs.containsKey(fullName)) {
  -                this.unknownFOs.put(fullName, "");
  -                getLogger().warn("Unknown formatting object "
  -                                       + fullName);
  -            }
  +            if (getLogger().isWarnEnabled())
  +                getLogger().warn("Unknown formatting object " + uri + "^" + localName);
               if(namespaces.contains(uri.intern())) {
                   // fall back
                   fobjMaker = new Unknown.Maker();
               } else {
                   fobjMaker = new UnknownXMLObj.Maker(uri);
  -                foreignXML = true;
               }
           }
   
  @@ -195,7 +183,7 @@
                                                           + " be fo:root, not "
                                                           + fobj.getName()));
               }
  -            rootFObj = (FObj)fobj;
  +            rootFObj = fobj;
           } else {
               currentFObj.addChild(fobj);
           }
  @@ -212,5 +200,4 @@
       public boolean hasData() {
           return (rootFObj != null);
       }
  -
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org