gmazza      2003/07/12 14:22:04

  Modified:    examples/mathml/src/org/apache/fop/mathml
                        MathMLElementMapping.java
               examples/plan/src/org/apache/fop/plan
                        PlanElementMapping.java
               src/java/org/apache/fop/extensions
                        ExtensionElementMapping.java
               src/java/org/apache/fop/fo ElementMapping.java
                        FOElementMapping.java FOTreeBuilder.java
               src/java/org/apache/fop/svg SVGElementMapping.java
  Log:
  Reconfigured ElementMapping from an interface to an abstract base class
  Removed FOTreeBuilder references from all ElementMapping subclasses
  Simplified FOTreeBuilder ElementMapping instantiation somewhat
  
  Revision  Changes    Path
  1.3       +6 -16     
xml-fop/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java
  
  Index: MathMLElementMapping.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MathMLElementMapping.java 7 Mar 2003 10:47:42 -0000       1.2
  +++ MathMLElementMapping.java 12 Jul 2003 21:22:03 -0000      1.3
  @@ -50,7 +50,6 @@
    */ 
   package org.apache.fop.mathml;
   
  -import org.apache.fop.fo.FOTreeBuilder;
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.ElementMapping;
   import org.apache.fop.image.analyser.XMLReader;
  @@ -65,14 +64,13 @@
   /**
    * This class provides the element mapping for FOP.
    */
  -public class MathMLElementMapping implements ElementMapping {
  +public class MathMLElementMapping extends ElementMapping {
   
  -    /** MathML namespace */
  -    public static final String URI = "http://www.w3.org/1998/Math/MathML";;
  -
  -    private static HashMap foObjs = null;
  +    public MathMLElementMapping() {
  +        URI = "http://www.w3.org/1998/Math/MathML";;
  +    }
   
  -    private static synchronized void setupMathML() {
  +    protected void initialize() {
           if (foObjs == null) {
               foObjs = new HashMap();
               foObjs.put("math", new ME());
  @@ -80,14 +78,6 @@
   
               XMLReader.setConverter(URI, new MathMLConverter());
           }
  -    }
  -
  -    /**
  -     * @see org.apache.fop.fo.ElementMapping#addToBuilder(FOTreeBuilder)
  -     */
  -    public void addToBuilder(FOTreeBuilder builder) {
  -        setupMathML();
  -        builder.addMapping(URI, foObjs);
       }
   
       static class MathMLMaker extends ElementMapping.Maker {
  
  
  
  1.3       +6 -16     
xml-fop/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java
  
  Index: PlanElementMapping.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PlanElementMapping.java   7 Mar 2003 10:47:51 -0000       1.2
  +++ PlanElementMapping.java   12 Jul 2003 21:22:03 -0000      1.3
  @@ -50,7 +50,6 @@
    */ 
   package org.apache.fop.plan;
   
  -import org.apache.fop.fo.FOTreeBuilder;
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.ElementMapping;
   import org.apache.fop.image.analyser.XMLReader;
  @@ -62,14 +61,13 @@
   /**
    * This class provides the element mapping for FOP.
    */
  -public class PlanElementMapping implements ElementMapping {
  +public class PlanElementMapping extends ElementMapping {
   
  -    /** The namespace for the plan extension */
  -    public static final String URI = "http://xml.apache.org/fop/plan";;
  -
  -    private static HashMap foObjs = null;
  +    public PlanElementMapping() {
  +        URI = "http://xml.apache.org/fop/plan";;
  +    }
   
  -    private static synchronized void setupPlan() {
  +    protected void initialize() {
           if (foObjs == null) {
               foObjs = new java.util.HashMap();
               foObjs.put("plan", new PE());
  @@ -77,14 +75,6 @@
   
               XMLReader.setConverter(URI, new PlanConverter());
           }
  -    }
  -
  -    /**
  -     * @see org.apache.fop.fo.ElementMapping#addToBuilder(FOTreeBuilder)
  -     */
  -    public void addToBuilder(FOTreeBuilder builder) {
  -        setupPlan();
  -        builder.addMapping(URI, foObjs);
       }
   
       static class PlanMaker extends ElementMapping.Maker {
  
  
  
  1.2       +5 -21     
xml-fop/src/java/org/apache/fop/extensions/ExtensionElementMapping.java
  
  Index: ExtensionElementMapping.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/extensions/ExtensionElementMapping.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExtensionElementMapping.java      11 Mar 2003 13:05:41 -0000      1.1
  +++ ExtensionElementMapping.java      12 Jul 2003 21:22:03 -0000      1.2
  @@ -52,7 +52,6 @@
   
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.ElementMapping;
  -import org.apache.fop.fo.FOTreeBuilder;
   
   import java.util.HashMap;
   
  @@ -61,34 +60,19 @@
    * This sets up the mapping for the classes that handle the
    * pdf bookmark extension.
    */
  -public class ExtensionElementMapping implements ElementMapping {
  -    /**
  -     * The pdf bookmark extension uri
  -     */
  -    public static final String URI = "http://xml.apache.org/fop/extensions";;
  +public class ExtensionElementMapping extends ElementMapping {
   
  -    // the mappings are only setup once and resued after that
  -    private static HashMap foObjs = null;
  +    public ExtensionElementMapping() {
  +        URI = "http://xml.apache.org/fop/extensions";;
  +    }
   
  -    private static synchronized void setupExt() {
  +    protected void initialize() {
           if (foObjs == null) {
               foObjs = new HashMap();
               foObjs.put("bookmarks", new B());
               foObjs.put("outline", new O());
               foObjs.put("label", new L());
           }
  -    }
  -
  -    /**
  -     * Add the mappings to the fo tree builder.
  -     *
  -     * @param builder the fo tree builder to add the mappings
  -     */
  -    public void addToBuilder(FOTreeBuilder builder) {
  -        if (foObjs == null) {
  -            setupExt();
  -        }
  -        builder.addMapping(URI, foObjs);
       }
   
       static class B extends ElementMapping.Maker {
  
  
  
  1.2       +37 -3     xml-fop/src/java/org/apache/fop/fo/ElementMapping.java
  
  Index: ElementMapping.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/ElementMapping.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ElementMapping.java       11 Mar 2003 13:05:19 -0000      1.1
  +++ ElementMapping.java       12 Jul 2003 21:22:03 -0000      1.2
  @@ -50,14 +50,48 @@
    */ 
   package org.apache.fop.fo;
   
  +import java.util.HashMap;
  +
   /**
    * Interface for adding supported element and property mappings to
    * the given builder.
    */
  -public interface ElementMapping {
  -    final String DEFAULT = "<default>";
  +/** Abstract base class of FO Element Mappings.  */
  +public abstract class ElementMapping {
  +    public static final String DEFAULT = "<default>";
  +
  +    /** The HashMap table of formatting objects defined by the ElementMapping */
  +    protected HashMap foObjs = null;
  +
  +    /** The namespace for the ElementMapping */
  +    protected String URI = null;
  +
  +    /**
  +     * Returns a HashMap of maker objects for this element mapping
  +     *
  +     * @return Table of Maker objects for this ElementMapping
  +     */
  +    public HashMap getTable() {
  +        if (foObjs == null) {
  +            initialize();
  +        }
  +        return foObjs;
  +    }
  +
  +    /**
  +     * Returns the namespace URI for this element mapping
  +     *
  +     * @return Namespace URI for this element mapping
  +    */
  +    public String getNamespaceURI() {
  +        return URI;
  +    }
   
  -    void addToBuilder(FOTreeBuilder builder);
  +    /**
  +     * Initializes the set of maker objects associated with this ElementMapping
  +     *
  +    */
  +    protected abstract void initialize();
   
       public static class Maker {
           public FONode make(FONode parent) {
  
  
  
  1.2       +5 -13     xml-fop/src/java/org/apache/fop/fo/FOElementMapping.java
  
  Index: FOElementMapping.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOElementMapping.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FOElementMapping.java     11 Mar 2003 13:05:19 -0000      1.1
  +++ FOElementMapping.java     12 Jul 2003 21:22:03 -0000      1.2
  @@ -56,11 +56,13 @@
   /**
    * Element mapping class for all XSL-FO elements.
    */
  -public class FOElementMapping implements ElementMapping {
  +public class FOElementMapping extends ElementMapping {
       
  -    private static HashMap foObjs = null;
  +    public FOElementMapping() {
  +        URI = "http://www.w3.org/1999/XSL/Format";;
  +    }
   
  -    private static synchronized void setupFO() {
  +    protected void initialize() {
           if (foObjs == null) {
               foObjs = new HashMap();
   
  @@ -148,16 +150,6 @@
               foObjs.put("marker", new M());
               foObjs.put("retrieve-marker", new RM());
           }
  -
  -    }
  -
  -    /**
  -     * @see org.apache.fop.fo.ElementMapping#addToBuilder(FOTreeBuilder)
  -     */
  -    public void addToBuilder(FOTreeBuilder builder) {
  -        setupFO();
  -        String uri = "http://www.w3.org/1999/XSL/Format";;
  -        builder.addMapping(uri, foObjs);
       }
   
       static class R extends ElementMapping.Maker {
  
  
  
  1.6       +2 -12     xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java
  
  Index: FOTreeBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FOTreeBuilder.java        4 Jul 2003 18:45:48 -0000       1.5
  +++ FOTreeBuilder.java        12 Jul 2003 21:22:03 -0000      1.6
  @@ -172,24 +172,14 @@
       }
   
       /**
  -     * Adds a mapping from a namespace to a table of makers.
  -     *
  -     * @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);
  -        this.namespaces.add(namespaceURI.intern());
  -    }
  -
  -    /**
        * Add the given element mapping.
        * An element mapping maps element names to Java classes.
        *
        * @param mapping the element mappingto add
        */
       public void addElementMapping(ElementMapping mapping) {
  -        mapping.addToBuilder(this);
  +        this.fobjTable.put(mapping.getNamespaceURI(), mapping.getTable());
  +        this.namespaces.add(mapping.getNamespaceURI().intern());
       }
   
       /**
  
  
  
  1.4       +14 -24    xml-fop/src/java/org/apache/fop/svg/SVGElementMapping.java
  
  Index: SVGElementMapping.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/svg/SVGElementMapping.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SVGElementMapping.java    17 Jun 2003 16:35:57 -0000      1.3
  +++ SVGElementMapping.java    12 Jul 2003 21:22:04 -0000      1.4
  @@ -53,7 +53,6 @@
   import java.util.HashMap;
   
   import org.apache.fop.fo.FONode;
  -import org.apache.fop.fo.FOTreeBuilder;
   import org.apache.fop.fo.ElementMapping;
   import org.apache.fop.apps.Driver;
   
  @@ -65,34 +64,25 @@
    * This adds the svg element mappings used to create the objects
    * that create the SVG Document.
    */
  -public class SVGElementMapping implements ElementMapping {
  -    private static HashMap foObjs = null;
  -    private static boolean batik = true;
  +public class SVGElementMapping extends ElementMapping {
  +    private boolean batik = true;
   
  -    private static synchronized void setupSVG() {
  -        if (foObjs == null) {
  +    public SVGElementMapping() {
  +        URI = SVGDOMImplementation.SVG_NAMESPACE_URI;
  +    }
  +
  +    protected void initialize() {
  +        if (foObjs == null && batik == true) {
               // this sets the parser that will be used
               // by default (SVGBrokenLinkProvider)
               // normally the user agent value is used
  -            XMLResourceDescriptor.setXMLParserClassName(
  -              Driver.getParserClassName());
  -
  -            foObjs = new HashMap();
  -            foObjs.put("svg", new SE());
  -            foObjs.put(DEFAULT, new SVGMaker());
  -        }
  -    }
  -
  -    /**
  -     * Add the SVG element mappings to the tree builder.
  -     * @param builder the FOTreeBuilder to add the mappings to
  -     */
  -    public void addToBuilder(FOTreeBuilder builder) {
  -        if (batik) {
               try {
  -                setupSVG();
  -                String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
  -                builder.addMapping(svgNS, foObjs);
  +                XMLResourceDescriptor.setXMLParserClassName(
  +                  Driver.getParserClassName());
  +    
  +                foObjs = new HashMap();
  +                foObjs.put("svg", new SE());
  +                foObjs.put(DEFAULT, new SVGMaker());
               } catch (Throwable t) {
                   // if the classes are not available
                   // the DISPLAY is not checked
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to