From cd49b6d553c7fd4c3bcd51e6d7c7a3a10a1898ea Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Sat, 24 Jul 2004 22:56:31 +0000 Subject: [PATCH] moved FO term of a Node's child elements from "Children" to "ChildNodes" git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197835 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/area/AreaTreeHandler.java | 2 +- src/java/org/apache/fop/fo/FONode.java | 12 ++-- src/java/org/apache/fop/fo/FObj.java | 57 +++++++++---------- src/java/org/apache/fop/fo/PropertySets.java | 20 +++---- .../apache/fop/fo/RecursiveCharIterator.java | 14 ++--- src/java/org/apache/fop/fo/flow/Block.java | 4 +- .../org/apache/fop/fo/flow/ListItemBody.java | 2 +- .../org/apache/fop/fo/flow/ListItemLabel.java | 2 +- src/java/org/apache/fop/fo/flow/Wrapper.java | 2 +- .../fop/fo/pagination/Declarations.java | 6 +- .../fop/fo/pagination/LayoutMasterSet.java | 2 +- .../fop/fo/pagination/PageSequenceMaster.java | 2 +- .../RepeatablePageMasterAlternatives.java | 2 +- .../fop/fo/pagination/StaticContent.java | 2 +- .../fop/layoutmgr/AbstractLayoutManager.java | 2 +- .../apache/fop/layoutmgr/AddLMVisitor.java | 20 +++---- .../org/apache/fop/render/rtf/RTFHandler.java | 4 +- 17 files changed, 77 insertions(+), 78 deletions(-) diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java index 59972cc17..d2ff24740 100644 --- a/src/java/org/apache/fop/area/AreaTreeHandler.java +++ b/src/java/org/apache/fop/area/AreaTreeHandler.java @@ -437,7 +437,7 @@ public class AreaTreeHandler extends FOInputHandler { // to the Title. InlineStackingLayoutManager lm; lm = new InlineStackingLayoutManager(foTitle); - lm.setLMiter(new LMiter(lm, foTitle.children.listIterator())); + lm.setLMiter(new LMiter(lm, foTitle.childNodes.listIterator())); lm.initialize(); // get breaks then add areas to title diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index 8314084d5..e507021f0 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -165,7 +165,7 @@ public abstract class FONode { } /** - * @param child child node to be added to the children of this node + * @param child child node to be added to the childNodes of this node */ protected void addChildNode(FONode child) { } @@ -178,21 +178,21 @@ public abstract class FONode { } /** - * Return an iterator over all the children of this FObj. + * Return an iterator over all the child nodes of this FObj. * @return A ListIterator. */ - public ListIterator getChildren() { + public ListIterator getChildNodes() { return null; } /** - * Return an iterator over the object's children starting + * Return an iterator over the object's child nodes starting * at the pased node. * @param childNode First node in the iterator - * @return A ListIterator or null if childNode isn't a child of + * @return A ListIterator or null if child node isn't a child of * this FObj. */ - public ListIterator getChildren(FONode childNode) { + public ListIterator getChildNodes(FONode childNode) { return null; } diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index b043ce75a..ac9f72baf 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -47,8 +47,8 @@ public class FObj extends FONode implements Constants { /** Id of this fo element of null if no id. */ protected String id = null; - /** The children of this node. */ - public ArrayList children = null; + /** The immediate child nodes of this node. */ + public ArrayList childNodes = null; /** Markers added to this element. */ protected Map markers = null; @@ -139,7 +139,21 @@ public class FObj extends FONode implements Constants { return propertyList.get(propId); } - /** + /** + * @see org.apache.fop.fo.FONode#addChildNode(FONode) + */ + protected void addChildNode(FONode child) { + if (containsMarkers() && "fo:marker".equals(child.getName())) { + addMarker((Marker)child); + } else { + if (childNodes == null) { + childNodes = new ArrayList(); + } + childNodes.add(child); + } + } + + /** * Find the nearest parent, grandparent, etc. FONode that is also an FObj * @return FObj the nearest ancestor FONode that is an FObj */ @@ -250,20 +264,6 @@ public class FObj extends FONode implements Constants { return new Integer(0); } - /** - * @see org.apache.fop.fo.FONode#addChildNode(FONode) - */ - protected void addChildNode(FONode child) { - if (containsMarkers() && "fo:marker".equals(child.getName())) { - addMarker((Marker)child); - } else { - if (children == null) { - children = new ArrayList(); - } - children.add(child); - } - } - /** * Setup the id for this formatting object. * Most formatting objects can have an id that can be referenced. @@ -335,28 +335,27 @@ public class FObj extends FONode implements Constants { } /** - * Return an iterator over all the children of this FObj. - * @return A ListIterator. + * @see org.apache.fop.fo.FONode#getChildNodes() */ - public ListIterator getChildren() { - if (children != null) { - return children.listIterator(); + public ListIterator getChildNodes() { + if (childNodes != null) { + return childNodes.listIterator(); } return null; } /** - * Return an iterator over the object's children starting + * Return an iterator over the object's childNodes starting * at the pased node. * @param childNode First node in the iterator * @return A ListIterator or null if childNode isn't a child of * this FObj. */ public ListIterator getChildren(FONode childNode) { - if (children != null) { - int i = children.indexOf(childNode); + if (childNodes != null) { + int i = childNodes.indexOf(childNode); if (i >= 0) { - return children.listIterator(i); + return childNodes.listIterator(i); } } return null; @@ -371,9 +370,9 @@ public class FObj extends FONode implements Constants { */ public void addMarker(Marker marker) { String mcname = marker.getMarkerClassName(); - if (children != null) { - // check for empty children - for (Iterator iter = children.iterator(); iter.hasNext();) { + if (childNodes != null) { + // check for empty childNodes + for (Iterator iter = childNodes.iterator(); iter.hasNext();) { FONode node = (FONode)iter.next(); if (node instanceof FOText) { FOText text = (FOText)node; diff --git a/src/java/org/apache/fop/fo/PropertySets.java b/src/java/org/apache/fop/fo/PropertySets.java index 8f4c12ef4..d959e2997 100644 --- a/src/java/org/apache/fop/fo/PropertySets.java +++ b/src/java/org/apache/fop/fo/PropertySets.java @@ -969,7 +969,7 @@ public class PropertySets { - // Merge the attributes from the children into the parent. + // Merge the attributes from the child nodes into the parent. for (boolean dirty = true; dirty; ) { dirty = false; for (int i = 1; i < elements.length; i++) { @@ -1017,7 +1017,7 @@ public class PropertySets { BitSet relevant = new BitSet(); BitSet valid = new BitSet(); int elementId; - ArrayList children; + ArrayList childNodes; Element(int elementId) { this.elementId = elementId; @@ -1043,14 +1043,14 @@ public class PropertySets { * Add a single fo element as a content child. */ public void addContent(int elementId) { - if (children == null) { - children = new ArrayList(); + if (childNodes == null) { + childNodes = new ArrayList(); } - children.add(elements[elementId]); + childNodes.add(elements[elementId]); } /** - * Add a set of fo elements as content children. + * Add a set of fo elements as content child nodes. */ public void addContent(BitSet elements) { for (int i = 0; i < elements.size(); i++) { @@ -1061,16 +1061,16 @@ public class PropertySets { } /** - * Merge the properties from the children into the set of valid + * Merge the properties from the child nodes into the set of valid * properties. Return true if at least one property could be added. */ public boolean merge() { - if (children == null) { + if (childNodes == null) { return false; } boolean dirty = false; - for (int i = 0; i < children.size(); i++) { - Element child = (Element) children.get(i); + for (int i = 0; i < childNodes.size(); i++) { + Element child = (Element) childNodes.get(i); BitSet childValid = child.valid; int n = childValid.length(); for (int j = 0; j < n; j++) { diff --git a/src/java/org/apache/fop/fo/RecursiveCharIterator.java b/src/java/org/apache/fop/fo/RecursiveCharIterator.java index a9e19858a..7757b101a 100644 --- a/src/java/org/apache/fop/fo/RecursiveCharIterator.java +++ b/src/java/org/apache/fop/fo/RecursiveCharIterator.java @@ -22,13 +22,13 @@ import java.util.Iterator; import java.util.NoSuchElementException; /** - * Kind of a super-iterator that iterates through children of an FONode, + * Kind of a super-iterator that iterates through child nodes of an FONode, * in turn managing character iterators for each of them. Caveat: Because this * class is itself a CharIterator, and manages a collection of CharIterators, it * is easy to get confused. */ public class RecursiveCharIterator extends AbstractCharIterator { - /** parent node for whose children this iterator iterates */ + /** parent node for whose child nodes this iterator iterates */ private FONode fobj; /** iterator for the child nodes */ private Iterator childIter = null; @@ -39,25 +39,25 @@ public class RecursiveCharIterator extends AbstractCharIterator { private CharIterator curCharIter = null; /** - * Constructor which creates an iterator for all children + * Constructor which creates an iterator for all child nodes * @param fobj FONode for which an iterator should be created */ public RecursiveCharIterator(FObj fobj) { // Set up first child iterator this.fobj = fobj; - this.childIter = fobj.getChildren(); + this.childIter = fobj.getChildNodes(); getNextCharIter(); } /** - * Constructor which creates an iterator for only some children + * Constructor which creates an iterator for only some child nodes * @param fobj FObj for which an iterator should be created * @param child FONode of the first child to include in iterator */ public RecursiveCharIterator(FObj fobj, FONode child) { // Set up first child iterator this.fobj = fobj; - this.childIter = fobj.getChildren(child); + this.childIter = fobj.getChildNodes(child); getNextCharIter(); } @@ -73,7 +73,7 @@ public class RecursiveCharIterator extends AbstractCharIterator { */ public Object clone() { RecursiveCharIterator ci = (RecursiveCharIterator) super.clone(); - ci.childIter = fobj.getChildren(ci.curChild); + ci.childIter = fobj.getChildNodes(ci.curChild); // Need to advance to the next child, else we get the same one!!! ci.childIter.next(); ci.curCharIter = (CharIterator) curCharIter.clone(); diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index c9e05e192..e57dacd98 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -220,13 +220,13 @@ public class Block extends FObjMixed { */ public void addChildNode(FONode child) { // Handle whitespace based on values of properties - // Handle a sequence of inline-producing children in + // Handle a sequence of inline-producing child nodes in // one pass if (child instanceof FObj && ((FObj) child).generatesInlineAreas()) { if (firstInlineChild == null) { firstInlineChild = child; } - // lastInlineChild = children.size(); + // lastInlineChild = childNodes.size(); } else { // Handle whitespace in preceeding inline areas if any handleWhiteSpace(); diff --git a/src/java/org/apache/fop/fo/flow/ListItemBody.java b/src/java/org/apache/fop/fo/flow/ListItemBody.java index c5fec56dd..4f8460fb8 100644 --- a/src/java/org/apache/fop/fo/flow/ListItemBody.java +++ b/src/java/org/apache/fop/fo/flow/ListItemBody.java @@ -49,7 +49,7 @@ public class ListItemBody extends FObj { * For calculating the lineage - The fo:list-item-body formatting object * does not generate any areas. The fo:list-item-body formatting object * returns the sequence of areas created by concatenating the sequences - * of areas returned by each of the children of the fo:list-item-body. + * of areas returned by each of the child nodes of the fo:list-item-body. */ } diff --git a/src/java/org/apache/fop/fo/flow/ListItemLabel.java b/src/java/org/apache/fop/fo/flow/ListItemLabel.java index fd6c3becb..dca922db4 100644 --- a/src/java/org/apache/fop/fo/flow/ListItemLabel.java +++ b/src/java/org/apache/fop/fo/flow/ListItemLabel.java @@ -61,7 +61,7 @@ public class ListItemLabel extends FObj { * For calculating the lineage - The fo:list-item-label formatting object * does not generate any areas. The fo:list-item-label formatting object * returns the sequence of areas created by concatenating the sequences - * of areas returned by each of the children of the fo:list-item-label. + * of areas returned by each of the child nodes of the fo:list-item-label. */ } diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java index 90e35a593..75364dbc6 100644 --- a/src/java/org/apache/fop/fo/flow/Wrapper.java +++ b/src/java/org/apache/fop/fo/flow/Wrapper.java @@ -26,7 +26,7 @@ import org.apache.fop.fo.FOTreeVisitor; /** * Implementation for fo:wrapper formatting object. * The wrapper object serves as - * a property holder for it's children objects. + * a property holder for its child node objects. * * Content: (#PCDATA|%inline;|%block;)* * Properties: id diff --git a/src/java/org/apache/fop/fo/pagination/Declarations.java b/src/java/org/apache/fop/fo/pagination/Declarations.java index 0a6c6c094..9893d6262 100644 --- a/src/java/org/apache/fop/fo/pagination/Declarations.java +++ b/src/java/org/apache/fop/fo/pagination/Declarations.java @@ -73,8 +73,8 @@ public class Declarations extends FObj { * a hashmap of color profiles and a list of external xml. */ protected void end() { - if (children != null) { - for (Iterator iter = children.iterator(); iter.hasNext();) { + if (childNodes != null) { + for (Iterator iter = childNodes.iterator(); iter.hasNext();) { FONode node = (FONode)iter.next(); if (node.getName().equals("fo:color-profile")) { ColorProfile cp = (ColorProfile)node; @@ -101,7 +101,7 @@ public class Declarations extends FObj { } } } - children = null; + childNodes = null; } public void acceptVisitor(FOTreeVisitor fotv) { diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java index a97cbae1e..ed910bdc1 100644 --- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java +++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java @@ -73,7 +73,7 @@ public class LayoutMasterSet extends FObj { * @see org.apache.fop.fo.FONode#end */ protected void end() { - if (children == null) { + if (childNodes == null) { missingChildElementError("(simple-page-master|page-sequence-master)+"); } } diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java index 53617b602..405cb30e5 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java @@ -80,7 +80,7 @@ public class PageSequenceMaster extends FObj { } protected void end() { - if (children == null) { + if (childNodes == null) { missingChildElementError("(single-page-master-reference|" + "repeatable-page-master-reference|repeatable-page-master-alternatives)+"); } diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java index 701270343..0846f4286 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java @@ -74,7 +74,7 @@ public class RepeatablePageMasterAlternatives extends FObj * @see org.apache.fop.fo.FONode#end */ protected void end() { - if (children == null) { + if (childNodes == null) { missingChildElementError("(conditional-page-master-reference+)"); } } diff --git a/src/java/org/apache/fop/fo/pagination/StaticContent.java b/src/java/org/apache/fop/fo/pagination/StaticContent.java index d0d2b008d..134da935c 100644 --- a/src/java/org/apache/fop/fo/pagination/StaticContent.java +++ b/src/java/org/apache/fop/fo/pagination/StaticContent.java @@ -60,7 +60,7 @@ public class StaticContent extends Flow { * @see org.apache.fop.fo.FONode#end */ protected void end() { - if (children == null) { + if (childNodes == null) { missingChildElementError("(%block;)+"); } getFOInputHandler().endFlow(this); diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java index 468b5bbf9..b25ec4752 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -79,7 +79,7 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants this.fobj = fo; foID = fobj.getID(); markers = fobj.getMarkers(); - childLMiter = new LMiter(this, fobj.getChildren()); + childLMiter = new LMiter(this, fobj.getChildNodes()); } /** diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java index 6b98673ff..d9ebf6294 100644 --- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java +++ b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java @@ -185,10 +185,10 @@ public class AddLMVisitor implements FOTreeVisitor { } public void serveFObjMixed(FObjMixed node) { - if (node.getChildren() != null) { + if (node.getChildNodes() != null) { InlineStackingLayoutManager lm; lm = new InlineStackingLayoutManager(node); - lm.setLMiter(new LMiter(lm, node.getChildren())); + lm.setLMiter(new LMiter(lm, node.getChildNodes())); currentLMList.add(lm); } } @@ -253,7 +253,7 @@ public class AddLMVisitor implements FOTreeVisitor { return area; } }; - lm.setLMiter(new LMiter(lm, node.getChildren())); + lm.setLMiter(new LMiter(lm, node.getChildNodes())); currentLMList.add(lm); } @@ -347,13 +347,13 @@ public class AddLMVisitor implements FOTreeVisitor { leaderArea = fa; } else if (node.getLeaderPattern() == Constants.LeaderPattern.USECONTENT) { - if (node.getChildren() == null) { + if (node.getChildNodes() == null) { node.getLogger().error("Leader use-content with no content"); return null; } InlineStackingLayoutManager lm; lm = new InlineStackingLayoutManager(node); - lm.setLMiter(new LMiter(lm, node.getChildren())); + lm.setLMiter(new LMiter(lm, node.getChildNodes())); lm.initialize(); // get breaks then add areas to FilledArea @@ -479,15 +479,15 @@ public class AddLMVisitor implements FOTreeVisitor { * @return the viewport inline area */ public Viewport getInstreamForeignObjectInlineArea(InstreamForeignObject node) { - if (node.getChildren() == null) { + if (node.getChildNodes() == null) { return null; } - if (node.children.size() != 1) { + if (node.childNodes.size() != 1) { // error return null; } - FONode fo = (FONode)node.children.get(0); + FONode fo = (FONode) node.childNodes.get(0); if (!(fo instanceof XMLObj)) { // error return null; @@ -610,7 +610,7 @@ public class AddLMVisitor implements FOTreeVisitor { org.w3c.dom.Document doc = child.getDOMDocument(); String ns = child.getDocumentNamespace(); - node.children = null; + node.childNodes = null; ForeignObject foreign = new ForeignObject(doc, ns); Viewport areaCurrent = new Viewport(foreign); @@ -894,7 +894,7 @@ public class AddLMVisitor implements FOTreeVisitor { */ public void serveWrapper(Wrapper node) { ListIterator baseIter; - baseIter = node.getChildren(); + baseIter = node.getChildNodes(); if (baseIter == null) return; while (baseIter.hasNext()) { FObj child = (FObj) baseIter.next(); diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java index bf23e5c71..cef51ee01 100644 --- a/src/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java @@ -1231,8 +1231,8 @@ public class RTFHandler extends FOInputHandler { private void recurseFObj(FObj fobj) { invokeDeferredEvent(fobj, true); - if (fobj.children!=null) { - for(Iterator it=fobj.children.iterator();it.hasNext();) { + if (fobj.childNodes != null) { + for(Iterator it=fobj.childNodes.iterator();it.hasNext();) { recurseFObj( (FObj) it.next() ); } } -- 2.39.5