]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2648: Code cleanup, use foreach
authorSimon Steiner <ssteiner@apache.org>
Fri, 16 Sep 2016 11:40:57 +0000 (11:40 +0000)
committerSimon Steiner <ssteiner@apache.org>
Fri, 16 Sep 2016 11:40:57 +0000 (11:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1761021 13f79535-47bb-0310-9956-ffa450edef68

46 files changed:
fop-core/src/main/java/org/apache/fop/afp/AFPResourceLevelDefaults.java
fop-core/src/main/java/org/apache/fop/afp/DataStream.java
fop-core/src/main/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java
fop-core/src/main/java/org/apache/fop/afp/modca/GraphicsObject.java
fop-core/src/main/java/org/apache/fop/afp/modca/MapCodedFont.java
fop-core/src/main/java/org/apache/fop/afp/modca/MapPageSegment.java
fop-core/src/main/java/org/apache/fop/afp/modca/ResourceGroup.java
fop-core/src/main/java/org/apache/fop/fo/properties/CommonTextDecoration.java
fop-core/src/main/java/org/apache/fop/fonts/apps/PFMReader.java
fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java
fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListObserver.java
fop-core/src/main/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/PageBreaker.java
fop-core/src/main/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
fop-core/src/main/java/org/apache/fop/layoutmgr/table/RowPainter.java
fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java
fop-core/src/main/java/org/apache/fop/pdf/PDFEmbeddedFiles.java
fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java
fop-core/src/main/java/org/apache/fop/render/RendererContext.java
fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java
fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/ActionSet.java
fop-core/src/main/java/org/apache/fop/render/java2d/Java2DRenderer.java
fop-core/src/main/java/org/apache/fop/render/pcl/PCLPageDefinition.java
fop-core/src/main/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java
fop-core/src/main/java/org/apache/fop/render/ps/PSTextPainter.java
fop-core/src/main/java/org/apache/fop/render/ps/ResourceHandler.java
fop-core/src/main/java/org/apache/fop/render/xml/XMLRenderer.java
fop-core/src/main/java/org/apache/fop/tools/fontlist/FontListGenerator.java
fop-core/src/main/java/org/apache/fop/tools/fontlist/FontListMain.java
fop-core/src/main/java/org/apache/fop/tools/fontlist/FontListSerializer.java
fop-core/src/test/java/org/apache/fop/layoutengine/ElementListCheck.java
fop-core/src/test/java/org/apache/fop/memory/Stats.java
fop-core/src/test/java/org/apache/fop/threading/FOPTestbed.java
fop-events/src/main/java/org/apache/fop/events/DefaultEventBroadcaster.java
fop-events/src/main/java/org/apache/fop/events/EventExceptionManager.java
fop-events/src/main/java/org/apache/fop/events/model/EventMethodModel.java
fop-events/src/main/java/org/apache/fop/tools/EventProducerCollectorTask.java
fop-util/src/main/java/org/apache/fop/util/text/AdvancedMessageFormat.java

index 39c72d8f50d72b105c305ca780577adee4caf0aa..f1df49b62697a41c400b888fa1c01eb4b7afe3fe 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.fop.afp;
 
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.fop.afp.AFPResourceLevel.ResourceType;
@@ -99,11 +98,10 @@ public class AFPResourceLevelDefaults {
      * @param other the other instance to get the defaults from
      */
     public void mergeFrom(AFPResourceLevelDefaults other) {
-        Iterator iter = other.defaultResourceLevels.entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry entry = (Map.Entry)iter.next();
-            Byte type = (Byte)entry.getKey();
-            AFPResourceLevel level = (AFPResourceLevel)entry.getValue();
+        for (Object o : other.defaultResourceLevels.entrySet()) {
+            Map.Entry entry = (Map.Entry) o;
+            Byte type = (Byte) entry.getKey();
+            AFPResourceLevel level = (AFPResourceLevel) entry.getValue();
             this.defaultResourceLevels.put(type, level);
         }
     }
index 5244d9212ecb5b6d5f0bb9f11d8cac9962890371..d33673c0e414509bda09b0b79d735f967005e98a 100644 (file)
@@ -24,7 +24,6 @@ import java.awt.Point;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
@@ -309,10 +308,8 @@ public class DataStream {
      *            a collection of AFP font attributes
      */
     public void addFontsToCurrentPage(Map pageFonts) {
-        Iterator iter = pageFonts.values().iterator();
-        while (iter.hasNext()) {
-            AFPFontAttributes afpFontAttributes = (AFPFontAttributes) iter
-                    .next();
+        for (Object o : pageFonts.values()) {
+            AFPFontAttributes afpFontAttributes = (AFPFontAttributes) o;
             createFont(afpFontAttributes.getFontReference(), afpFontAttributes
                     .getFont(), afpFontAttributes.getPointSize());
         }
index 5bd05fd4b9370951e7863e811b2e26a0c702a15c..b3fc8effe8aa98ffcf08f6ff1815737db0af0f8c 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.fop.afp.goca;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.fop.afp.Completable;
@@ -122,20 +121,17 @@ implements StructuredData, Completable, Startable {
      */
     public int getDataLength() {
         int dataLen = 0;
-        Iterator it = objects.iterator();
-        while (it.hasNext()) {
-            dataLen += ((StructuredData)it.next()).getDataLength();
+        for (Object object : objects) {
+            dataLen += ((StructuredData) object).getDataLength();
         }
         return dataLen;
     }
 
     /** {@inheritDoc} */
     public void setComplete(boolean complete) {
-        Iterator it = objects.iterator();
-        while (it.hasNext()) {
-            Object object = it.next();
+        for (Object object : objects) {
             if (object instanceof Completable) {
-                ((Completable)object).setComplete(true);
+                ((Completable) object).setComplete(true);
             }
         }
         this.complete = true;
index 434d4f838a38a7509771699f4385548d2b8cb80f..d7da42cae1e02abf8d9ba531df3867d84236ecc1 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.fop.afp.modca;
 import java.awt.Color;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.xmlgraphics.java2d.color.ColorConverter;
@@ -30,7 +29,6 @@ import org.apache.xmlgraphics.java2d.color.ColorUtil;
 
 import org.apache.fop.afp.AFPDataObjectInfo;
 import org.apache.fop.afp.AFPObjectAreaInfo;
-import org.apache.fop.afp.Completable;
 import org.apache.fop.afp.Factory;
 import org.apache.fop.afp.StructuredData;
 import org.apache.fop.afp.fonts.CharacterSet;
@@ -383,9 +381,7 @@ public class GraphicsObject extends AbstractDataObject {
     /** {@inheritDoc} */
     @Override
     public void setComplete(boolean complete) {
-        Iterator<GraphicsData> it = objects.iterator();
-        while (it.hasNext()) {
-            Completable completedObject = it.next();
+        for (GraphicsData completedObject : objects) {
             completedObject.setComplete(true);
         }
         super.setComplete(complete);
index 38533652c4324c331b30928b2e86b5f26a784e4c..f4224931463aea2f6a5a85d6b2916af48a40075a 100644 (file)
@@ -23,7 +23,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.fop.afp.AFPConstants;
@@ -62,9 +61,8 @@ public class MapCodedFont extends AbstractStructuredObject {
         copySF(startData, Type.MAP, Category.CODED_FONT);
         baos.write(startData);
 
-        Iterator iter = fontList.iterator();
-        while (iter.hasNext()) {
-            FontDefinition fd = (FontDefinition) iter.next();
+        for (Object aFontList : fontList) {
+            FontDefinition fd = (FontDefinition) aFontList;
 
             // Start of repeating groups (occurs 1 to 254)
             baos.write(0x00);
@@ -114,10 +112,10 @@ public class MapCodedFont extends AbstractStructuredObject {
                 baos.write(0x00);
 
                 baos.write(BinaryUtils.convert(fd.scale, 2)); // Height
-                baos.write(new byte[] {0x00, 0x00}); // Width
+                baos.write(new byte[]{0x00, 0x00}); // Width
 
-                baos.write(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                    0x00, 0x00, 0x00, 0x00, 0x00});
+                baos.write(new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                        0x00, 0x00, 0x00, 0x00, 0x00});
 
                 baos.write(0x60);
 
index 81d6f47244f22244e8b03d20fc820cf5bc27c223..85b68c01fe3e3c8a527769a557714342b2bda18e 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.fop.afp.modca;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
 import java.util.Set;
 
 import org.apache.fop.afp.AFPConstants;
@@ -115,17 +114,16 @@ public class MapPageSegment extends AbstractAFPObject {
 
         int pos = 13;
 
-        Iterator iter = this.pageSegments.iterator();
-        while (iter.hasNext()) {
+        for (Object pageSegment : this.pageSegments) {
             pos += 4;
 
-            String name = (String)iter.next();
+            String name = (String) pageSegment;
             try {
                 byte[] nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
                 System.arraycopy(nameBytes, 0, data, pos, nameBytes.length);
             } catch (UnsupportedEncodingException usee) {
                 LOG.error("UnsupportedEncodingException translating the name "
-                    + name);
+                        + name);
             }
             pos += 8;
         }
index 2218998a000395724ff3149ff70916c14108d835..c301557c88a2a3163ac5a627a7dfdba2dee4f0e9 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.afp.modca;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Iterator;
 import java.util.Set;
 
 import org.apache.fop.afp.Streamable;
@@ -83,11 +82,9 @@ public class ResourceGroup extends AbstractNamedAFPObject {
 
     /** {@inheritDoc} */
     public void writeContent(OutputStream os) throws IOException {
-        Iterator it = resourceSet.iterator();
-        while (it.hasNext()) {
-            Object object = it.next();
+        for (Object object : resourceSet) {
             if (object instanceof Streamable) {
-                Streamable streamableObject = (Streamable)object;
+                Streamable streamableObject = (Streamable) object;
                 streamableObject.writeToStream(os);
             }
         }
index 9ce22180eccc278afc5329aaf21d294743348e3e..751a4a711e573070c013e7de171dc7251537a6bb 100644 (file)
@@ -20,7 +20,6 @@
 package org.apache.fop.fo.properties;
 
 import java.awt.Color;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.fop.apps.FOUserAgent;
@@ -74,9 +73,8 @@ public class CommonTextDecoration {
         Property textDecoProp = pList.getExplicit(Constants.PR_TEXT_DECORATION);
         if (textDecoProp != null) {
             List list = textDecoProp.getList();
-            Iterator i = list.iterator();
-            while (i.hasNext()) {
-                Property prop = (Property)i.next();
+            for (Object aList : list) {
+                Property prop = (Property) aList;
                 int propEnum = prop.getEnum();
                 FOUserAgent ua = pList.getFObj() == null ? null : pList.getFObj().getUserAgent();
                 if (propEnum == Constants.EN_NONE) {
index e45b4c2c4346e8fbd8fc94c30fd670fbca105a63..d2e9b7cbd9eed819c6d989198012bdbf3fcc0060 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.fonts.apps;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Iterator;
 import java.util.Map;
 
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -299,18 +298,15 @@ public class PFMReader extends AbstractFontReader {
 
 
         // Get kerning
-        Iterator iter = pfm.getKerning().keySet().iterator();
-        while (iter.hasNext()) {
-            Integer kpx1 = (Integer)iter.next();
+        for (Object kpx1 : pfm.getKerning().keySet()) {
             el = doc.createElement("kerning");
             el.setAttribute("kpx1", kpx1.toString());
             root.appendChild(el);
             Element el2 = null;
 
             Map h2 = (Map) pfm.getKerning().get(kpx1);
-            Iterator enum2 = h2.entrySet().iterator();
-            while (enum2.hasNext()) {
-                Map.Entry entry = (Map.Entry) enum2.next();
+            for (Object o : h2.entrySet()) {
+                Map.Entry entry = (Map.Entry) o;
                 Integer kpx2 = (Integer) entry.getKey();
                 el2 = doc.createElement("pair");
                 el2.setAttribute("kpx2", kpx2.toString());
index cda3ce5ece9a3e679df18700fec4b1a28b6d2cbc..95e2e4cc0dcc2017272d7bb71ef6e8ef42c362fa 100644 (file)
@@ -1636,9 +1636,8 @@ public abstract class OpenFont {
                     Integer cidKey2 = unicodeToGlyph(unicodeKey2);
                     Integer kern = e.getValue();
 
-                    Iterator uniMap = mtxTab[cidKey2].getUnicodeIndex().listIterator();
-                    while (uniMap.hasNext()) {
-                        Integer unicodeKey = (Integer)uniMap.next();
+                    for (Object o : mtxTab[cidKey2].getUnicodeIndex()) {
+                        Integer unicodeKey = (Integer) o;
                         Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey);
                         for (Integer ansiKey : ansiKeys) {
                             akpx.put(ansiKey, kern);
@@ -1647,9 +1646,8 @@ public abstract class OpenFont {
                 }
 
                 if (akpx.size() > 0) {
-                    Iterator uniMap = mtxTab[cidKey1].getUnicodeIndex().listIterator();
-                    while (uniMap.hasNext()) {
-                        Integer unicodeKey = (Integer)uniMap.next();
+                    for (Object o : mtxTab[cidKey1].getUnicodeIndex()) {
+                        Integer unicodeKey = (Integer) o;
                         Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey);
                         for (Integer ansiKey : ansiKeys) {
                             ansiKerningTab.put(ansiKey, akpx);
index 3a73b233b233e70720dc72820f305d70b2b9f89f..a1e888116119a5d12104fc42313976f9746e23ae 100644 (file)
@@ -282,9 +282,8 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager im
         if (newLMs == null || newLMs.size() == 0) {
             return;
         }
-        ListIterator<LayoutManager> iter = newLMs.listIterator();
-        while (iter.hasNext()) {
-            addChildLM(iter.next());
+        for (LayoutManager newLM : (Iterable<LayoutManager>) newLMs) {
+            addChildLM(newLM);
         }
     }
 
index 17cdd1462d2eb8e0dbb3efe7d3dc34362b4786ff..8108cda7e8eb444f758c7ae0cfbfecf67ff6715d 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.fop.layoutmgr;
 
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -67,9 +66,8 @@ public final class ElementListObserver {
             if (category == null) {
                 throw new NullPointerException("category must not be null");
             }
-            Iterator i = activeObservers.iterator();
-            while (i.hasNext()) {
-                ((Observer)i.next()).observe(elementList, category, id);
+            for (Object activeObserver : activeObservers) {
+                ((Observer) activeObserver).observe(elementList, category, id);
             }
         }
     }
index 99f6367a35f05bd9b94d9cfb4a079392eb720593..1ac70da82bbec83687e48941e5a34a027b1b15b8 100644 (file)
@@ -349,9 +349,8 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
 
         // "wrap" the Position stored in each element of returnedList
         // and add elements to returnList
-        ListIterator<KnuthElement> listIter = returnedList.listIterator();
-        while (listIter.hasNext()) {
-            returnedElement = listIter.next();
+        for (KnuthElement aReturnedList : returnedList) {
+            returnedElement = aReturnedList;
             if (returnedElement.getLayoutManager() != this) {
                 returnedElement.setPosition(
                         new NonLeafPosition(this, returnedElement.getPosition()));
index 8cc9db7907e8924df457cd7bbf8b6055d1e01ece..9c1315640da483bafce458028d158be9655d364d 100644 (file)
@@ -23,7 +23,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import java.util.ListIterator;
 
 import org.apache.fop.area.Block;
 import org.apache.fop.area.BodyRegion;
@@ -184,11 +183,10 @@ public class PageBreaker extends AbstractBreaker {
     private boolean containsFootnotes(List contentList, LayoutContext context) {
         boolean containsFootnotes = false;
         if (contentList != null) {
-            ListIterator contentListIterator = contentList.listIterator();
-            while (contentListIterator.hasNext()) {
-                ListElement element = (ListElement) contentListIterator.next();
+            for (Object aContentList : contentList) {
+                ListElement element = (ListElement) aContentList;
                 if (element instanceof KnuthBlockBox
-                    && ((KnuthBlockBox) element).hasAnchors()) {
+                        && ((KnuthBlockBox) element).hasAnchors()) {
                     // element represents a line with footnote citations
                     containsFootnotes = true;
                     KnuthBlockBox box = (KnuthBlockBox) element;
index c5031cd0f3304a5bc97c06bbc29526681aba51a3..af166498100e4390774a2128423fe21aaf78b90b 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.fop.layoutmgr.inline;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.ListIterator;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -130,9 +129,8 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
         stackSize = 0;
 
         List contentList = getNextKnuthElements(childLC, Constants.EN_START);
-        ListIterator contentIter = contentList.listIterator();
-        while (contentIter.hasNext()) {
-            KnuthElement element = (KnuthElement) contentIter.next();
+        for (Object aContentList : contentList) {
+            KnuthElement element = (KnuthElement) aContentList;
             if (element instanceof KnuthInlineBox) {
                 KnuthInlineBox box = (KnuthInlineBox) element;
                 // TODO handle alignment here?
@@ -245,9 +243,8 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
         if (newLMs == null || newLMs.size() == 0) {
             return;
         }
-        ListIterator iter = newLMs.listIterator();
-        while (iter.hasNext()) {
-            LayoutManager lm = (LayoutManager) iter.next();
+        for (Object newLM : newLMs) {
+            LayoutManager lm = (LayoutManager) newLM;
             addChildLM(lm);
         }
     }
index 0a0658b4d5a3423be69bff88c854faf517ba4844..df37b9902c48fc8276b3cd7c01a341158e78bd31 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.fop.layoutmgr.inline;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.ListIterator;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -341,9 +340,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
             if (curLM instanceof InlineLevelLayoutManager) {
                 context.clearKeepWithNextPending();
                 // "wrap" the Position stored in each element of returnedList
-                ListIterator seqIter = returnedList.listIterator();
-                while (seqIter.hasNext()) {
-                    KnuthSequence sequence = (KnuthSequence) seqIter.next();
+                for (KnuthSequence sequence : returnedList) {
                     sequence.wrapPositions(this);
                 }
                 int insertionStartIndex = 0;
index 5e3820a4b4199f661b7f1c82501d708dd84e4bf2..5b9efa43ee65b8103efeb6550b987daeb6616889 100644 (file)
@@ -377,11 +377,10 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
 
         // this is a new list
         // "wrap" the Position stored in each element of returnedList
-        ListIterator listIter = returnedList.listIterator();
-        while (listIter.hasNext()) {
-            returnedElement = (KnuthElement) listIter.next();
+        for (Object aReturnedList : returnedList) {
+            returnedElement = (KnuthElement) aReturnedList;
             returnedElement.setPosition(
-                notifyPos(new NonLeafPosition(this, returnedElement.getPosition())));
+                    notifyPos(new NonLeafPosition(this, returnedElement.getPosition())));
             returnList.add(returnedElement);
         }
 
index 41f0cd5a4667895e15c5bddf48afdf0b188cbc37..40c7703ae2513a917a756b3ec9fc1d90aa883fff 100644 (file)
@@ -729,9 +729,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
             }
 
             // loop over the KnuthSequences (and single KnuthElements) in returnedList
-            ListIterator iter = inlineElements.listIterator();
-            while (iter.hasNext()) {
-                KnuthSequence sequence = (KnuthSequence) iter.next();
+            for (Object inlineElement : inlineElements) {
+                KnuthSequence sequence = (KnuthSequence) inlineElement;
                 // the sequence contains inline Knuth elements
                 if (sequence.isInlineSequence()) {
                     // look at the last element
@@ -745,9 +744,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager
                     // else this is the last paragraph
                     if (lastPar == null) {
                         lastPar = new Paragraph(this,
-                                                textAlignment, textAlignmentLast,
-                                                textIndent.getValue(this),
-                                                lastLineEndIndent.getValue(this));
+                                textAlignment, textAlignmentLast,
+                                textIndent.getValue(this),
+                                lastLineEndIndent.getValue(this));
                         lastPar.startSequence();
                         if (log.isTraceEnabled()) {
                             trace.append(" [");
@@ -765,7 +764,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
                     // finish last paragraph if it was closed with a linefeed
                     if (lastElement.isPenalty()
                             && ((KnuthPenalty) lastElement).getPenalty()
-                                == -KnuthPenalty.INFINITE) {
+                            == -KnuthPenalty.INFINITE) {
                         // a penalty item whose value is -inf
                         // represents a preserved linefeed,
                         // which forces a line break
@@ -938,10 +937,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager
 
             if (!seq.isInlineSequence()) {
                 List<ListElement> targetList = new LinkedList<ListElement>();
-                ListIterator listIter = seq.listIterator();
-                while (listIter.hasNext()) {
+                for (Object aSeq : seq) {
                     ListElement tempElement;
-                    tempElement = (ListElement) listIter.next();
+                    tempElement = (ListElement) aSeq;
                     LayoutManager lm = tempElement.getLayoutManager();
                     if (baselineOffset < 0 && lm != null && lm.hasLineAreaDescendant()) {
                         baselineOffset = lm.getBaselineOffset();
index 638460866aa9a0b6b0623e3d6d30f89eb67adc66..ab7d0c01a4f85df2ff73a5ffa27b0be27698450b 100644 (file)
@@ -1115,9 +1115,8 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
             int oldIndex = -1;
             int changeIndex;
             PendingChange currChange;
-            ListIterator changeListIterator = changeList.listIterator();
-            while (changeListIterator.hasNext()) {
-                currChange = (PendingChange) changeListIterator.next();
+            for (Object aChangeList : changeList) {
+                currChange = (PendingChange) aChangeList;
                 if (currChange.index == oldIndex) {
                     mappingsAdded++;
                     changeIndex = currChange.index + mappingsAdded - mappingsRemoved;
index 46a93b3f51be3ed649284f0dc2e248f7f8eaca66..094caaf3db8ba77888815ddaadc47759e621b04a 100644 (file)
@@ -563,9 +563,8 @@ public class ListItemLayoutManager extends SpacedBorderedPaddedBlockLayoutManage
         List tempList = returnedList;
         KnuthElement tempElement;
         returnedList = new LinkedList();
-        ListIterator listIter = tempList.listIterator();
-        while (listIter.hasNext()) {
-            tempElement = (KnuthElement)listIter.next();
+        for (Object aTempList : tempList) {
+            tempElement = (KnuthElement) aTempList;
             tempElement.setPosition(new NonLeafPosition(this, tempElement.getPosition()));
             returnedList.add(tempElement);
         }
index 35e8c0c4fc5707cab823e16ff55debc8826b3753..1835d05477f5549cdfcb356efe6c481032b54851 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.layoutmgr.table;
 
 import java.util.Iterator;
 import java.util.List;
-import java.util.ListIterator;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -68,9 +67,8 @@ public class ColumnSetup {
         List rawCols = table.getColumns();
         if (rawCols != null) {
             int colnum = 1;
-            ListIterator iter = rawCols.listIterator();
-            while (iter.hasNext()) {
-                TableColumn col = (TableColumn)iter.next();
+            for (Object rawCol : rawCols) {
+                TableColumn col = (TableColumn) rawCol;
                 if (col == null) {
                     continue;
                 }
@@ -86,9 +84,8 @@ public class ColumnSetup {
             //Post-processing the list (looking for gaps)
             //TODO The following block could possibly be removed
             int pos = 1;
-            ListIterator ppIter = columns.listIterator();
-            while (ppIter.hasNext()) {
-                TableColumn col = (TableColumn)ppIter.next();
+            for (Object column : columns) {
+                TableColumn col = (TableColumn) column;
                 if (col == null) {
                     assert false; //Gaps are filled earlier by fo.flow.table.Table.finalizeColumns()
                     //log.error("Found a gap in the table-columns at position " + pos);
index 85c016537c3caac7955970904c7ba47ed71255b2..cbc19c1ecff927430c52cf5de7b871f5e507598c 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.layoutmgr.table;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
 
@@ -166,10 +165,9 @@ class RowPainter {
                 firstRowOnPageIndex = firstRowIndex;
             }
         }
-        Iterator partIter = tcpos.cellParts.iterator();
         //Iterate over all grid units in the current step
-        while (partIter.hasNext()) {
-            CellPart cellPart = (CellPart)partIter.next();
+        for (Object cellPart1 : tcpos.cellParts) {
+            CellPart cellPart = (CellPart) cellPart1;
             if (log.isDebugEnabled()) {
                 log.debug(">" + cellPart);
             }
index 9458793c71506beb69a2f254c3759b6084d8db04..4940c66b2838f3856eda5cf22c8010933c62ec25 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.layoutmgr.table;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -272,9 +271,8 @@ public class TableLayoutManager extends SpacedBorderedPaddedBlockLayoutManager
 
         contentKnuthElements = contentLM.getNextKnuthElements(childLC, alignment);
         //Set index values on elements coming from the content LM
-        Iterator iter = contentKnuthElements.iterator();
-        while (iter.hasNext()) {
-            ListElement el = (ListElement)iter.next();
+        for (Object contentKnuthElement : contentKnuthElements) {
+            ListElement el = (ListElement) contentKnuthElement;
             notifyPos(el.getPosition());
         }
         log.debug(contentKnuthElements);
index 59ff9c988c7657eed79de2ac2804d766c7e3d7be..f5b886bc6d726fed7b41d581d1cfb33ec04d1d2e 100644 (file)
@@ -29,7 +29,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -742,9 +741,7 @@ public class PDFDocument {
      */
     protected PDFGState findGState(PDFGState wanted, PDFGState current) {
         PDFGState poss;
-        Iterator<PDFGState> iter = this.gstates.iterator();
-        while (iter.hasNext()) {
-            PDFGState avail = iter.next();
+        for (PDFGState avail : this.gstates) {
             poss = new PDFGState();
             poss.addValues(current);
             poss.addValues(avail);
index c4979312e94fdc42ebefd7467a51d2ffbae56baf..d929f80d44fa9dd93b1bfa5c93658e6d2c32db8b 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.pdf;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.SortedMap;
 
@@ -54,9 +53,8 @@ public class PDFEmbeddedFiles extends PDFNameTreeNode {
             map.put(key, value);
         }
         names.clear();
-        Iterator iter = map.entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry entry = (Map.Entry)iter.next();
+        for (Object o : map.entrySet()) {
+            Map.Entry entry = (Map.Entry) o;
             names.add(entry.getKey());
             names.add(entry.getValue());
         }
index bdfb2a94da3f3b362f347389df34ad18244403cd..09debe179a08d06428eeae6f75e2b817ab7df727 100644 (file)
@@ -29,7 +29,6 @@ import java.text.DecimalFormat;
 import java.util.Arrays;
 import java.util.BitSet;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.SortedSet;
@@ -436,9 +435,8 @@ public class PDFFactory {
         if (deep) {
             dests = new PDFDests();
             PDFArray kids = new PDFArray(dests);
-            Iterator iter = destinationList.iterator();
-            while (iter.hasNext()) {
-                PDFDestination dest = (PDFDestination)iter.next();
+            for (Object aDestinationList : destinationList) {
+                PDFDestination dest = (PDFDestination) aDestinationList;
                 PDFNameTreeNode node = new PDFNameTreeNode();
                 getDocument().registerObject(node);
                 node.setLowerLimit(dest.getIDRef());
index c7f13eefa7fcb7cf3e1e4a53c8b86bf9c84faa38..ba95297f11054e38490df4623abbe39577d1ad99 100644 (file)
@@ -20,7 +20,6 @@
 package org.apache.fop.render;
 
 //Java
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.fop.apps.FOUserAgent;
@@ -117,9 +116,8 @@ public class RendererContext {
     /** {@inheritDoc} **/
     public String toString() {
         StringBuffer stringBuffer = new StringBuffer("RendererContext{\n");
-        Iterator it = props.keySet().iterator();
-        while (it.hasNext()) {
-            String key = (String)it.next();
+        for (Object o : props.keySet()) {
+            String key = (String) o;
             Object value = props.get(key);
             stringBuffer.append("\t" + key + "=" + value + "\n");
         }
index 91290c481c60831d90b372e8f0697b17e95e9dd7..eb8c4bc2f4618eb92890acc20655ec76eef4b6c5 100644 (file)
@@ -486,10 +486,9 @@ implements IFConstants, IFPainter, IFDocumentNavigationHandler {
     private void addForeignAttributes(AttributesImpl atts) throws SAXException {
         Map foreignAttributes = getContext().getForeignAttributes();
         if (!foreignAttributes.isEmpty()) {
-            Iterator iter = foreignAttributes.entrySet().iterator();
-            while (iter.hasNext()) {
-                Map.Entry entry = (Map.Entry)iter.next();
-                addAttribute(atts, (QName)entry.getKey(), entry.getValue().toString());
+            for (Object o : foreignAttributes.entrySet()) {
+                Map.Entry entry = (Map.Entry) o;
+                addAttribute(atts, (QName) entry.getKey(), entry.getValue().toString());
             }
         }
     }
@@ -857,9 +856,8 @@ implements IFConstants, IFPainter, IFDocumentNavigationHandler {
         AttributesImpl atts = new AttributesImpl();
         try {
             handler.startElement(DocumentNavigationExtensionConstants.BOOKMARK_TREE, atts);
-            Iterator iter = tree.getBookmarks().iterator();
-            while (iter.hasNext()) {
-                Bookmark b = (Bookmark)iter.next();
+            for (Object o : tree.getBookmarks()) {
+                Bookmark b = (Bookmark) o;
                 if (b.getAction() != null) {
                     serializeBookmark(b);
                 }
@@ -879,9 +877,8 @@ implements IFConstants, IFPainter, IFDocumentNavigationHandler {
                 XMLUtil.CDATA, bookmark.isShown() ? "show" : "hide");
         handler.startElement(DocumentNavigationExtensionConstants.BOOKMARK, atts);
         serializeXMLizable(bookmark.getAction());
-        Iterator iter = bookmark.getChildBookmarks().iterator();
-        while (iter.hasNext()) {
-            Bookmark b = (Bookmark)iter.next();
+        for (Object o : bookmark.getChildBookmarks()) {
+            Bookmark b = (Bookmark) o;
             if (b.getAction() != null) {
                 serializeBookmark(b);
             }
index 080a33a8114424027bab7a7613de54d0ad678fb8..d460527beae71c1adb35f4590484720ae565f3f2 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.fop.render.intermediate.extensions;
 
-import java.util.Iterator;
 import java.util.Map;
 
 /**
@@ -80,9 +79,8 @@ public class ActionSet {
     }
 
     private AbstractAction normalize(AbstractAction action) {
-        Iterator iter = this.actionRegistry.values().iterator();
-        while (iter.hasNext()) {
-            AbstractAction a = (AbstractAction)iter.next();
+        for (Object o : this.actionRegistry.values()) {
+            AbstractAction a = (AbstractAction) o;
             if (a.isSame(action)) {
                 return a;
             }
index 75957c396494a27fcba0f7c6513c1c943e9956c4..b12d708ba7e0a94dadb0225ae9953ed2a32db35c 100644 (file)
@@ -39,7 +39,6 @@ import java.awt.print.PrinterException;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Stack;
@@ -63,7 +62,6 @@ import org.apache.fop.area.CTM;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.area.Trait;
 import org.apache.fop.area.inline.Image;
-import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.Leader;
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
@@ -497,9 +495,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
     protected void restoreStateStackAfterBreakOut(List breakOutList) {
         log.debug("Block.FIXED --> restoring context after break-out");
 
-        Iterator it = breakOutList.iterator();
-        while (it.hasNext()) {
-            Java2DGraphicsState s = (Java2DGraphicsState)it.next();
+        for (Object aBreakOutList : breakOutList) {
+            Java2DGraphicsState s = (Java2DGraphicsState) aBreakOutList;
             stateStack.push(state);
             this.state = s;
         }
@@ -761,11 +758,9 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
 
         float textCursor = 0;
 
-        Iterator iter = text.getChildAreas().iterator();
-        while (iter.hasNext()) {
-            InlineArea child = (InlineArea)iter.next();
+        for (Object child : text.getChildAreas()) {
             if (child instanceof WordArea) {
-                WordArea word = (WordArea)child;
+                WordArea word = (WordArea) child;
                 String s = word.getWord();
                 int[] letterAdjust = word.getLetterAdjustArray();
                 GlyphVector gv = g2d.getFont().createGlyphVector(g2d.getFontRenderContext(), s);
@@ -788,12 +783,12 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
                 g2d.drawGlyphVector(gv, textCursor, 0);
                 textCursor += gv.getLogicalBounds().getWidth() + additionalWidth;
             } else if (child instanceof SpaceArea) {
-                SpaceArea space = (SpaceArea)child;
+                SpaceArea space = (SpaceArea) child;
                 String s = space.getSpace();
                 char sp = s.charAt(0);
                 int tws = (space.isAdjustable()
                         ? text.getTextWordSpaceAdjust()
-                                + 2 * text.getTextLetterSpaceAdjust()
+                        + 2 * text.getTextLetterSpaceAdjust()
                         : 0);
 
                 textCursor += (font.getCharWidth(sp) + tws) / 1000f;
index 3e577cfa0bb0112fb899f66bbe01c524bb1b0bbc..a07a1a503cba27db642cd766af94691c5652ba65 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.render.pcl;
 
 import java.awt.Dimension;
 import java.awt.Rectangle;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.xmlgraphics.util.UnitConv;
@@ -104,9 +103,8 @@ public class PCLPageDefinition {
      * @return the page definition or null if no match was found
      */
     public static PCLPageDefinition getPageDefinition(long width, long height, int errorMargin) {
-        Iterator iter = pageDefinitions.iterator();
-        while (iter.hasNext()) {
-            PCLPageDefinition def = (PCLPageDefinition)iter.next();
+        for (Object pageDefinition : pageDefinitions) {
+            PCLPageDefinition def = (PCLPageDefinition) pageDefinition;
             if (def.matches(width, height, errorMargin)) {
                 return def;
             }
@@ -120,9 +118,8 @@ public class PCLPageDefinition {
      * @return the page definition or null if no match was found
      */
     public static PCLPageDefinition getPageDefinition(String name) {
-        Iterator iter = pageDefinitions.iterator();
-        while (iter.hasNext()) {
-            PCLPageDefinition def = (PCLPageDefinition)iter.next();
+        for (Object pageDefinition : pageDefinitions) {
+            PCLPageDefinition def = (PCLPageDefinition) pageDefinition;
             if (def.getName().equalsIgnoreCase(name)) {
                 return def;
             }
index cb9f43fa946829b14377eeceb036551b1885ff52..8ffd817aaa0b46da92fd4e344455e71a7e14fc1e 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.fop.render.pdf;
 import java.awt.Rectangle;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.fop.pdf.PDFAction;
@@ -76,9 +75,8 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler
 
     /** {@inheritDoc} */
     public void renderBookmarkTree(BookmarkTree tree) throws IFException {
-        Iterator iter = tree.getBookmarks().iterator();
-        while (iter.hasNext()) {
-            Bookmark b = (Bookmark)iter.next();
+        for (Object o : tree.getBookmarks()) {
+            Bookmark b = (Bookmark) o;
             renderBookmark(b, null);
         }
     }
@@ -91,9 +89,8 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler
         PDFReference actionRef = (action != null ? action.makeReference() : null);
         PDFOutline pdfOutline = getPDFDoc().getFactory().makeOutline(parent,
             bookmark.getTitle(), actionRef, bookmark.isShown());
-        Iterator iter = bookmark.getChildBookmarks().iterator();
-        while (iter.hasNext()) {
-            Bookmark b = (Bookmark)iter.next();
+        for (Object o : bookmark.getChildBookmarks()) {
+            Bookmark b = (Bookmark) o;
             renderBookmark(b, pdfOutline);
         }
     }
index 189a6bd8fb87368718e9f9bb735fde89bc203fcf..eb726c9402088b51240c1ed39e1f006a93e94897 100644 (file)
@@ -358,9 +358,7 @@ public class PSTextPainter extends NativeTextPainter {
             if (x || y) {
                 sb.append("\n[");
                 int idx = 0;
-                Iterator<Point2D> iter = this.relativePositions.iterator();
-                while (iter.hasNext()) {
-                    Point2D pt = iter.next();
+                for (Point2D pt : this.relativePositions) {
                     if (idx > 0) {
                         if (x) {
                             sb.append(format(gen, pt.getX()));
index a12ae5a491cdd58cfb749f8e4ae421e4c24c6b3c..42eea5dfd8e84e813456c82eda84320a0094194e 100644 (file)
@@ -23,7 +23,6 @@ import java.awt.geom.Rectangle2D;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
@@ -117,10 +116,9 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
         if (formResources == null) {
             return;
         }
-        Iterator iter = formResources.entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry entry = (Map.Entry)iter.next();
-            PSResource res = (PSResource)entry.getValue();
+        for (Object o : formResources.entrySet()) {
+            Map.Entry entry = (Map.Entry) o;
+            PSResource res = (PSResource) entry.getValue();
             long count = resTracker.getUsageCount(res);
             if (count > 1) {
                 //Make global form
@@ -264,9 +262,8 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
         if (formResources == null) {
             return;
         }
-        Iterator iter = formResources.values().iterator();
-        while (iter.hasNext()) {
-            PSImageFormResource form = (PSImageFormResource)iter.next();
+        for (Object o : formResources.values()) {
+            PSImageFormResource form = (PSImageFormResource) o;
             resTracker.registerSuppliedResource(form);
         }
     }
@@ -275,9 +272,8 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors {
         if (formResources == null) {
             return;
         }
-        Iterator iter = formResources.values().iterator();
-        while (iter.hasNext()) {
-            PSImageFormResource form = (PSImageFormResource)iter.next();
+        for (Object o : formResources.values()) {
+            PSImageFormResource form = (PSImageFormResource) o;
             generateFormForImage(gen, form);
         }
     }
index e1a1233223493dc3bdef3a5df147ab71682d6bf8..ffe16f2caedcbaf86196405e73428fa494a69de6 100644 (file)
@@ -192,9 +192,8 @@ public class XMLRenderer extends AbstractXMLRenderer {
     protected void addTraitAttributes(Area area) {
         Map traitMap = area.getTraits();
         if (traitMap != null) {
-            Iterator iter = traitMap.entrySet().iterator();
-            while (iter.hasNext()) {
-                Map.Entry traitEntry = (Map.Entry) iter.next();
+            for (Object o : traitMap.entrySet()) {
+                Map.Entry traitEntry = (Map.Entry) o;
                 Object key = traitEntry.getKey();
                 String name = Trait.getTraitName(key);
                 Class clazz = Trait.getTraitClass(key);
@@ -203,15 +202,15 @@ public class XMLRenderer extends AbstractXMLRenderer {
                 }
                 Object value = traitEntry.getValue();
                 if (((Integer) key).intValue() == Trait.FONT) {
-                    FontTriplet triplet = (FontTriplet)value;
+                    FontTriplet triplet = (FontTriplet) value;
                     addAttribute("font-name", triplet.getName());
                     addAttribute("font-style", triplet.getStyle());
                     addAttribute("font-weight", triplet.getWeight());
                 } else if (clazz.equals(InternalLink.class)) {
-                    InternalLink iLink = (InternalLink)value;
+                    InternalLink iLink = (InternalLink) value;
                     addAttribute(name, iLink.xmlAttribute());
                 } else if (clazz.equals(Background.class)) {
-                    Background bkg = (Background)value;
+                    Background bkg = (Background) value;
                     //TODO Remove the following line (makes changes in the test checks necessary)
                     addAttribute(name, bkg.toString());
                     if (bkg.getColor() != null) {
@@ -222,28 +221,28 @@ public class XMLRenderer extends AbstractXMLRenderer {
                         String repString;
                         int repeat = bkg.getRepeat();
                         switch (repeat) {
-                        case Constants.EN_REPEAT:
-                            repString = "repeat";
-                            break;
-                        case Constants.EN_REPEATX:
-                            repString = "repeat-x";
-                            break;
-                        case Constants.EN_REPEATY:
-                            repString = "repeat-y";
-                            break;
-                        case Constants.EN_NOREPEAT:
-                            repString = "no-repeat";
-                            break;
-                        default:
-                            throw new IllegalStateException(
-                                    "Illegal value for repeat encountered: " + repeat);
+                            case Constants.EN_REPEAT:
+                                repString = "repeat";
+                                break;
+                            case Constants.EN_REPEATX:
+                                repString = "repeat-x";
+                                break;
+                            case Constants.EN_REPEATY:
+                                repString = "repeat-y";
+                                break;
+                            case Constants.EN_NOREPEAT:
+                                repString = "no-repeat";
+                                break;
+                            default:
+                                throw new IllegalStateException(
+                                        "Illegal value for repeat encountered: " + repeat);
                         }
                         addAttribute("bkg-repeat", repString);
                         addAttribute("bkg-horz-offset", bkg.getHoriz());
                         addAttribute("bkg-vert-offset", bkg.getVertical());
                     }
                 } else if (clazz.equals(Color.class)) {
-                    Color c = (Color)value;
+                    Color c = (Color) value;
                     addAttribute(name, ColorUtil.colorToString(c));
                 } else if (((Integer) key).intValue() == Trait.START_INDENT
                         || ((Integer) key).intValue() == Trait.END_INDENT) {
@@ -429,12 +428,11 @@ public class XMLRenderer extends AbstractXMLRenderer {
     protected void handleExtensionAttachments(List attachments) {
         if (attachments != null && attachments.size() > 0) {
             startElement("extension-attachments");
-            Iterator i = attachments.iterator();
-            while (i.hasNext()) {
-                ExtensionAttachment attachment = (ExtensionAttachment)i.next();
+            for (Object attachment1 : attachments) {
+                ExtensionAttachment attachment = (ExtensionAttachment) attachment1;
                 if (attachment instanceof XMLizable) {
                     try {
-                        ((XMLizable)attachment).toSAX(this.handler);
+                        ((XMLizable) attachment).toSAX(this.handler);
                     } catch (SAXException e) {
                         log.error("Error while serializing Extension Attachment", e);
                     }
index 0f3f737f7f5452f2644149ca44d6e614235df09f..dff9564450c4d06acedb447f9b28d037a0393ddf 100644 (file)
@@ -19,8 +19,8 @@
 
 package org.apache.fop.tools.fontlist;
 
+import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -81,31 +81,30 @@ public class FontListGenerator {
         SortedMap fontFamilies = new java.util.TreeMap();
         //SortedMap<String/font-family, List<FontSpec>>
 
-        Iterator iter = fontInfo.getFontTriplets().entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry entry = (Map.Entry)iter.next();
-            FontTriplet triplet = (FontTriplet)entry.getKey();
-            String key = (String)entry.getValue();
+        for (Object o : fontInfo.getFontTriplets().entrySet()) {
+            Map.Entry entry = (Map.Entry) o;
+            FontTriplet triplet = (FontTriplet) entry.getKey();
+            String key = (String) entry.getValue();
             FontSpec container;
             if (keyBag.contains(key)) {
                 keyBag.remove(key);
 
-                FontMetrics metrics = (FontMetrics)fonts.get(key);
+                FontMetrics metrics = (FontMetrics) fonts.get(key);
 
                 container = new FontSpec(key, metrics);
                 container.addFamilyNames(metrics.getFamilyNames());
                 keys.put(key, container);
-                String firstFamilyName = (String)container.getFamilyNames().first();
-                List containers = (List)fontFamilies.get(firstFamilyName);
+                String firstFamilyName = (String) container.getFamilyNames().first();
+                List containers = (List) fontFamilies.get(firstFamilyName);
                 if (containers == null) {
-                    containers = new java.util.ArrayList();
+                    containers = new ArrayList();
                     fontFamilies.put(firstFamilyName, containers);
                 }
                 containers.add(container);
                 Collections.sort(containers);
 
             } else {
-                container = (FontSpec)keys.get(key);
+                container = (FontSpec) keys.get(key);
             }
             container.addTriplet(triplet);
         }
index dcc1f57856f268a4f3ec02b337ae20ff2542e033..adb5aa36e06964916bbd12a4e479d2cf4fd310b8 100644 (file)
@@ -177,9 +177,8 @@ public final class FontListMain {
             sb.append(':');
             sb.append('\n');
             List list = (List)entry.getValue();
-            Iterator fonts = list.iterator();
-            while (fonts.hasNext()) {
-                FontSpec f = (FontSpec)fonts.next();
+            for (Object aList : list) {
+                FontSpec f = (FontSpec) aList;
                 sb.append("  ");
                 sb.append(f.getKey());
                 sb.append(' ');
@@ -194,9 +193,8 @@ public final class FontListMain {
                     }
                 }
                 sb.append('\n');
-                Iterator triplets = f.getTriplets().iterator();
-                while (triplets.hasNext()) {
-                    FontTriplet triplet = (FontTriplet)triplets.next();
+                for (Object o : f.getTriplets()) {
+                    FontTriplet triplet = (FontTriplet) o;
                     sb.append("    ");
                     sb.append(triplet.toString());
                     sb.append('\n');
@@ -211,24 +209,23 @@ public final class FontListMain {
             throws TransformerConfigurationException, SAXException, IOException {
         if (this.outputFile.isDirectory()) {
             System.out.println("Creating one file for each family...");
-            Iterator iter = fontFamilies.entrySet().iterator();
-            while (iter.hasNext()) {
-                Map.Entry entry = (Map.Entry)iter.next();
-                String familyName = (String)entry.getKey();
+            for (Object o : fontFamilies.entrySet()) {
+                Map.Entry entry = (Map.Entry) o;
+                String familyName = (String) entry.getKey();
                 System.out.println("Creating output file for " + familyName + "...");
                 String filename;
-                switch(this.mode) {
-                case GENERATE_RENDERED:
-                    filename = familyName + ".pdf";
-                    break;
-                case GENERATE_FO:
-                    filename = familyName + ".fo";
-                    break;
-                case GENERATE_XML:
-                    filename = familyName + ".xml";
-                    break;
-                default:
-                    throw new IllegalStateException("Unsupported mode");
+                switch (this.mode) {
+                    case GENERATE_RENDERED:
+                        filename = familyName + ".pdf";
+                        break;
+                    case GENERATE_FO:
+                        filename = familyName + ".fo";
+                        break;
+                    case GENERATE_XML:
+                        filename = familyName + ".xml";
+                        break;
+                    default:
+                        throw new IllegalStateException("Unsupported mode");
                 }
                 File outFile = new File(this.outputFile, filename);
                 generateXML(fontFamilies, outFile, familyName);
index 3b3d1324546cd38c9845fef4d2e7b12df590bc22..931cf6c2863fc4d6b6326673d1d2026ff0fd2601 100644 (file)
@@ -20,7 +20,6 @@
 package org.apache.fop.tools.fontlist;
 
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.SortedMap;
@@ -77,10 +76,9 @@ public class FontListSerializer {
         AttributesImpl atts = new AttributesImpl();
         handler.startElement(FONTS, atts);
 
-        Iterator iter = fontFamilies.entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry entry = (Map.Entry)iter.next();
-            String familyName = (String)entry.getKey();
+        for (Object o : fontFamilies.entrySet()) {
+            Map.Entry entry = (Map.Entry) o;
+            String familyName = (String) entry.getKey();
             if (singleFamily != null && !singleFamily.equals(familyName)) {
                 continue;
             }
@@ -90,7 +88,7 @@ public class FontListSerializer {
                     stripQuotes(familyName));
             handler.startElement(FAMILY, atts);
 
-            List containers = (List)entry.getValue();
+            List containers = (List) entry.getValue();
             generateXMLForFontContainers(handler, containers);
             handler.endElement(FAMILY);
         }
@@ -108,9 +106,8 @@ public class FontListSerializer {
     private void generateXMLForFontContainers(GenerationHelperContentHandler handler,
             List containers) throws SAXException {
         AttributesImpl atts = new AttributesImpl();
-        Iterator fontIter = containers.iterator();
-        while (fontIter.hasNext()) {
-            FontSpec cont = (FontSpec)fontIter.next();
+        for (Object container : containers) {
+            FontSpec cont = (FontSpec) container;
             atts.clear();
             atts.addAttribute(null, KEY, KEY, CDATA, cont.getKey());
             atts.addAttribute(null, TYPE, TYPE, CDATA,
@@ -126,9 +123,8 @@ public class FontListSerializer {
         AttributesImpl atts = new AttributesImpl();
         atts.clear();
         handler.startElement(TRIPLETS, atts);
-        Iterator iter = triplets.iterator();
-        while (iter.hasNext()) {
-            FontTriplet triplet = (FontTriplet)iter.next();
+        for (Object triplet1 : triplets) {
+            FontTriplet triplet = (FontTriplet) triplet1;
             atts.clear();
             atts.addAttribute(null, NAME, NAME, CDATA, triplet.getName());
             atts.addAttribute(null, STYLE, STYLE, CDATA, triplet.getStyle());
index 4ac29b4cdddaa50d3738949c0517993b5c846cf2..eaaa996932f52db9a1146e0d9752afcf5b9afdf6 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.fop.layoutengine;
 
-import java.util.Iterator;
 import java.util.List;
 
 import org.w3c.dom.CDATASection;
@@ -230,9 +229,8 @@ public class ElementListCheck implements LayoutEngineCheck {
 
     private ElementListCollector.ElementList findElementList(LayoutResult result) {
         List candidates = new java.util.ArrayList();
-        Iterator iter = result.getElementListCollector().getElementLists().iterator();
-        while (iter.hasNext()) {
-            ElementListCollector.ElementList el = (ElementListCollector.ElementList)iter.next();
+        for (Object o : result.getElementListCollector().getElementLists()) {
+            ElementListCollector.ElementList el = (ElementListCollector.ElementList) o;
             if (el.getCategory().equals(category)) {
                 if (haveID() && this.id.equals(el.getID())) {
                     candidates.add(el);
index 3549523476bd75c55bd1c42b40edf460be601207..6c1ae31122008d9945d28f05d92dc9ff66c2253e 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.fop.memory;
 
-import java.util.Iterator;
 import java.util.List;
 
 class Stats {
@@ -83,9 +82,8 @@ class Stats {
         sb.append("&chd=t:");
         boolean first = true;
         int maxY = 0;
-        Iterator iter = samples.iterator();
-        while (iter.hasNext()) {
-            Sample sample = (Sample)iter.next();
+        for (Object sample1 : samples) {
+            Sample sample = (Sample) sample1;
             if (first) {
                 first = false;
             } else {
index 7b03ada612d1bdf1f1b3688a4c0828630b9bc996..ec66080cd87fea8808ce576a91f280d1babac5f1 100644 (file)
@@ -23,7 +23,6 @@ import java.io.File;
 import java.io.OutputStream;
 import java.text.DecimalFormat;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 
 import javax.xml.transform.Source;
@@ -101,9 +100,8 @@ public class FOPTestbed extends AbstractLogEnabled
         }
 
         //Start threads
-        Iterator i = threadList.iterator();
-        while (i.hasNext()) {
-            ((Thread)i.next()).start();
+        for (Object aThreadList : threadList) {
+            ((Thread) aThreadList).start();
         }
 
         //Wait for threads to end
@@ -129,9 +127,8 @@ public class FOPTestbed extends AbstractLogEnabled
         int failures = 0;
         long bytesWritten = 0;
         System.out.println("Report on " + count + " tasks:");
-        Iterator iter = this.results.iterator();
-        while (iter.hasNext()) {
-            Result res = (Result)iter.next();
+        for (Object result : this.results) {
+            Result res = (Result) result;
             if (res.failure != null) {
                 System.out.println("FAIL: " + (res.end - res.start) + " " + res.task);
                 System.out.println("  -> " + res.failure.getMessage());
@@ -158,9 +155,8 @@ public class FOPTestbed extends AbstractLogEnabled
         public void run() {
             try {
                 for (int r = 0; r < repeat; r++) {
-                    Iterator i = taskList.iterator();
-                    while (i.hasNext()) {
-                        TaskDef def = (TaskDef)i.next();
+                    for (Object aTaskList : taskList) {
+                        TaskDef def = (TaskDef) aTaskList;
                         final Task task = new Task(def, counter++, foprocessor);
                         ContainerUtil.enableLogging(task, getLogger());
                         task.execute();
index 24499ea35189fd3da91986080afd802d36399b48..d4e03faea7038ed25f36ae356d9abe91a441ea90 100644 (file)
@@ -23,7 +23,6 @@ import java.io.InputStream;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.MissingResourceException;
@@ -161,10 +160,9 @@ public class DefaultEventBroadcaster implements EventBroadcaster {
                         }
                         Map params = new java.util.HashMap();
                         int i = 1;
-                        Iterator iter = methodModel.getParameters().iterator();
-                        while (iter.hasNext()) {
+                        for (Object o : methodModel.getParameters()) {
                             EventMethodModel.Parameter param
-                                = (EventMethodModel.Parameter)iter.next();
+                                    = (EventMethodModel.Parameter) o;
                             params.put(param.getName(), args[i]);
                             i++;
                         }
index e9208fbc63d1c1c27a0c374a1ec569ba330dc792..21351caff8b4290ffba0166daf4e109cdcce3466 100644 (file)
@@ -64,11 +64,9 @@ public final class EventExceptionManager {
             String msg = EventFormatter.format(event);
             //Get original exception as cause if it is given as one of the parameters
             Throwable t = null;
-            Iterator<Object> iter = event.getParams().values().iterator();
-            while (iter.hasNext()) {
-                Object o = iter.next();
+            for (Object o : event.getParams().values()) {
                 if (o instanceof Throwable) {
-                    t = (Throwable)o;
+                    t = (Throwable) o;
                     break;
                 }
             }
index b9c62f8aba9b30cdf1f4ab3dabaeba7283fab314..7a0283db483494566527a892e386b701382a025e 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.events.model;
 
 import java.io.Serializable;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 
 import org.xml.sax.ContentHandler;
@@ -141,9 +140,8 @@ public class EventMethodModel implements Serializable, XMLizable {
         }
         String elName = "method";
         handler.startElement("", elName, elName, atts);
-        Iterator iter = this.params.iterator();
-        while (iter.hasNext()) {
-            ((XMLizable)iter.next()).toSAX(handler);
+        for (Object param : this.params) {
+            ((XMLizable) param).toSAX(handler);
         }
         handler.endElement("", elName, elName);
     }
index f56eea2e4f7005447c66828ba29bb9ca78d84b73..8796280fd3215d7133ffd3e15a45c97b8a028aa6 100644 (file)
@@ -201,9 +201,7 @@ public class EventProducerCollectorTask extends Task {
     protected long processFileSets(EventProducerCollector collector)
             throws IOException, EventConventionException, ClassNotFoundException {
         long lastModified = 0;
-        Iterator<FileSet> iter = filesets.iterator();
-        while (iter.hasNext()) {
-            FileSet fs = (FileSet)iter.next();
+        for (FileSet fs : filesets) {
             DirectoryScanner ds = fs.getDirectoryScanner(getProject());
             String[] srcFiles = ds.getIncludedFiles();
             File directory = fs.getDir(getProject());
index f8508e082e366534dfe22d768007a3d2b855230b..acb85155386473be87c9c307d43ff41f8476cc3a 100644 (file)
@@ -355,9 +355,7 @@ public class AdvancedMessageFormat {
             target.append(obj);
         } else {
             boolean handled = false;
-            Iterator<ObjectFormatter> iter = OBJECT_FORMATTERS.iterator();
-            while (iter.hasNext()) {
-                ObjectFormatter formatter = iter.next();
+            for (ObjectFormatter formatter : OBJECT_FORMATTERS) {
                 if (formatter.supportsObject(obj)) {
                     formatter.format(target, obj);
                     handled = true;
@@ -437,9 +435,7 @@ public class AdvancedMessageFormat {
 
         public void write(StringBuffer sb, Map<String, Object> params) {
             if (hasSections) {
-                Iterator<Part> iter = this.parts.iterator();
-                while (iter.hasNext()) {
-                    Part part = iter.next();
+                for (Part part : this.parts) {
                     if (part.isGenerated(params)) {
                         part.write(sb, params);
                         break;
@@ -447,9 +443,7 @@ public class AdvancedMessageFormat {
                 }
             } else {
                 if (isGenerated(params)) {
-                    Iterator<Part> iter = this.parts.iterator();
-                    while (iter.hasNext()) {
-                        Part part = iter.next();
+                    for (Part part : this.parts) {
                         part.write(sb, params);
                     }
                 }
@@ -458,9 +452,7 @@ public class AdvancedMessageFormat {
 
         public boolean isGenerated(Map<String, Object> params) {
             if (hasSections) {
-                Iterator<Part> iter = this.parts.iterator();
-                while (iter.hasNext()) {
-                    Part part = iter.next();
+                for (Part part : this.parts) {
                     if (part.isGenerated(params)) {
                         return true;
                     }
@@ -468,9 +460,7 @@ public class AdvancedMessageFormat {
                 return false;
             } else {
                 if (conditional) {
-                    Iterator<Part> iter = this.parts.iterator();
-                    while (iter.hasNext()) {
-                        Part part = iter.next();
+                    for (Part part : this.parts) {
                         if (!part.isGenerated(params)) {
                             return false;
                         }