pbwest      2004/04/15 22:09:10

  Modified:    src/java/org/apache/fop/fo/flow Tag: FOP_0-20-0_Alt-Design
                        FoPageSequence.java
  Log:
  Added HashMap of ArrayLists of static-content subtrees, indexed by flow-name
  Provide access to umodifiable Map of above
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.12  +58 -7     
xml-fop/src/java/org/apache/fop/fo/flow/Attic/FoPageSequence.java
  
  Index: FoPageSequence.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Attic/FoPageSequence.java,v
  retrieving revision 1.1.2.11
  retrieving revision 1.1.2.12
  diff -u -r1.1.2.11 -r1.1.2.12
  --- FoPageSequence.java       25 Feb 2004 23:40:28 -0000      1.1.2.11
  +++ FoPageSequence.java       16 Apr 2004 05:09:10 -0000      1.1.2.12
  @@ -21,9 +21,16 @@
   package org.apache.fop.fo.flow;
   
   // FOP
  +import java.util.ArrayList;
   import java.util.Arrays;
   import java.util.BitSet;
  +import java.util.Collections;
  +import java.util.HashMap;
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.Map;
   import java.util.NoSuchElementException;
  +import java.util.Set;
   
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.datastructs.TreeException;
  @@ -97,6 +104,20 @@
       private int title = -1;
       /** Child index of first fo:static-content child. */
       private int firstStaticContent = -1;
  +    /**
  +     * Private map of <code>List</code>s of static-content subtrees hashed on
  +     * flow-name.  Note that there is no restriction on multiple
  +     * <code>fo:static-content</code> elements being assigned to a single
  +     * <code>flow-name</code>, so the objects keyed by <code>flow-name</code>
  +     * must be able to hold more than one element; hence <code>List</code>s.
  +     * 
  +     * Each element of the <code>HashMap</code>, keyed on the
  +     * <code>flow-name</code> is an <code>ArrayList</code> containing one or
  +     * more instances of <code>FoStaticContent</code>.
  +     */
  +    private HashMap staticSubtrees = null;
  +    /** Unmodifiable version of <code>staticSubtrees</code> */
  +    public Map staticContents = null;
       /** Child index of fo:flow child. */
       private int flowChild = -1;
   
  @@ -127,18 +148,48 @@
                   namespaces.relinquishEvent(ev);
               } // else ignore
   
  -            // Look for zero or more static-content
  +            // Look for zero or more static-content subtrees
               nowProcessing = "static-content";
               while ((ev = xmlevents.expectStartElement
                       (FObjectNames.STATIC_CONTENT, XmlEvent.DISCARD_W_SPACE))
                      != null) {
                   // Loop over remaining fo:static-content
  -                if (firstStaticContent == -1)
  +                if (firstStaticContent == -1) {
                       firstStaticContent = numChildren();
  -                new FoStaticContent(getFOTree(), this, (FoXmlEvent)ev);
  +                    staticSubtrees = new HashMap();
  +                }
  +                FoStaticContent statContent  =
  +                    new FoStaticContent(getFOTree(), this, (FoXmlEvent)ev);
                   namespaces.relinquishEvent(ev);
  +                // Collect the static-content subtrees for this page-sequence
  +                String flowname = statContent.getFlowName();
  +                if (! staticSubtrees.containsKey(flowname)) {
  +                    // Create a new list for this key
  +                    staticSubtrees.put(flowname, new ArrayList(1));
  +                }
  +                // Add an entry to an existing List
  +                ArrayList statconsList =
  +                    (ArrayList)(staticSubtrees.get(flowname));
  +                statconsList.add(statContent);
  +            }
  +            // Create the unmodifiable map of unmodifiable lists
  +            // TODO make the contents of the events buffer unmodifiable
  +            // Each value in the Map is an ArrayList.  Iterate over all of the
  +            // entries, replacing the ArrayList value in each Map.Entry with an
  +            // unmodifiableList constructed from the ArrayList
  +            if (staticSubtrees != null) {
  +                Set entries = staticSubtrees.entrySet();
  +                Iterator iter = entries.iterator();
  +                while (iter.hasNext()) {
  +                    Map.Entry entry = (Map.Entry)(iter.next());
  +                    entry.setValue(
  +                            Collections.unmodifiableList(
  +                                    (List)(entry.getValue())));
  +                }
  +                // Now make an unmodifiableMap from the overall HashMap
  +                // of flow-name indexed ArrayLists
  +                staticContents = Collections.unmodifiableMap(staticSubtrees);
               }
  -            
               // Generate a null page for the flow(s)
               
   
  
  
  

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

Reply via email to