diff options
Diffstat (limited to 'src/org/apache/fop/fo/RecursiveCharIterator.java')
-rw-r--r-- | src/org/apache/fop/fo/RecursiveCharIterator.java | 87 |
1 files changed, 47 insertions, 40 deletions
diff --git a/src/org/apache/fop/fo/RecursiveCharIterator.java b/src/org/apache/fop/fo/RecursiveCharIterator.java index 0cc52152c..c39f886a7 100644 --- a/src/org/apache/fop/fo/RecursiveCharIterator.java +++ b/src/org/apache/fop/fo/RecursiveCharIterator.java @@ -1,3 +1,10 @@ +/* + * $Id$ + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. + */ + package org.apache.fop.fo; import java.util.Iterator; @@ -12,72 +19,72 @@ public class RecursiveCharIterator extends AbstractCharIterator { private FONode curChild; public RecursiveCharIterator(FObj fobj) { - // Set up first child iterator - this.fobj = fobj; - this.childIter = fobj.getChildren(); - getNextCharIter(); + // Set up first child iterator + this.fobj = fobj; + this.childIter = fobj.getChildren(); + getNextCharIter(); } public RecursiveCharIterator(FObj fobj, FONode child) { - // Set up first child iterator - this.fobj = fobj; - this.childIter = fobj.getChildren(child); - getNextCharIter(); + // Set up first child iterator + this.fobj = fobj; + this.childIter = fobj.getChildren(child); + getNextCharIter(); } public CharIterator mark() { - return (CharIterator) this.clone(); + return (CharIterator) this.clone(); } public Object clone() { - RecursiveCharIterator ci = (RecursiveCharIterator)super.clone(); - ci.childIter = fobj.getChildren(ci.curChild); - // Need to advance to the next child, else we get the same one!!! - ci.childIter.next(); - ci.curCharIter = (CharIterator)curCharIter.clone(); - return ci; + RecursiveCharIterator ci = (RecursiveCharIterator) super.clone(); + ci.childIter = fobj.getChildren(ci.curChild); + // Need to advance to the next child, else we get the same one!!! + ci.childIter.next(); + ci.curCharIter = (CharIterator) curCharIter.clone(); + return ci; } public void replaceChar(char c) { - if (curCharIter != null) { - curCharIter.replaceChar(c); - } + if (curCharIter != null) { + curCharIter.replaceChar(c); + } } private void getNextCharIter() { - if (childIter.hasNext()) { - this.curChild = (FONode)childIter.next(); - this.curCharIter = curChild.charIterator(); - } - else { - curChild = null; - curCharIter = null; - } + if (childIter.hasNext()) { + this.curChild = (FONode) childIter.next(); + this.curCharIter = curChild.charIterator(); + } else { + curChild = null; + curCharIter = null; + } } public boolean hasNext() { - while (curCharIter != null) { - if (curCharIter.hasNext()==false) { - getNextCharIter(); - } - else return true; - } - return false; + while (curCharIter != null) { + if (curCharIter.hasNext() == false) { + getNextCharIter(); + } else + return true; + } + return false; } public char nextChar() throws NoSuchElementException { - if (curCharIter != null) { - return curCharIter.nextChar(); - } - else throw new NoSuchElementException(); + if (curCharIter != null) { + return curCharIter.nextChar(); + } else + throw new NoSuchElementException(); } public void remove() { - if (curCharIter != null) { - curCharIter.remove(); - } + if (curCharIter != null) { + curCharIter.remove(); + } } } + |