xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adelme...@apache.org
Subject svn commit: r1066275 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr: KnuthPossPosIter.java PositionIterator.java
Date Tue, 01 Feb 2011 23:46:39 GMT
Author: adelmelle
Date: Tue Feb  1 23:46:38 2011
New Revision: 1066275

URL: http://svn.apache.org/viewvc?rev=1066275&view=rev
Log:
Add type safety to PositionIterator + attempt at javadoc improvement

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PositionIterator.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java?rev=1066275&r1=1066274&r2=1066275&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java Tue Feb
 1 23:46:38 2011
@@ -22,7 +22,8 @@ package org.apache.fop.layoutmgr;
 import java.util.List;
 
 /**
- * A Knuth element position iterator.
+ * A dedicated {@link PositionIterator} that is backed by an iterator
+ * over a list of {@link KnuthElement}s.
  */
 public class KnuthPossPosIter extends PositionIterator {
 
@@ -60,7 +61,7 @@ public class KnuthPossPosIter extends Po
     }
 
     /** {@inheritDoc} */
-    public Object next() {
+    public Position next() {
         --iterCount;
         return super.next();
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PositionIterator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PositionIterator.java?rev=1066275&r1=1066274&r2=1066275&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PositionIterator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PositionIterator.java Tue Feb
 1 23:46:38 2011
@@ -22,20 +22,30 @@ package org.apache.fop.layoutmgr;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
-/** A position iterator. */
-public abstract class PositionIterator implements Iterator {
+/**
+ * An iterator over {@link Position} instances, that is wrapped around
+ * another 'parent' {@link Iterator}. The parent can be either another
+ * {@code PositionIterator}, or an iterator over {@link KnuthElement}s,
+ * for example.<br/>
+ * The {@link #next()} method always returns a {@link Position}. The
+ * protected {@link #getLM(Object)} and {@link #getPos(Object)} methods
+ * must be overridden in subclasses to take care of obtaining the
+ * {@link LayoutManager} or {@link Position} from the object returned
+ * by the parent iterator's {@code next()} method.
+ */
+public abstract class PositionIterator implements Iterator<Position> {
 
     private Iterator parentIter;
     private Object nextObj;
     private LayoutManager childLM;
-    private boolean bHasNext;
+    private boolean hasNext;
 
     /**
      * Construct position iterator.
-     * @param pIter an iterator to use as parent
+     * @param parentIter an iterator to use as parent
      */
-    protected PositionIterator(Iterator pIter) {
-        parentIter = pIter;
+    protected PositionIterator(Iterator parentIter) {
+        this.parentIter = parentIter;
         lookAhead();
         //checkNext();
     }
@@ -45,7 +55,7 @@ public abstract class PositionIterator i
         // Move to next "segment" of iterator, ie: new childLM
         if (childLM == null && nextObj != null) {
             childLM = getLM(nextObj);
-            bHasNext = true;
+            hasNext = true;
         }
         return childLM;
     }
@@ -64,7 +74,7 @@ public abstract class PositionIterator i
 
     private void lookAhead() {
         if (parentIter.hasNext()) {
-            bHasNext = true;
+            hasNext = true;
             nextObj = parentIter.next();
         } else {
             endIter();
@@ -78,7 +88,7 @@ public abstract class PositionIterator i
             childLM = lm;
         } else if (childLM != lm && lm != null) {
             // End of this sub-sequence with same child LM
-            bHasNext = false;
+            hasNext = false;
             childLM = null;
             return false;
         }
@@ -87,23 +97,23 @@ public abstract class PositionIterator i
 
     /** end (reset) iterator */
     protected void endIter() {
-        bHasNext = false;
+        hasNext = false;
         nextObj = null;
         childLM = null;
     }
 
     /** {@inheritDoc} */
     public boolean hasNext() {
-        return (bHasNext && checkNext());
+        return (hasNext && checkNext());
     }
 
 
     /** {@inheritDoc} */
-    public Object next() throws NoSuchElementException {
-        if (bHasNext) {
-            Object retObj = getPos(nextObj);
+    public Position next() throws NoSuchElementException {
+        if (hasNext) {
+            Position retPos = getPos(nextObj);
             lookAhead();
-            return retObj;
+            return retPos;
         } else {
             throw new NoSuchElementException("PosIter");
         }
@@ -119,4 +129,3 @@ public abstract class PositionIterator i
         throw new UnsupportedOperationException("PositionIterator doesn't support remove");
     }
 }
-



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


Mime
View raw message