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

132 files changed:
fop-core/src/main/java/org/apache/fop/afp/AFPGraphics2D.java
fop-core/src/main/java/org/apache/fop/afp/DataStream.java
fop-core/src/main/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java
fop-core/src/main/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java
fop-core/src/main/java/org/apache/fop/afp/modca/MapPageOverlay.java
fop-core/src/main/java/org/apache/fop/apps/FOUserAgent.java
fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java
fop-core/src/main/java/org/apache/fop/area/LineArea.java
fop-core/src/main/java/org/apache/fop/area/Span.java
fop-core/src/main/java/org/apache/fop/area/Trait.java
fop-core/src/main/java/org/apache/fop/area/inline/InlineParent.java
fop-core/src/main/java/org/apache/fop/area/inline/TextArea.java
fop-core/src/main/java/org/apache/fop/cli/CommandLineOptions.java
fop-core/src/main/java/org/apache/fop/cli/Main.java
fop-core/src/main/java/org/apache/fop/complexscripts/bidi/BidiResolver.java
fop-core/src/main/java/org/apache/fop/complexscripts/bidi/DelimitedTextRange.java
fop-core/src/main/java/org/apache/fop/complexscripts/bidi/InlineRun.java
fop-core/src/main/java/org/apache/fop/complexscripts/bidi/UnflattenProcessor.java
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphClassTable.java
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphCoverageTable.java
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionTable.java
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphMappingTable.java
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphPositioningState.java
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionState.java
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubtable.java
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphTable.java
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java
fop-core/src/main/java/org/apache/fop/complexscripts/scripts/IndicScriptProcessor.java
fop-core/src/main/java/org/apache/fop/complexscripts/scripts/ScriptProcessor.java
fop-core/src/main/java/org/apache/fop/complexscripts/util/CharAssociation.java
fop-core/src/main/java/org/apache/fop/complexscripts/util/CharScript.java
fop-core/src/main/java/org/apache/fop/complexscripts/util/GlyphSequence.java
fop-core/src/main/java/org/apache/fop/complexscripts/util/NumberConverter.java
fop-core/src/main/java/org/apache/fop/datatypes/URISpecification.java
fop-core/src/main/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
fop-core/src/main/java/org/apache/fop/fo/flow/table/EffRow.java
fop-core/src/main/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
fop-core/src/main/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
fop-core/src/main/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java
fop-core/src/main/java/org/apache/fop/fonts/CustomFontCollection.java
fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfigurator.java
fop-core/src/main/java/org/apache/fop/fonts/FontAdder.java
fop-core/src/main/java/org/apache/fop/fonts/FontCache.java
fop-core/src/main/java/org/apache/fop/fonts/FontInfo.java
fop-core/src/main/java/org/apache/fop/fonts/FontManager.java
fop-core/src/main/java/org/apache/fop/fonts/FontManagerConfigurator.java
fop-core/src/main/java/org/apache/fop/fonts/FontSelector.java
fop-core/src/main/java/org/apache/fop/fonts/FontSetup.java
fop-core/src/main/java/org/apache/fop/fonts/FontUtil.java
fop-core/src/main/java/org/apache/fop/fonts/MultiByteFont.java
fop-core/src/main/java/org/apache/fop/fonts/SingleByteFont.java
fop-core/src/main/java/org/apache/fop/fonts/XMLFontMetricsReader.java
fop-core/src/main/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java
fop-core/src/main/java/org/apache/fop/fonts/substitute/FontQualifier.java
fop-core/src/main/java/org/apache/fop/fonts/substitute/FontSubstitutions.java
fop-core/src/main/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java
fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java
fop-core/src/main/java/org/apache/fop/hyphenation/HyphenationTree.java
fop-core/src/main/java/org/apache/fop/hyphenation/PatternParser.java
fop-core/src/main/java/org/apache/fop/layoutmgr/SpaceResolver.java
fop-core/src/main/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
fop-core/src/main/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/table/RowPainter.java
fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableStepper.java
fop-core/src/main/java/org/apache/fop/pdf/PDFArray.java
fop-core/src/main/java/org/apache/fop/pdf/PDFColorHandler.java
fop-core/src/main/java/org/apache/fop/pdf/PDFFilterList.java
fop-core/src/main/java/org/apache/fop/pdf/PDFPages.java
fop-core/src/main/java/org/apache/fop/pdf/PDFPaintingState.java
fop-core/src/main/java/org/apache/fop/pdf/PDFText.java
fop-core/src/main/java/org/apache/fop/pdf/PDFWArray.java
fop-core/src/main/java/org/apache/fop/render/AbstractFOEventHandlerMaker.java
fop-core/src/main/java/org/apache/fop/render/AbstractRenderer.java
fop-core/src/main/java/org/apache/fop/render/AbstractRendererMaker.java
fop-core/src/main/java/org/apache/fop/render/ImageHandlerRegistry.java
fop-core/src/main/java/org/apache/fop/render/RendererFactory.java
fop-core/src/main/java/org/apache/fop/render/XMLHandlerConfigurator.java
fop-core/src/main/java/org/apache/fop/render/XMLHandlerRegistry.java
fop-core/src/main/java/org/apache/fop/render/afp/AFPRendererConfig.java
fop-core/src/main/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandlerMaker.java
fop-core/src/main/java/org/apache/fop/render/intermediate/AbstractIFPainter.java
fop-core/src/main/java/org/apache/fop/render/intermediate/IFRenderer.java
fop-core/src/main/java/org/apache/fop/render/intermediate/IFUtil.java
fop-core/src/main/java/org/apache/fop/render/java2d/InstalledFontCollection.java
fop-core/src/main/java/org/apache/fop/render/pcl/PCLGenerator.java
fop-core/src/main/java/org/apache/fop/render/ps/PSImageHandlerSVG.java
fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java
fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java
fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfContainer.java
fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java
fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java
fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java
fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListTable.java
fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceManager.java
fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java
fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java
fop-core/src/main/java/org/apache/fop/render/txt/TXTState.java
fop-core/src/main/java/org/apache/fop/render/xml/XMLRenderer.java
fop-core/src/main/java/org/apache/fop/svg/NativeTextPainter.java
fop-core/src/main/java/org/apache/fop/svg/PDFGraphics2D.java
fop-core/src/main/java/org/apache/fop/tools/anttasks/FileCompare.java
fop-core/src/main/java/org/apache/fop/tools/anttasks/Fop.java
fop-core/src/main/java/org/apache/fop/traits/BorderStyle.java
fop-core/src/main/java/org/apache/fop/traits/Direction.java
fop-core/src/main/java/org/apache/fop/traits/RuleStyle.java
fop-core/src/main/java/org/apache/fop/traits/WritingMode.java
fop-core/src/main/java/org/apache/fop/util/ColorExt.java
fop-core/src/main/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java
fop-core/src/main/java/org/apache/fop/util/DOM2SAX.java
fop-core/src/test/java/org/apache/fop/DigestFilterTestCase.java
fop-core/src/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java
fop-core/src/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java
fop-core/src/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java
fop-core/src/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java
fop-core/src/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java
fop-core/src/test/java/org/apache/fop/threading/FOPTestbed.java
fop-core/src/test/java/org/apache/fop/util/DigestFilter.java
fop-core/src/test/java/org/apache/fop/visual/BitmapComparator.java
fop-events/src/main/java/org/apache/fop/events/DefaultEventBroadcaster.java
fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java
fop-events/src/main/java/org/apache/fop/tools/EventProducerCollectorTask.java

index f6db94458d5cdcb6e050b1482b7566d7fe04d62f..e42b07fc546840a4e12a16cd31331625bf07784c 100644 (file)
@@ -455,8 +455,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
                 double[][] quadParts = CubicBezierApproximator.fixedMidPointApproximation(
                         cubicCoords);
                 if (quadParts.length >= 4) {
-                    for (int segIndex = 0; segIndex < quadParts.length; segIndex++) {
-                        double[] quadPts = quadParts[segIndex];
+                    for (double[] quadPts : quadParts) {
                         if (quadPts != null && quadPts.length == 4) {
                             graphicsObj.addFillet(new int[]{
                                     (int) Math.round(quadPts[X1]),
index e9e574a6f5d98df14e177222b9f17a1ec9c83cfb..5244d9212ecb5b6d5f0bb9f11d8cac9962890371 100644 (file)
@@ -551,9 +551,9 @@ public class DataStream {
      */
 
     public void createPageTagLogicalElement(TagLogicalElement.State[] attributes) {
-        for (int i = 0; i < attributes.length; i++) {
+        for (TagLogicalElement.State attribute : attributes) {
 
-            currentPage.createTagLogicalElement(attributes[i]);
+            currentPage.createTagLogicalElement(attribute);
         }
     }
 
@@ -564,8 +564,8 @@ public class DataStream {
      *            the array of key value pairs.
      */
     public void createPageGroupTagLogicalElement(TagLogicalElement.State[] attributes) {
-        for (int i = 0; i < attributes.length; i++) {
-            currentPageGroup.createTagLogicalElement(attributes[i]);
+        for (TagLogicalElement.State attribute : attributes) {
+            currentPageGroup.createTagLogicalElement(attribute);
         }
     }
 
index 39d2be8455d87fafea96cc5bafa14d55fa939f1e..4174f31d892daea18978ede815cf13b5fe6b5391 100644 (file)
@@ -302,8 +302,7 @@ public abstract class CharacterSetBuilder {
                 //process D3AC89 Font Position
                 processFontPosition(structuredFieldReader, characterSetOrientations, normalizer);
                 //process D38C89 Font Index (per orientation)
-                for (int i = 0; i < characterSetOrientations.length; i++) {
-                    CharacterSetOrientation characterSetOrientation = characterSetOrientations[i];
+                for (CharacterSetOrientation characterSetOrientation : characterSetOrientations) {
                     processFontIndex(structuredFieldReader, characterSetOrientation, codePage, normalizer);
                     characterSet.addCharacterSetOrientation(characterSetOrientation);
                 }
index f5808bda62d46401029259d1fc4c635e8d4ecd51..d4b3c68ec809de67d1f827edea559bc743262f78 100644 (file)
@@ -111,14 +111,14 @@ public class GraphicsSetProcessColor extends AbstractGraphicsDrawingOrder {
         if (colSpaceType == ColorSpace.TYPE_CMYK) {
             colspace = CMYK;
             colsizes = new byte[] {0x08, 0x08, 0x08, 0x08};
-            for (int i = 0; i < colorComponents.length; i++) {
-                baout.write(Math.round(colorComponents[i] * 255));
+            for (float colorComponent : colorComponents) {
+                baout.write(Math.round(colorComponent * 255));
             }
         } else if (colSpaceType == ColorSpace.TYPE_RGB) {
             colspace = RGB;
             colsizes = new byte[] {0x08, 0x08, 0x08, 0x00};
-            for (int i = 0; i < colorComponents.length; i++) {
-                baout.write(Math.round(colorComponents[i] * 255));
+            for (float colorComponent : colorComponents) {
+                baout.write(Math.round(colorComponent * 255));
             }
         } else if (cs instanceof CIELabColorSpace) {
             colspace = CIELAB;
index cde2e031d8157626ba67c8f0d7b40134fc36e708..67a1ae1b874eaa491155bec5eaaa7c930d08dc64 100644 (file)
@@ -125,8 +125,8 @@ public class MapPageOverlay extends AbstractAFPObject {
             //now add the name
             byte[] name = (byte[]) overLays.get(i);
 
-            for (int j = 0; j < name.length; j++) {
-                data[++pos] = name[j];
+            for (byte aName : name) {
+                data[++pos] = aName;
             }
 
             data[++pos] = 0x04; //Resource Local Identifier (RLI)
index 43d2b9d800422069926a47f8da8d46977d087d7d..2aaa2ad22e931417a474a9219a94a664ccb57a33 100644 (file)
@@ -682,8 +682,7 @@ public class FOUserAgent {
         Configuration userConfig = null;
 
         Configuration[] cfgs = cfg.getChild(type + "s").getChildren(type);
-        for (int i = 0; i < cfgs.length; ++i) {
-            Configuration child = cfgs[i];
+        for (Configuration child : cfgs) {
             try {
                 if (child.getAttribute(mime).equals(mimeType)) {
                     userConfig = child;
index a42ef15497b4a680e5728925ab93491984a87767..c68226db5888cca491ae49af7e2424c1c7639972 100644 (file)
@@ -370,8 +370,7 @@ public class FopConfParser {
         ImageImplRegistry registry = fopFactoryBuilder.getImageManager().getRegistry();
         Configuration[] penalties = parent.getChildren("penalty");
         try {
-            for (int i = 0, c = penalties.length; i < c; i++) {
-                Configuration penaltyCfg = penalties[i];
+            for (Configuration penaltyCfg : penalties) {
                 String className = penaltyCfg.getAttribute("class");
                 String value = penaltyCfg.getAttribute("value");
                 Penalty p = null;
index 8639b8201aa1ffbbf9d8f13443dafaa93565a438..f659c2d788e140fb0c4f9ea812ee8a4807906abc 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.area;
 
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.fop.area.inline.InlineArea;
@@ -132,8 +131,7 @@ public class LineArea extends Area {
      * @param inlineAreas the list of inline areas
      */
     public void setInlineAreas(List inlineAreas) {
-        for (Iterator<InlineArea> it = inlineAreas.iterator(); it.hasNext();) {
-            InlineArea ia = it.next();
+        for (InlineArea ia : (Iterable<InlineArea>) inlineAreas) {
             Area pa = ia.getParentArea();
             if (pa == null) {
                 ia.setParentArea(this);
@@ -189,9 +187,9 @@ public class LineArea extends Area {
     public void updateExtentsFromChildren() {
         int ipd = 0;
         int bpd = 0;
-        for (int i = 0, len = inlineAreas.size(); i < len; i++) {
-            ipd = Math.max(ipd, inlineAreas.get(i).getAllocIPD());
-            bpd += inlineAreas.get(i).getAllocBPD();
+        for (InlineArea inlineArea : inlineAreas) {
+            ipd = Math.max(ipd, inlineArea.getAllocIPD());
+            bpd += inlineArea.getAllocBPD();
         }
         setIPD(ipd);
         setBPD(bpd);
@@ -258,8 +256,8 @@ public class LineArea extends Area {
             // justified line: apply the variation factor
             boolean bUnresolvedAreasPresent = false;
             // recursively apply variation factor to descendant areas
-            for (int i = 0, len = inlineAreas.size(); i < len; i++) {
-                bUnresolvedAreasPresent |= inlineAreas.get(i)
+            for (InlineArea inlineArea : inlineAreas) {
+                bUnresolvedAreasPresent |= inlineArea
                         .applyVariationFactor(adjustingInfo.variationFactor,
                                 adjustingInfo.availableStretch,
                                 adjustingInfo.availableShrink);
index e0f8633be6a662cc46c4d7e26e15104f69c03a05..41610f355af49124bca9fe06933db6952b3115e6 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.fop.area;
 
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.fop.fo.Constants;
@@ -196,14 +195,14 @@ public class Span extends Area {
         switch (wmtg.getColumnProgressionDirection().getEnumValue()) {
         case Constants.EN_RL:
             setBidiLevel(1);
-            for (Iterator<NormalFlow> it = flowAreas.iterator(); it.hasNext();) {
-                it.next().setBidiLevel(1);
+            for (NormalFlow flowArea1 : flowAreas) {
+                flowArea1.setBidiLevel(1);
             }
             break;
         default:
             resetBidiLevel();
-            for (Iterator<NormalFlow> it = flowAreas.iterator(); it.hasNext();) {
-                it.next().resetBidiLevel();
+            for (NormalFlow flowArea : flowAreas) {
+                flowArea.resetBidiLevel();
             }
             break;
         }
index 51bf5cad0996adfe840b3a8196a5d59e63732278..cfde0c83bf67c5c49056581ce2480cf7ce1b1d41 100644 (file)
@@ -438,8 +438,7 @@ public final class Trait implements Serializable {
             String dest = null;
             boolean newWindow = false;
             String[] values = traitValue.split(",");
-            for (int i = 0, c = values.length; i < c; i++) {
-                String v = values[i];
+            for (String v : values) {
                 if (v.startsWith("dest=")) {
                     dest = v.substring(5);
                 } else if (v.startsWith("newWindow=")) {
index 2e03f4d804144507ec7f7dedc024b1d9e9699f05..66075b641b63f0fb7a4a48dd25e041886d9fb7d5 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.fop.area.inline;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.fop.area.Area;
@@ -108,8 +107,7 @@ public class InlineParent extends InlineArea {
         boolean hasUnresolvedAreas = false;
         int cumulativeIPD = 0;
         // recursively apply variation factor to descendant areas
-        for (int i = 0, len = inlines.size(); i < len; i++) {
-            InlineArea inline = inlines.get(i);
+        for (InlineArea inline : inlines) {
             hasUnresolvedAreas |= inline.applyVariationFactor(
                     variationFactor, lineStretch, lineShrink);
             cumulativeIPD += inline.getIPD();  //Update this area's IPD based on changes to children
@@ -121,8 +119,7 @@ public class InlineParent extends InlineArea {
 
     @Override
     public List collectInlineRuns(List runs) {
-        for (Iterator<InlineArea> it = getChildAreas().iterator(); it.hasNext();) {
-            InlineArea ia = it.next();
+        for (InlineArea ia : getChildAreas()) {
             runs = ia.collectInlineRuns(runs);
         }
         return runs;
@@ -133,8 +130,8 @@ public class InlineParent extends InlineArea {
      * signalling that they will inherit the level of their parent text area.
      */
     public void resetChildrenLevel() {
-        for (Iterator it = inlines.iterator(); it.hasNext();) {
-            ((InlineArea) it.next()) .resetBidiLevel();
+        for (InlineArea inline : inlines) {
+            (inline).resetBidiLevel();
         }
     }
 
index 5a1b31c986d2bd2d1ef354e7b8abdf3b306d0436..3081a38eb4bca66bc9c1d0470de58de37b7b69b4 100644 (file)
@@ -184,8 +184,7 @@ public class TextArea extends AbstractTextArea {
     private static int findMinLevel(int[] levels, int defaultLevel) {
         if (levels != null) {
             int lMin = Integer.MAX_VALUE;
-            for (int i = 0, n = levels.length; i < n; i++) {
-                int l = levels [ i ];
+            for (int l : levels) {
                 if ((l >= 0) && (l < lMin)) {
                     lMin = l;
                 }
index 8bc16fec4d36ab7c636929a9b9790a9ade167717..f62b386700536686b226976bfc2824a7063e81e8 100644 (file)
@@ -599,8 +599,7 @@ public class CommandLineOptions {
                 && (args[i + 1].charAt(0) != '-')) {
             String arg = args[i + 1];
             String[] parts = arg.split(",");
-            for (int j = 0; j < parts.length; j++) {
-                String s = parts[j];
+            for (String s : parts) {
                 if (s.matches("\\d+")) {
                     renderingOptions.put(PrintRenderer.START_PAGE, Integer.valueOf(s));
                 } else if (s.matches("\\d+-\\d+")) {
@@ -702,8 +701,8 @@ public class CommandLineOptions {
             if ("list".equals(mime)) {
                 String[] mimes = factory.getRendererFactory().listSupportedMimeTypes();
                 System.out.println("Supported MIME types:");
-                for (int j = 0; j < mimes.length; j++) {
-                    System.out.println("  " + mimes[j]);
+                for (String mime1 : mimes) {
+                    System.out.println("  " + mime1);
                 }
                 // @SuppressFBWarnings("DM_EXIT")
                 System.exit(0);
index b4c294e6ed09e7cc39faa716ec041f8a83c7cbc7..e082265f1eb56c17fc2047d606af2d2c9841d00e 100644 (file)
@@ -84,16 +84,16 @@ public final class Main {
         }
         files = libDir.listFiles(filter);
         if (files != null) {
-            for (int i = 0, size = files.length; i < size; i++) {
-                jars.add(files[i].toURI().toURL());
+            for (File file : files) {
+                jars.add(file.toURI().toURL());
             }
         }
         String optionalLib = System.getProperty("fop.optional.lib");
         if (optionalLib != null) {
             files = new File(optionalLib).listFiles(filter);
             if (files != null) {
-                for (int i = 0, size = files.length; i < size; i++) {
-                    jars.add(files[i].toURI().toURL());
+                for (File file : files) {
+                    jars.add(file.toURI().toURL());
                 }
             }
         }
index e458e781ce327421fd82bbcafc27cbf573b6fc62..6c9c6fbbcdfc42a4e2cbc68539ba87b5db25b93a 100644 (file)
@@ -20,7 +20,6 @@
 package org.apache.fop.complexscripts.bidi;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Stack;
 import java.util.Vector;
@@ -119,8 +118,8 @@ public final class BidiResolver {
     }
 
     private static void resolveInlineDirectionality(List ranges) {
-        for (Iterator it = ranges.iterator(); it.hasNext(); ) {
-            DelimitedTextRange r = (DelimitedTextRange) it.next();
+        for (Object range : ranges) {
+            DelimitedTextRange r = (DelimitedTextRange) range;
             r.resolve();
             if (log.isDebugEnabled()) {
                 log.debug(r);
@@ -129,8 +128,8 @@ public final class BidiResolver {
     }
 
     private static List collectRuns(List inlines, List runs) {
-        for (Iterator it = inlines.iterator(); it.hasNext(); ) {
-            InlineArea ia = (InlineArea) it.next();
+        for (Object inline : inlines) {
+            InlineArea ia = (InlineArea) inline;
             runs = ia.collectInlineRuns(runs);
         }
         return runs;
@@ -138,8 +137,8 @@ public final class BidiResolver {
 
     private static List splitRuns(List runs) {
         List runsNew = new Vector();
-        for (Iterator it = runs.iterator(); it.hasNext(); ) {
-            InlineRun ir = (InlineRun) it.next();
+        for (Object run : runs) {
+            InlineRun ir = (InlineRun) run;
             if (ir.isHomogenous()) {
                 runsNew.add(ir);
             } else {
@@ -156,8 +155,8 @@ public final class BidiResolver {
         if (mm == null) {
             mm = new int[] {Integer.MAX_VALUE, Integer.MIN_VALUE};
         }
-        for (Iterator it = runs.iterator(); it.hasNext(); ) {
-            InlineRun ir = (InlineRun) it.next();
+        for (Object run : runs) {
+            InlineRun ir = (InlineRun) run;
             ir.updateMinMax(mm);
         }
         return mm;
@@ -205,8 +204,8 @@ public final class BidiResolver {
         return runsNew;
     }
     private static void reverseWords(List runs, boolean mirror) {
-        for (Iterator it = runs.iterator(); it.hasNext(); ) {
-            InlineRun ir = (InlineRun) it.next();
+        for (Object run : runs) {
+            InlineRun ir = (InlineRun) run;
             ir.maybeReverseWord(mirror);
         }
     }
@@ -217,8 +216,8 @@ public final class BidiResolver {
     }
     private static void replaceInlines(LineArea la, List runs) {
         List<InlineArea> inlines = new ArrayList<InlineArea>();
-        for (Iterator it = runs.iterator(); it.hasNext(); ) {
-            InlineRun ir = (InlineRun) it.next();
+        for (Object run : runs) {
+            InlineRun ir = (InlineRun) run;
             inlines.add(ir.getInline());
         }
         la.setInlineAreas(unflattenInlines(inlines));
@@ -228,22 +227,22 @@ public final class BidiResolver {
     }
     private static void dumpRuns(String header, List runs) {
         log.debug(header);
-        for (Iterator it = runs.iterator(); it.hasNext(); ) {
-            InlineRun ir = (InlineRun) it.next();
+        for (Object run : runs) {
+            InlineRun ir = (InlineRun) run;
             log.debug(ir);
         }
     }
     private static void dumpRanges(String header, List ranges) {
         log.debug(header);
-        for (Iterator it = ranges.iterator(); it.hasNext(); ) {
-            DelimitedTextRange r = (DelimitedTextRange) it.next();
+        for (Object range : ranges) {
+            DelimitedTextRange r = (DelimitedTextRange) range;
             log.debug(r);
         }
     }
     private static List pruneEmptyRanges(List ranges) {
         Vector rv = new Vector();
-        for (Iterator it = ranges.iterator(); it.hasNext(); ) {
-            DelimitedTextRange r = (DelimitedTextRange) it.next();
+        for (Object range : ranges) {
+            DelimitedTextRange r = (DelimitedTextRange) range;
             if (!r.isEmpty()) {
                 rv.add(r);
             }
index 67bb0aae126b771c8f3c08e098b03d55ffd212f5..75de90b5e5add7a632c5fdafcfb526ff23142b2a 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.fop.complexscripts.bidi;
 
-import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
 
@@ -114,8 +113,8 @@ public class DelimitedTextRange {
         StringBuffer sb = new StringBuffer("DR: " + fn.getLocalName() + " { <" + CharUtilities.toNCRefs(buffer.toString()) + ">");
         sb.append(", intervals <");
         boolean first = true;
-        for (Iterator it = intervals.iterator(); it.hasNext(); ) {
-            TextInterval ti = (TextInterval) it.next();
+        for (Object interval : intervals) {
+            TextInterval ti = (TextInterval) interval;
             if (first) {
                 first = false;
             } else {
@@ -144,8 +143,8 @@ public class DelimitedTextRange {
      */
     private void assignLevels(int[] levels) {
         Vector intervalsNew = new Vector(intervals.size());
-        for (Iterator it = intervals.iterator(); it.hasNext(); ) {
-            TextInterval ti = (TextInterval) it.next();
+        for (Object interval : intervals) {
+            TextInterval ti = (TextInterval) interval;
             intervalsNew.addAll(assignLevels(ti, levels));
         }
         if (!intervalsNew.equals(intervals)) {
@@ -196,15 +195,15 @@ public class DelimitedTextRange {
      * <p>Assign resolved levels for each interval to source #PCDATA in the associated FOText.</p>
      */
     private void assignTextLevels() {
-        for (Iterator it = intervals.iterator(); it.hasNext(); ) {
-            TextInterval ti = (TextInterval) it.next();
+        for (Object interval : intervals) {
+            TextInterval ti = (TextInterval) interval;
             ti.assignTextLevels();
         }
     }
     private void assignBlockLevel(Direction paragraphEmbeddingLevel) {
         int defaultLevel = (paragraphEmbeddingLevel == Direction.RL) ? 1 : 0;
-        for (Iterator it = intervals.iterator(); it.hasNext(); ) {
-            TextInterval ti = (TextInterval) it.next();
+        for (Object interval : intervals) {
+            TextInterval ti = (TextInterval) interval;
             assignBlockLevel(ti.getNode(), defaultLevel);
         }
     }
index 828da13e36cbec8869be55a43658780b4b3efcd1..2fafbe23316c84361786f831cbf0191374a7962d 100644 (file)
@@ -93,8 +93,7 @@ public class InlineRun {
         int mn = Integer.MAX_VALUE;
         int mx = Integer.MIN_VALUE;
         if ((levels != null) && (levels.length > 0)) {
-            for (int i = 0, n = levels.length; i < n; i++) {
-                int l = levels [ i ];
+            for (int l : levels) {
                 if (l < mn) {
                     mn = l;
                 }
@@ -265,8 +264,7 @@ public class InlineRun {
         StringBuffer lb = new StringBuffer();
         int maxLevel = -1;
         int numLevels = levels.length;
-        for (int i = 0; i < numLevels; i++) {
-            int l = levels [ i ];
+        for (int l : levels) {
             if (l > maxLevel) {
                 maxLevel = l;
             }
@@ -275,19 +273,19 @@ public class InlineRun {
             // leave level buffer empty
         } else if (maxLevel < 10) {
             // use string of decimal digits
-            for (int i = 0; i < numLevels; i++) {
-                lb.append((char) ('0' + levels [ i ]));
+            for (int level : levels) {
+                lb.append((char) ('0' + level));
             }
         } else {
             // use comma separated list
             boolean first = true;
-            for (int i = 0; i < numLevels; i++) {
+            for (int level : levels) {
                 if (first) {
                     first = false;
                 } else {
                     lb.append(',');
                 }
-                lb.append(levels [ i ]);
+                lb.append(level);
             }
         }
         return lb.toString();
index 456aa52ade669af861794539588ee79b504aee67..23b34f16955418338b23e1e7fcc29a179e83fc4b 100644 (file)
@@ -20,7 +20,6 @@
 package org.apache.fop.complexscripts.bidi;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Stack;
@@ -61,8 +60,8 @@ class UnflattenProcessor {
     }
     List unflatten() {
         if (il != null) {
-            for (Iterator<InlineArea> it = il.iterator(); it.hasNext(); ) {
-                process(it.next());
+            for (InlineArea anIl : il) {
+                process(anIl);
             }
         }
         finishAll();
@@ -125,8 +124,7 @@ class UnflattenProcessor {
     }
     private void finishInlineContainer(List<InlineParent> ich, TextArea tc, InlineArea ia) {
         if ((ich != null) && !ich.isEmpty()) {     // finish non-matching inner inline container(s)
-            for (Iterator<InlineParent> it = ich.iterator(); it.hasNext(); ) {
-                InlineParent ic  = it.next();
+            for (InlineParent ic : ich) {
                 InlineParent ic0 = icOrig.empty() ? null : icOrig.peek();
                 if (ic0 == null) {
                     assert icNew.empty();
@@ -191,8 +189,8 @@ class UnflattenProcessor {
         }
     }
     private boolean alreadyUnflattened(InlineArea ia) {
-        for (Iterator<InlineArea> it = ilNew.iterator(); it.hasNext(); ) {
-            if (ia.isAncestorOrSelf(it.next())) {
+        for (InlineArea anIlNew : ilNew) {
+            if (ia.isAncestorOrSelf(anIlNew)) {
                 return true;
             }
         }
@@ -200,16 +198,14 @@ class UnflattenProcessor {
     }
     private void pushInlineContainers(List<InlineParent> ich) {
         LinkedList<InlineParent> icl = new LinkedList<InlineParent>();
-        for (Iterator<InlineParent> it = ich.iterator(); it.hasNext(); ) {
-            InlineParent ic = it.next();
+        for (InlineParent ic : ich) {
             if (icOrig.search(ic) >= 0) {
                 break;
             } else {
                 icl.addFirst(ic);
             }
         }
-        for (Iterator<InlineParent> it = icl.iterator(); it.hasNext(); ) {
-            InlineParent ic = it.next();
+        for (InlineParent ic : icl) {
             icOrig.push(ic);
             icNew.push(generateInlineContainer(ic));
         }
@@ -307,8 +303,7 @@ class UnflattenProcessor {
     }
     private void updateIPD(TextArea tc) {
         int numAdjustable = 0;
-        for (Iterator it = tc.getChildAreas().iterator(); it.hasNext(); ) {
-            InlineArea ia = (InlineArea) it.next();
+        for (InlineArea ia : tc.getChildAreas()) {
             if (ia instanceof SpaceArea) {
                 SpaceArea sa = (SpaceArea) ia;
                 if (sa.isAdjustable()) {
index 25ff6034fb250b5574bae5c98a2d832696829806..b15fcbead99784cd47eeb61c3a3ab54b2390c0a3 100644 (file)
@@ -97,8 +97,7 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla
         if ((entries == null) || (entries.size() == 0)) {
             return false;
         } else {
-            for (Iterator it = entries.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : entries) {
                 if (!(o instanceof Integer)) {
                     return false;
                 }
@@ -111,8 +110,7 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla
         if ((entries == null) || (entries.size() == 0)) {
             return false;
         } else {
-            for (Iterator it = entries.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : entries) {
                 if (!(o instanceof MappingRange)) {
                     return false;
                 }
@@ -125,8 +123,7 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla
         if ((entries == null) || (entries.size() == 0)) {
             return false;
         } else {
-            for (Iterator it = entries.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : entries) {
                 if (!(o instanceof GlyphCoverageTable)) {
                     return false;
                 }
@@ -161,8 +158,8 @@ public final class GlyphClassTable extends GlyphMappingTable implements GlyphCla
             List entries = new java.util.ArrayList();
             entries.add(firstGlyph);
             if (gca != null) {
-                for (int i = 0, n = gca.length; i < n; i++) {
-                    entries.add(gca[i]);
+                for (int aGca : gca) {
+                    entries.add(aGca);
                 }
             }
             return entries;
index a4251e9ef485ff0f31fef2fa3c8a7ac425b0c120..aecebc3f02e840fbb5cf75f76d38f4b31960e592 100644 (file)
@@ -20,7 +20,6 @@
 package org.apache.fop.complexscripts.fonts;
 
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
@@ -99,8 +98,7 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph
         if ((entries == null) || (entries.size() == 0)) {
             return false;
         } else {
-            for (Iterator it = entries.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : entries) {
                 if (!(o instanceof Integer)) {
                     return false;
                 }
@@ -113,8 +111,7 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph
         if ((entries == null) || (entries.size() == 0)) {
             return false;
         } else {
-            for (Iterator it = entries.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : entries) {
                 if (!(o instanceof MappingRange)) {
                     return false;
                 }
@@ -146,8 +143,8 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph
         public List getEntries() {
             List entries = new java.util.ArrayList();
             if (map != null) {
-                for (int i = 0, n = map.length; i < n; i++) {
-                    entries.add(map[i]);
+                for (int aMap : map) {
+                    entries.add(aMap);
                 }
             }
             return entries;
@@ -178,13 +175,12 @@ public final class GlyphCoverageTable extends GlyphMappingTable implements Glyph
             int n = entries.size();
             int gidMax = -1;
             int[] map = new int [ n ];
-            for (Iterator it = entries.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : entries) {
                 if (o instanceof Integer) {
                     int gid = (Integer) o;
                     if ((gid >= 0) && (gid < 65536)) {
                         if (gid > gidMax) {
-                            map [ i++ ] = gidMax = gid;
+                            map[i++] = gidMax = gid;
                         } else {
                             log.info("ignoring out of order or duplicate glyph index: " + gid);
                             skipped++;
index 2ed1c2875f7184e0595d52e9604f2b4f58af6a74..aaba896361615d7e9d547f3466b92dfc3956cfaa 100644 (file)
@@ -20,7 +20,6 @@
 package org.apache.fop.complexscripts.fonts;
 
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
@@ -78,8 +77,7 @@ public class GlyphDefinitionTable extends GlyphTable {
         if ((subtables == null) || (subtables.size() == 0)) {
             throw new AdvancedTypographicTableFormatException("subtables must be non-empty");
         } else {
-            for (Iterator it = subtables.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : subtables) {
                 if (o instanceof GlyphDefinitionSubtable) {
                     addSubtable((GlyphSubtable) o);
                 } else {
index 469bb6211395d2a4cabb4f0b183fcfa31eeb121f..5511670b829d98c8c568d5fc4ac583c94ab7e421 100644 (file)
@@ -20,7 +20,6 @@
 package org.apache.fop.complexscripts.fonts;
 
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 
 // CSOFF: LineLengthCheck
@@ -186,8 +185,7 @@ public class GlyphMappingTable {
             int[] sa = new int [ n ];
             int[] ea = new int [ n ];
             int[] ma = new int [ n ];
-            for (Iterator it = entries.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : entries) {
                 if (o instanceof MappingRange) {
                     MappingRange r = (MappingRange) o;
                     int gs = r.getStart();
@@ -205,9 +203,9 @@ public class GlyphMappingTable {
                         throw new AdvancedTypographicTableFormatException("illegal mapping index: " + mi);
                     } else {
                         int miLast;
-                        sa [ i ] = gs;
-                        ea [ i ] = gidMax = ge;
-                        ma [ i ] = mi;
+                        sa[i] = gs;
+                        ea[i] = gidMax = ge;
+                        ma[i] = mi;
                         if ((miLast = mi + (ge - gs)) > miMax) {
                             miMax = miLast;
                         }
index 08c533860e6536c422a0b159c3f6455560337fbf..7dfc544541b28c7c308236c7b8f8b00111deda7e 100644 (file)
@@ -184,8 +184,7 @@ public class GlyphPositioningState extends GlyphProcessingState {
     public boolean apply(GlyphTable.RuleLookup[] lookups, int nig) {
         if ((lookups != null) && (lookups.length > 0)) {
             // apply each rule lookup to extracted input glyph array
-            for (int i = 0, n = lookups.length; i < n; i++) {
-                GlyphTable.RuleLookup l = lookups [ i ];
+            for (GlyphTable.RuleLookup l : lookups) {
                 if (l != null) {
                     GlyphTable.LookupTable lt = l.getLookup();
                     if (lt != null) {
index 705c0ff672dc1348be807f4547a93b8658ef355e..4713f02cfab237138e3c344acbcfab2878155328 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.complexscripts.fonts;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -76,8 +75,7 @@ public class GlyphPositioningTable extends GlyphTable {
         if ((subtables == null) || (subtables.size() == 0)) {
             throw new AdvancedTypographicTableFormatException("subtables must be non-empty");
         } else {
-            for (Iterator it = subtables.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : subtables) {
                 if (o instanceof GlyphPositioningSubtable) {
                     addSubtable((GlyphSubtable) o);
                 } else {
@@ -342,8 +340,8 @@ public class GlyphPositioningTable extends GlyphTable {
         public List getEntries() {
             if (values != null) {
                 List entries = new ArrayList(values.length);
-                for (int i = 0, n = values.length; i < n; i++) {
-                    entries.add(values[i]);
+                for (Value value : values) {
+                    entries.add(value);
                 }
                 return entries;
             } else {
@@ -487,8 +485,7 @@ public class GlyphPositioningTable extends GlyphTable {
         public PairValues getPairValues(int ci, int gi1, int gi2) {
             if ((pvm != null) && (ci < pvm.length)) {
                 PairValues[] pvt = pvm [ ci ];
-                for (int i = 0, n = pvt.length; i < n; i++) {
-                    PairValues pv = pvt [ i ];
+                for (PairValues pv : pvt) {
                     if (pv != null) {
                         int g = pv.getGlyph();
                         if (g < gi2) {
@@ -1225,8 +1222,7 @@ public class GlyphPositioningTable extends GlyphTable {
                 RuleSet rs = rsa [ 0 ];
                 if (rs != null) {
                     Rule[] ra = rs.getRules();
-                    for (int i = 0, n = ra.length; i < n; i++) {
-                        Rule r = ra [ i ];
+                    for (Rule r : ra) {
                         if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) {
                             ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r;
                             int[] iga = cr.getGlyphs(gi);
@@ -1313,8 +1309,7 @@ public class GlyphPositioningTable extends GlyphTable {
                 RuleSet rs = rsa [ 0 ];
                 if (rs != null) {
                     Rule[] ra = rs.getRules();
-                    for (int i = 0, n = ra.length; i < n; i++) {
-                        Rule r = ra [ i ];
+                    for (Rule r : ra) {
                         if ((r != null) && (r instanceof ChainedClassSequenceRule)) {
                             ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r;
                             int[] ca = cr.getClasses(cdt.getClassIndex(gi, ps.getClassMatchSet(gi)));
@@ -1415,8 +1410,7 @@ public class GlyphPositioningTable extends GlyphTable {
                 RuleSet rs = rsa [ 0 ];
                 if (rs != null) {
                     Rule[] ra = rs.getRules();
-                    for (int i = 0, n = ra.length; i < n; i++) {
-                        Rule r = ra [ i ];
+                    for (Rule r : ra) {
                         if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) {
                             ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r;
                             GlyphCoverageTable[] gca = cr.getCoverages();
@@ -1552,8 +1546,7 @@ public class GlyphPositioningTable extends GlyphTable {
                 RuleSet rs = rsa [ 0 ];
                 if (rs != null) {
                     Rule[] ra = rs.getRules();
-                    for (int i = 0, n = ra.length; i < n; i++) {
-                        Rule r = ra [ i ];
+                    for (Rule r : ra) {
                         if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) {
                             ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r;
                             int[] iga = cr.getGlyphs(gi);
@@ -1628,8 +1621,7 @@ public class GlyphPositioningTable extends GlyphTable {
                 RuleSet rs = rsa [ 0 ];
                 if (rs != null) {
                     Rule[] ra = rs.getRules();
-                    for (int i = 0, n = ra.length; i < n; i++) {
-                        Rule r = ra [ i ];
+                    for (Rule r : ra) {
                         if ((r != null) && (r instanceof ChainedClassSequenceRule)) {
                             ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r;
                             int[] ica = cr.getClasses(icdt.getClassIndex(gi, ps.getClassMatchSet(gi)));
@@ -1719,8 +1711,7 @@ public class GlyphPositioningTable extends GlyphTable {
                 RuleSet rs = rsa [ 0 ];
                 if (rs != null) {
                     Rule[] ra = rs.getRules();
-                    for (int i = 0, n = ra.length; i < n; i++) {
-                        Rule r = ra [ i ];
+                    for (Rule r : ra) {
                         if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) {
                             ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r;
                             GlyphCoverageTable[] igca = cr.getCoverages();
index da40bbd873743d450cc8779b34c93f92073396c2..0be47b8c1c1451071e0f01a8436486d14e1d19fb 100644 (file)
@@ -204,8 +204,7 @@ public class GlyphSubstitutionState extends GlyphProcessingState {
         int nog = 0;
         if ((lookups != null) && (lookups.length > 0)) {
             // apply each rule lookup to extracted input glyph array
-            for (int i = 0, n = lookups.length; i < n; i++) {
-                GlyphTable.RuleLookup l = lookups [ i ];
+            for (GlyphTable.RuleLookup l : lookups) {
                 if (l != null) {
                     GlyphTable.LookupTable lt = l.getLookup();
                     if (lt != null) {
index 35df1f48f69b53827cbdb6fb58cf1cfbffc716b8..26e3a35c701f80d4c276f6d1bfd06142e547f1ff 100644 (file)
@@ -20,7 +20,6 @@
 package org.apache.fop.complexscripts.fonts;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -74,8 +73,7 @@ public class GlyphSubstitutionTable extends GlyphTable {
         if ((subtables == null) || (subtables.size() == 0)) {
             throw new AdvancedTypographicTableFormatException("subtables must be non-empty");
         } else {
-            for (Iterator it = subtables.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : subtables) {
                 if (o instanceof GlyphSubstitutionSubtable) {
                     addSubtable((GlyphSubtable) o);
                 } else {
@@ -324,8 +322,8 @@ public class GlyphSubstitutionTable extends GlyphTable {
         /** {@inheritDoc} */
         public List getEntries() {
             List entries = new ArrayList(glyphs.length);
-            for (int i = 0, n = glyphs.length; i < n; i++) {
-                entries.add(glyphs[i]);
+            for (int glyph : glyphs) {
+                entries.add(glyph);
             }
             return entries;
         }
@@ -343,12 +341,11 @@ public class GlyphSubstitutionTable extends GlyphTable {
             int i = 0;
             int n = entries.size();
             int[] glyphs = new int [ n ];
-            for (Iterator it = entries.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : entries) {
                 if (o instanceof Integer) {
                     int gid = (Integer) o;
                     if ((gid >= 0) && (gid < 65536)) {
-                        glyphs [ i++ ] = gid;
+                        glyphs[i++] = gid;
                     } else {
                         throw new AdvancedTypographicTableFormatException("illegal glyph index: " + gid);
                     }
@@ -509,8 +506,8 @@ public class GlyphSubstitutionTable extends GlyphTable {
         /** {@inheritDoc} */
         public List getEntries() {
             List entries = new ArrayList(gaa.length);
-            for (int i = 0, n = gaa.length; i < n; i++) {
-                entries.add(gaa[i]);
+            for (int[] aGaa : gaa) {
+                entries.add(aGaa);
             }
             return entries;
         }
@@ -528,10 +525,9 @@ public class GlyphSubstitutionTable extends GlyphTable {
             int i = 0;
             int n = entries.size();
             int[][] gaa = new int [ n ][];
-            for (Iterator it = entries.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : entries) {
                 if (o instanceof int[]) {
-                    gaa [ i++ ] = (int[]) o;
+                    gaa[i++] = (int[]) o;
                 } else {
                     throw new AdvancedTypographicTableFormatException("illegal entries entry, must be int[]: " + o);
                 }
@@ -642,8 +638,8 @@ public class GlyphSubstitutionTable extends GlyphTable {
         /** {@inheritDoc} */
         public List getEntries() {
             List entries = new ArrayList(ligatureSets.length);
-            for (int i = 0, n = ligatureSets.length; i < n; i++) {
-                entries.add(ligatureSets[i]);
+            for (LigatureSet ligatureSet : ligatureSets) {
+                entries.add(ligatureSet);
             }
             return entries;
         }
@@ -661,10 +657,9 @@ public class GlyphSubstitutionTable extends GlyphTable {
             int i = 0;
             int n = entries.size();
             LigatureSet[] ligatureSets = new LigatureSet [ n ];
-            for (Iterator it = entries.iterator(); it.hasNext();) {
-                Object o = it.next();
+            for (Object o : entries) {
                 if (o instanceof LigatureSet) {
-                    ligatureSets [ i++ ] = (LigatureSet) o;
+                    ligatureSets[i++] = (LigatureSet) o;
                 } else {
                     throw new AdvancedTypographicTableFormatException("illegal ligatures entry, must be LigatureSet: " + o);
                 }
@@ -754,8 +749,7 @@ public class GlyphSubstitutionTable extends GlyphTable {
                 RuleSet rs = rsa [ 0 ];
                 if (rs != null) {
                     Rule[] ra = rs.getRules();
-                    for (int i = 0, n = ra.length; i < n; i++) {
-                        Rule r = ra [ i ];
+                    for (Rule r : ra) {
                         if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) {
                             ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r;
                             int[] iga = cr.getGlyphs(gi);
@@ -842,8 +836,7 @@ public class GlyphSubstitutionTable extends GlyphTable {
                 RuleSet rs = rsa [ 0 ];
                 if (rs != null) {
                     Rule[] ra = rs.getRules();
-                    for (int i = 0, n = ra.length; i < n; i++) {
-                        Rule r = ra [ i ];
+                    for (Rule r : ra) {
                         if ((r != null) && (r instanceof ChainedClassSequenceRule)) {
                             ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r;
                             int[] ca = cr.getClasses(cdt.getClassIndex(gi, ss.getClassMatchSet(gi)));
@@ -944,8 +937,7 @@ public class GlyphSubstitutionTable extends GlyphTable {
                 RuleSet rs = rsa [ 0 ];
                 if (rs != null) {
                     Rule[] ra = rs.getRules();
-                    for (int i = 0, n = ra.length; i < n; i++) {
-                        Rule r = ra [ i ];
+                    for (Rule r : ra) {
                         if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) {
                             ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r;
                             GlyphCoverageTable[] gca = cr.getCoverages();
@@ -1082,8 +1074,7 @@ public class GlyphSubstitutionTable extends GlyphTable {
                 RuleSet rs = rsa [ 0 ];
                 if (rs != null) {
                     Rule[] ra = rs.getRules();
-                    for (int i = 0, n = ra.length; i < n; i++) {
-                        Rule r = ra [ i ];
+                    for (Rule r : ra) {
                         if ((r != null) && (r instanceof ChainedGlyphSequenceRule)) {
                             ChainedGlyphSequenceRule cr = (ChainedGlyphSequenceRule) r;
                             int[] iga = cr.getGlyphs(gi);
@@ -1154,8 +1145,7 @@ public class GlyphSubstitutionTable extends GlyphTable {
                 RuleSet rs = rsa [ 0 ];
                 if (rs != null) {
                     Rule[] ra = rs.getRules();
-                    for (int i = 0, n = ra.length; i < n; i++) {
-                        Rule r = ra [ i ];
+                    for (Rule r : ra) {
                         if ((r != null) && (r instanceof ChainedClassSequenceRule)) {
                             ChainedClassSequenceRule cr = (ChainedClassSequenceRule) r;
                             int[] ica = cr.getClasses(icdt.getClassIndex(gi, ss.getClassMatchSet(gi)));
@@ -1249,8 +1239,7 @@ public class GlyphSubstitutionTable extends GlyphTable {
                 RuleSet rs = rsa [ 0 ];
                 if (rs != null) {
                     Rule[] ra = rs.getRules();
-                    for (int i = 0, n = ra.length; i < n; i++) {
-                        Rule r = ra [ i ];
+                    for (Rule r : ra) {
                         if ((r != null) && (r instanceof ChainedCoverageSequenceRule)) {
                             ChainedCoverageSequenceRule cr = (ChainedCoverageSequenceRule) r;
                             GlyphCoverageTable[] igca = cr.getCoverages();
@@ -1348,8 +1337,7 @@ public class GlyphSubstitutionTable extends GlyphTable {
             } else if (components == null) {
                 throw new AdvancedTypographicTableFormatException("invalid ligature components, must be non-null array");
             } else {
-                for (int i = 0, n = components.length; i < n; i++) {
-                    int gc = components [ i ];
+                for (int gc : components) {
                     if ((gc < 0) || (gc > 65535)) {
                         throw new AdvancedTypographicTableFormatException("invalid component glyph index: " + gc);
                     }
@@ -1436,8 +1424,7 @@ public class GlyphSubstitutionTable extends GlyphTable {
             } else {
                 this.ligatures = ligatures;
                 int ncMax = -1;
-                for (int i = 0, n = ligatures.length; i < n; i++) {
-                    Ligature l = ligatures [ i ];
+                for (Ligature l : ligatures) {
                     int nc = l.getNumComponents() + 1;
                     if (nc > ncMax) {
                         ncMax = nc;
index a53fdfd342dc7e77ed2f23e53f48e1f8a9a4805c..135901735e7c462572416cf15799999c6d05f909 100644 (file)
@@ -271,8 +271,8 @@ public abstract class GlyphSubtable implements Comparable {
         if ((subtables == null) || (subtables.length == 0)) {
             return false;
         } else {
-            for (int i = 0, n = subtables.length; i < n; i++) {
-                if (subtables[i].usesReverseScan()) {
+            for (GlyphSubtable subtable : subtables) {
+                if (subtable.usesReverseScan()) {
                     return true;
                 }
             }
@@ -292,16 +292,16 @@ public abstract class GlyphSubtable implements Comparable {
         } else {
             int flags = 0;
             // obtain first non-zero value of flags in array of subtables
-            for (int i = 0, n = subtables.length; i < n; i++) {
-                int f = subtables[i].getFlags();
+            for (GlyphSubtable subtable1 : subtables) {
+                int f = subtable1.getFlags();
                 if (flags == 0) {
                     flags = f;
                     break;
                 }
             }
             // enforce flag consistency
-            for (int i = 0, n = subtables.length; i < n; i++) {
-                int f = subtables[i].getFlags();
+            for (GlyphSubtable subtable : subtables) {
+                int f = subtable.getFlags();
                 if (f != flags) {
                     throw new IllegalStateException("inconsistent lookup flags " + f + ", expected " + flags);
                 }
index de5d8f824c95d2441c625ec00351cff0ff0fe169..46a724b88e464aafd6779f5beba8699be7906cfe 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.fop.complexscripts.fonts;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -117,8 +116,8 @@ public class GlyphTable {
     public List/*<LookupTable>*/ getLookupTables() {
         TreeSet/*<String>*/ lids = new TreeSet/*<String>*/(lookupTables.keySet());
         List/*<LookupTable>*/ ltl = new ArrayList/*<LookupTable>*/(lids.size());
-        for (Iterator it = lids.iterator(); it.hasNext(); ) {
-            String lid = (String) it.next();
+        for (Object lid1 : lids) {
+            String lid = (String) lid1;
             ltl.add(lookupTables.get(lid));
         }
         return ltl;
@@ -162,8 +161,8 @@ public class GlyphTable {
      */
     protected void freezeSubtables() {
         if (!frozen) {
-            for (Iterator it = lookupTables.values().iterator(); it.hasNext(); ) {
-                LookupTable lt = (LookupTable) it.next();
+            for (Object o : lookupTables.values()) {
+                LookupTable lt = (LookupTable) o;
                 lt.freezeSubtables(lookupTables);
             }
             frozen = true;
@@ -181,8 +180,8 @@ public class GlyphTable {
     public List/*<LookupSpec>*/ matchLookupSpecs(String script, String language, String feature) {
         Set/*<LookupSpec>*/ keys = lookups.keySet();
         List/*<LookupSpec>*/ matches = new ArrayList/*<LookupSpec>*/();
-        for (Iterator it = keys.iterator(); it.hasNext();) {
-            LookupSpec ls = (LookupSpec) it.next();
+        for (Object key : keys) {
+            LookupSpec ls = (LookupSpec) key;
             if (!"*".equals(script)) {
                 if (!ls.getScript().equals(script)) {
                     continue;
@@ -217,8 +216,8 @@ public class GlyphTable {
         if (lm == null) {
             lm = new LinkedHashMap();
             List/*<LookupSpec>*/ lsl = matchLookupSpecs(script, language, feature);
-            for (Iterator it = lsl.iterator(); it.hasNext(); ) {
-                LookupSpec ls = (LookupSpec) it.next();
+            for (Object aLsl : lsl) {
+                LookupSpec ls = (LookupSpec) aLsl;
                 lm.put(ls, findLookupTables(ls));
             }
             matchedLookups.put(lsm, lm);
@@ -239,8 +238,8 @@ public class GlyphTable {
         TreeSet/*<LookupTable>*/ lts = new TreeSet/*<LookupTable>*/();
         List/*<String>*/ ids;
         if ((ids = (List/*<String>*/) lookups.get(ls)) != null) {
-            for (Iterator it = ids.iterator(); it.hasNext();) {
-                String lid = (String) it.next();
+            for (Object id : ids) {
+                String lid = (String) id;
                 LookupTable lt;
                 if ((lt = (LookupTable) lookupTables.get(lid)) != null) {
                     lts.add(lt);
@@ -259,16 +258,15 @@ public class GlyphTable {
      */
     public UseSpec[] assembleLookups(String[] features, Map/*<LookupSpec,List<LookupTable>>*/ lookups) {
         TreeSet/*<UseSpec>*/ uss = new TreeSet/*<UseSpec>*/();
-        for (int i = 0, n = features.length; i < n; i++) {
-            String feature = features[i];
-            for (Iterator it = lookups.entrySet().iterator(); it.hasNext(); ) {
-                Map.Entry/*<LookupSpec,List<LookupTable>>*/ e = (Map.Entry/*<LookupSpec,List<LookupTable>>*/) it.next();
+        for (String feature : features) {
+            for (Object o : lookups.entrySet()) {
+                Map.Entry/*<LookupSpec,List<LookupTable>>*/ e = (Map.Entry/*<LookupSpec,List<LookupTable>>*/) o;
                 LookupSpec ls = (LookupSpec) e.getKey();
                 if (ls.getFeature().equals(feature)) {
                     List/*<LookupTable>*/ ltl = (List/*<LookupTable>*/) e.getValue();
                     if (ltl != null) {
-                        for (Iterator ltit = ltl.iterator(); ltit.hasNext(); ) {
-                            LookupTable lt = (LookupTable) ltit.next();
+                        for (Object aLtl : ltl) {
+                            LookupTable lt = (LookupTable) aLtl;
                             uss.add(new UseSpec(lt, feature));
                         }
                     }
@@ -334,8 +332,7 @@ public class GlyphTable {
      */
     public static void resolveLookupReferences(RuleSet[] rsa, Map/*<String,LookupTable>*/ lookupTables) {
         if ((rsa != null) && (lookupTables != null)) {
-            for (int i = 0, n = rsa.length; i < n; i++) {
-                RuleSet rs = rsa [ i ];
+            for (RuleSet rs : rsa) {
                 if (rs != null) {
                     rs.resolveLookupReferences(lookupTables);
                 }
@@ -498,8 +495,8 @@ public class GlyphTable {
             this.idOrdinal = Integer.parseInt(id.substring(2));
             this.subtables = new LinkedList/*<GlyphSubtable>*/();
             if (subtables != null) {
-                for (Iterator it = subtables.iterator(); it.hasNext(); ) {
-                    GlyphSubtable st = (GlyphSubtable) it.next();
+                for (Object subtable : subtables) {
+                    GlyphSubtable st = (GlyphSubtable) subtable;
                     addSubtable(st);
                 }
             }
@@ -600,8 +597,7 @@ public class GlyphTable {
 
         private void resolveLookupReferences(GlyphSubtable[] subtables, Map/*<String,LookupTable>*/ lookupTables) {
             if (subtables != null) {
-                for (int i = 0, n = subtables.length; i < n; i++) {
-                    GlyphSubtable st = subtables [ i ];
+                for (GlyphSubtable st : subtables) {
                     if (st != null) {
                         st.resolveLookupReferences(lookupTables);
                     }
@@ -936,8 +932,7 @@ public class GlyphTable {
          */
         public void resolveLookupReferences(Map/*<String,LookupTable>*/ lookupTables) {
             if (lookups != null) {
-                for (int i = 0, n = lookups.length; i < n; i++) {
-                    RuleLookup l = lookups [ i ];
+                for (RuleLookup l : lookups) {
                     if (l != null) {
                         l.resolveLookupReferences(lookupTables);
                     }
@@ -1274,8 +1269,7 @@ public class GlyphTable {
          */
         public void resolveLookupReferences(Map/*<String,LookupTable>*/ lookupTables) {
             if (rules != null) {
-                for (int i = 0, n = rules.length; i < n; i++) {
-                    Rule r = rules [ i ];
+                for (Rule r : rules) {
                     if (r != null) {
                         r.resolveLookupReferences(lookupTables);
                     }
index ca51e9a24b109077dd726d916fffb6e267a9fa2c..74bf803d8c8816b6ba8bf011dc2ee5a9e50808e1 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.complexscripts.fonts;
 
 import java.io.IOException;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -3577,8 +3576,8 @@ public final class OTFAdvancedTypographicTableReader {
     }
 
     private void constructLookupsFeatures(Map lookups, String st, String lt, List/*<String>*/ fids) {
-        for (Iterator fit = fids.iterator(); fit.hasNext();) {
-            String fid = (String) fit.next();
+        for (Object fid1 : fids) {
+            String fid = (String) fid1;
             constructLookupsFeature(lookups, st, lt, fid);
         }
     }
@@ -3597,16 +3596,16 @@ public final class OTFAdvancedTypographicTableReader {
     }
 
     private void constructLookupsLanguages(Map lookups, String st, List/*<String>*/ ll, Map/*<String,Object[2]>*/ languages) {
-        for (Iterator lit = ll.iterator(); lit.hasNext();) {
-            String lt = (String) lit.next();
+        for (Object aLl : ll) {
+            String lt = (String) aLl;
             constructLookupsLanguage(lookups, st, lt, languages);
         }
     }
 
     private Map constructLookups() {
         Map/*<GlyphTable.LookupSpec,List<String>>*/ lookups = new java.util.LinkedHashMap();
-        for (Iterator sit = seScripts.keySet().iterator(); sit.hasNext();) {
-            String st = (String) sit.next();
+        for (Object o : seScripts.keySet()) {
+            String st = (String) o;
             Object[] sp = (Object[]) seScripts.get(st);
             if (sp != null) {
                 assert sp.length == 3;
@@ -3625,8 +3624,8 @@ public final class OTFAdvancedTypographicTableReader {
     private List constructGDEFSubtables() {
         List/*<GlyphDefinitionSubtable>*/ subtables = new java.util.ArrayList();
         if (seSubtables != null) {
-            for (Iterator it = seSubtables.iterator(); it.hasNext();) {
-                Object[] stp = (Object[]) it.next();
+            for (Object seSubtable : seSubtables) {
+                Object[] stp = (Object[]) seSubtable;
                 GlyphSubtable st;
                 if ((st = constructGDEFSubtable(stp)) != null) {
                     subtables.add(st);
@@ -3661,8 +3660,8 @@ public final class OTFAdvancedTypographicTableReader {
     private List constructGSUBSubtables() {
         List/*<GlyphSubtable>*/ subtables = new java.util.ArrayList();
         if (seSubtables != null) {
-            for (Iterator it = seSubtables.iterator(); it.hasNext();) {
-                Object[] stp = (Object[]) it.next();
+            for (Object seSubtable : seSubtables) {
+                Object[] stp = (Object[]) seSubtable;
                 GlyphSubtable st;
                 if ((st = constructGSUBSubtable(stp)) != null) {
                     subtables.add(st);
@@ -3697,8 +3696,8 @@ public final class OTFAdvancedTypographicTableReader {
     private List constructGPOSSubtables() {
         List/*<GlyphSubtable>*/ subtables = new java.util.ArrayList();
         if (seSubtables != null) {
-            for (Iterator it = seSubtables.iterator(); it.hasNext();) {
-                Object[] stp = (Object[]) it.next();
+            for (Object seSubtable : seSubtables) {
+                Object[] stp = (Object[]) seSubtable;
                 GlyphSubtable st;
                 if ((st = constructGPOSSubtable(stp)) != null) {
                     subtables.add(st);
@@ -3786,13 +3785,13 @@ public final class OTFAdvancedTypographicTableReader {
             sb.append('-');
         } else {
             boolean first = true;
-            for (int i = 0; i < ia.length; i++) {
+            for (int anIa : ia) {
                 if (!first) {
                     sb.append(' ');
                 } else {
                     first = false;
                 }
-                sb.append(ia[i]);
+                sb.append(anIa);
             }
         }
         return sb.toString();
index 01d5c6d70ecf268d1666405e36c023898af659e9..9e7721121ae6024f487e25161994389ec8a673fe 100644 (file)
@@ -184,8 +184,7 @@ public class IndicScriptProcessor extends DefaultScriptProcessor {
         for (int i = 0, n = sa.length; i < n; i++) {
             GlyphSequence s = sa [ i ];
             // apply basic shaping subs
-            for (int j = 0, m = usa.length; j < m; j++) {
-                GlyphTable.UseSpec us = usa [ j ];
+            for (GlyphTable.UseSpec us : usa) {
                 if (isBasicShapingUse(us)) {
                     s.setPredications(true);
                     s = us.substitute(s, script, language, sct);
@@ -196,8 +195,7 @@ public class IndicScriptProcessor extends DefaultScriptProcessor {
             // reorder reph
             s = reorderReph(s);
             // apply presentation subs
-            for (int j = 0, m = usa.length; j < m; j++) {
-                GlyphTable.UseSpec us = usa [ j ];
+            for (GlyphTable.UseSpec us : usa) {
                 if (isPresentationUse(us)) {
                     s.setPredications(true);
                     s = us.substitute(s, script, language, sct);
@@ -503,19 +501,18 @@ public class IndicScriptProcessor extends DefaultScriptProcessor {
             int[] ga = gs.getGlyphArray(false);
             CharAssociation[] aa = gs.getAssociations(0, -1);
             Vector<GlyphSequence> nsv = new Vector<GlyphSequence>();
-            for (int i = 0, ns = sa.length; i < ns; i++) {
-                Segment s = sa [ i ];
+            for (Segment s : sa) {
                 Vector<Integer> ngv = new Vector<Integer>(ng);
                 Vector<CharAssociation> nav = new Vector<CharAssociation>(ng);
                 for (int j = 0; j < ng; j++) {
-                    CharAssociation ca = aa [ j ];
+                    CharAssociation ca = aa[j];
                     if (ca.contained(s.getOffset(), s.getCount())) {
-                        ngv.add(ga [ j ]);
+                        ngv.add(ga[j]);
                         nav.add(ca);
                     }
                 }
                 if (ngv.size() > 0) {
-                    nsv.add(new GlyphSequence(gs, null, toIntArray(ngv), null, null, nav.toArray(new CharAssociation [ nav.size() ]), null));
+                    nsv.add(new GlyphSequence(gs, null, toIntArray(ngv), null, null, nav.toArray(new CharAssociation[nav.size()]), null));
                 }
             }
             if (nsv.size() > 0) {
index d492045f1e0d5997378275a1cbe87d2b4b758ce7..82dc822be2d1bc7ec9af5e0a9a916abdd27617fb 100644 (file)
@@ -109,8 +109,7 @@ public abstract class ScriptProcessor {
      */
     public GlyphSequence substitute(GlyphSequence gs, String script, String language, GlyphTable.UseSpec[] usa, ScriptContextTester sct) {
         assert usa != null;
-        for (int i = 0, n = usa.length; i < n; i++) {
-            GlyphTable.UseSpec us = usa [ i ];
+        for (GlyphTable.UseSpec us : usa) {
             gs = us.substitute(gs, script, language, sct);
         }
         return gs;
@@ -186,8 +185,7 @@ public abstract class ScriptProcessor {
     public boolean position(GlyphSequence gs, String script, String language, int fontSize, GlyphTable.UseSpec[] usa, int[] widths, int[][] adjustments, ScriptContextTester sct) {
         assert usa != null;
         boolean adjusted = false;
-        for (int i = 0, n = usa.length; i < n; i++) {
-            GlyphTable.UseSpec us = usa [ i ];
+        for (GlyphTable.UseSpec us : usa) {
             if (us.position(gs, script, language, fontSize, widths, adjustments, sct)) {
                 adjusted = true;
             }
index 23aebbb9a812fa11567468bfd324b333a5152f75..f5d15b3034e8f1703fe4a0bf36f5ac636c202b3d 100644 (file)
@@ -358,8 +358,7 @@ public class CharAssociation implements Cloneable {
      */
     private static int[] extractIntervals(CharAssociation[] aa) {
         int ni = 0;
-        for (int i = 0, n = aa.length; i < n; i++) {
-            CharAssociation a = aa [ i ];
+        for (CharAssociation a : aa) {
             if (a.isDisjoint()) {
                 ni += a.getSubIntervalCount();
             } else {
@@ -401,25 +400,25 @@ public class CharAssociation implements Cloneable {
         assert sa.length == ea.length;
         int ni = sa.length;
         int[] incr = (ni < 21) ? SORT_INCREMENTS_03 : SORT_INCREMENTS_16;
-        for (int k = 0; k < incr.length; k++) {
-            for (int h = incr [ k ], i = h, n = ni, j; i < n; i++) {
-                int s1 = sa [ i ];
-                int e1 = ea [ i ];
+        for (int anIncr : incr) {
+            for (int h = anIncr, i = h, n = ni, j; i < n; i++) {
+                int s1 = sa[i];
+                int e1 = ea[i];
                 for (j = i; j >= h; j -= h) {
-                    int s2 = sa [ j - h ];
-                    int e2 = ea [ j - h ];
+                    int s2 = sa[j - h];
+                    int e2 = ea[j - h];
                     if (s2 > s1) {
-                        sa [ j ] = s2;
-                        ea [ j ] = e2;
+                        sa[j] = s2;
+                        ea[j] = e2;
                     } else if ((s2 == s1) && (e2 > e1)) {
-                        sa [ j ] = s2;
-                        ea [ j ] = e2;
+                        sa[j] = s2;
+                        ea[j] = e2;
                     } else {
                         break;
                     }
                 }
-                sa [ j ] = s1;
-                ea [ j ] = e1;
+                sa[j] = s1;
+                ea[j] = e1;
             }
         }
         int[] ia = new int [ ni * 2 ];
index e82bb4779927b0176a876bad48084b3a603ec987..dbe98f19fa1cc7733c5e23ad65a764173b552c3a 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.fop.complexscripts.util;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
@@ -712,8 +711,8 @@ public final class CharScript {
         }
         int[] sa = new int [ s.size() ];
         int ns = 0;
-        for (Iterator it = s.iterator(); it.hasNext();) {
-            sa [ ns++ ] = (Integer) it.next();
+        for (Object value : s) {
+            sa[ns++] = (Integer) value;
         }
         Arrays.sort(sa);
         return sa;
@@ -739,23 +738,23 @@ public final class CharScript {
         }
         int sMax = -1;
         int cMax = -1;
-        for (Iterator it = m.entrySet().iterator(); it.hasNext();) {
-            Map.Entry e = (Map.Entry) it.next();
+        for (Object o : m.entrySet()) {
+            Map.Entry e = (Map.Entry) o;
             Integer k = (Integer) e.getKey();
             int s = k;
             switch (s) {
-            case SCRIPT_UNDETERMINED:
-            case SCRIPT_UNCODED:
-                break;
-            default:
-                Integer v = (Integer) e.getValue();
-                assert v != null;
-                int c = v;
-                if (c > cMax) {
-                    cMax = c;
-                    sMax = s;
-                }
-                break;
+                case SCRIPT_UNDETERMINED:
+                case SCRIPT_UNCODED:
+                    break;
+                default:
+                    Integer v = (Integer) e.getValue();
+                    assert v != null;
+                    int c = v;
+                    if (c > cMax) {
+                        cMax = c;
+                        sMax = s;
+                    }
+                    break;
             }
         }
         if (sMax < 0) {
index 2b1d636e1572dcac7e578e1e52f7c5c769d17018..72fc357f00242354a68dddff226418c405db919f 100644 (file)
@@ -459,18 +459,18 @@ public class GlyphSequence implements Cloneable {
         if (na > 0) {
             List gl = new ArrayList(na);
             if (baa != null) {
-                for (int i = 0; i < baa.length; i++) {
-                    gl.add(baa[i]);
+                for (CharAssociation aBaa : baa) {
+                    gl.add(aBaa);
                 }
             }
             if (iaa != null) {
-                for (int i = 0; i < iaa.length; i++) {
-                    gl.add(iaa[i]);
+                for (CharAssociation anIaa : iaa) {
+                    gl.add(anIaa);
                 }
             }
             if (laa != null) {
-                for (int i = 0; i < laa.length; i++) {
-                    gl.add(laa[i]);
+                for (CharAssociation aLaa : laa) {
+                    gl.add(aLaa);
                 }
             }
             return gl;
@@ -489,8 +489,7 @@ public class GlyphSequence implements Cloneable {
         assert sa != null;
         int tg = 0;
         int ta = 0;
-        for (int i = 0, n = sa.length; i < n; i++) {
-            GlyphSequence s = sa [ i ];
+        for (GlyphSequence s : sa) {
             IntBuffer ga = s.getGlyphs();
             assert ga != null;
             int ng = ga.limit();
@@ -503,8 +502,7 @@ public class GlyphSequence implements Cloneable {
         }
         IntBuffer uga = IntBuffer.allocate(tg);
         ArrayList ual = new ArrayList(ta);
-        for (int i = 0, n = sa.length; i < n; i++) {
-            GlyphSequence s = sa [ i ];
+        for (GlyphSequence s : sa) {
             uga.put(s.getGlyphs());
             ual.addAll(s.getAssociations());
         }
index 817f70a18dd258a5bb5c58d2b5c392d052082f90..6a21851fa0c9874fb2e651a254772297f5136238 100644 (file)
@@ -160,15 +160,14 @@ public class NumberConverter {
         int tokenType = TOKEN_NONE;
         List<Integer> token = new ArrayList<Integer>();
         Integer[] ca = UTF32.toUTF32(format, 0, true);
-        for (int i = 0, n = ca.length; i < n; i++) {
-            int c = ca[i];
+        for (Integer c : ca) {
             int tokenTypeNew = isAlphaNumeric(c) ? TOKEN_ALPHANUMERIC : TOKEN_NONALPHANUMERIC;
             if (tokenTypeNew != tokenType) {
                 if (token.size() > 0) {
                     if (tokenType == TOKEN_ALPHANUMERIC) {
-                        tokens.add(token.toArray(new Integer [ token.size() ]));
+                        tokens.add(token.toArray(new Integer[token.size()]));
                     } else {
-                        separators.add(token.toArray(new Integer [ token.size() ]));
+                        separators.add(token.toArray(new Integer[token.size()]));
                     }
                     token.clear();
                 }
@@ -429,8 +428,8 @@ public class NumberConverter {
         for (String[] el : equivalentLanguages) {
             assert el.length >= 2;
             if (el[0].equals(i3c)) {
-                for (int i = 0, n = el.length; i < n; i++) {
-                    if (el[i].equals(lc)) {
+                for (String anEl : el) {
+                    if (anEl.equals(lc)) {
                         return true;
                     }
                 }
index 9beb817d0acd0d92d3528b1f5531ed14bd6df140..718d846954b93afe37c2364116b22a574651dda2 100644 (file)
@@ -132,8 +132,8 @@ public final class URISpecification {
             } else {
                 try {
                     byte[] utf8 = Character.toString(ch).getBytes("UTF-8");
-                    for (int j = 0, cj = utf8.length; j < cj; j++) {
-                        appendEscape(sb, utf8[j]);
+                    for (byte anUtf8 : utf8) {
+                        appendEscape(sb, anUtf8);
                     }
                 } catch (UnsupportedEncodingException e) {
                     throw new Error("Incompatible JVM. UTF-8 not supported.");
index 0af17996df5e10044893abc8dcc12b30a6ad0fad..1a7e6fe3f77d0a9b627b87c018cc87a7478f2792 100644 (file)
@@ -121,8 +121,8 @@ class CollapsingBorderResolver implements BorderResolver {
         /** Integrates the border-after of the part. */
         void resolveBordersLastRowInPart(List/*<GridUnit>*/ row, boolean withNormal,
                 boolean withLeadingTrailing, boolean withRest) {
-            for (int i = 0; i < row.size(); i++) {
-                ((GridUnit) row.get(i)).integrateBorderSegment(CommonBorderPaddingBackground.AFTER,
+            for (Object aRow : row) {
+                ((GridUnit) aRow).integrateBorderSegment(CommonBorderPaddingBackground.AFTER,
                         tablePart, withNormal, withLeadingTrailing, withRest);
             }
         }
@@ -203,8 +203,8 @@ class CollapsingBorderResolver implements BorderResolver {
             // Resolve before- and after-borders for the table-row
             if (container instanceof TableRow) {
                 TableRow tableRow = (TableRow) container;
-                for (Iterator iter = row.iterator(); iter.hasNext();) {
-                    GridUnit gu = (GridUnit) iter.next();
+                for (Object aRow : row) {
+                    GridUnit gu = (GridUnit) aRow;
                     boolean first = (gu.getRowSpanIndex() == 0);
                     boolean last = gu.isLastGridUnitRowSpan();
                     gu.integrateBorderSegment(CommonBorderPaddingBackground.BEFORE, tableRow,
@@ -219,8 +219,8 @@ class CollapsingBorderResolver implements BorderResolver {
             }
             if (firstInPart) {
                 // Integrate the border-before of the part
-                for (int i = 0; i < row.size(); i++) {
-                    ((GridUnit) row.get(i)).integrateBorderSegment(
+                for (Object aRow : row) {
+                    ((GridUnit) aRow).integrateBorderSegment(
                             CommonBorderPaddingBackground.BEFORE, tablePart, true, true, true);
                 }
                 firstInPart = false;
@@ -269,8 +269,8 @@ class CollapsingBorderResolver implements BorderResolver {
                  * To represent those values we (ab)use the normal and the rest fields of
                  * ConditionalBorder. But strictly speaking this is not their purposes.
                  */
-                for (Iterator guIter = row.iterator(); guIter.hasNext();) {
-                    ConditionalBorder borderBefore = ((GridUnit) guIter.next()).borderBefore;
+                for (Object aRow : row) {
+                    ConditionalBorder borderBefore = ((GridUnit) aRow).borderBefore;
                     borderBefore.leadingTrailing = borderBefore.normal;
                     borderBefore.rest = borderBefore.normal;
                 }
@@ -291,8 +291,8 @@ class CollapsingBorderResolver implements BorderResolver {
              * grid units from the body will always resolve against the same, normal
              * header border.
              */
-            for (Iterator guIter = previousRow.iterator(); guIter.hasNext();) {
-                ConditionalBorder borderAfter = ((GridUnit) guIter.next()).borderAfter;
+            for (Object aPreviousRow : previousRow) {
+                ConditionalBorder borderAfter = ((GridUnit) aPreviousRow).borderAfter;
                 borderAfter.leadingTrailing = borderAfter.normal;
                 borderAfter.rest = borderAfter.normal;
                 leadingBorders.add(borderAfter);
@@ -324,8 +324,8 @@ class CollapsingBorderResolver implements BorderResolver {
             resolveBordersLastRowInPart(footerLastRow, true, true, true);
             trailingBorders = new ArrayList(table.getNumberOfColumns());
             // See same method in ResolverInHeader for an explanation of the hack
-            for (Iterator guIter = footerFirstRow.iterator(); guIter.hasNext();) {
-                ConditionalBorder borderBefore = ((GridUnit) guIter.next()).borderBefore;
+            for (Object aFooterFirstRow : footerFirstRow) {
+                ConditionalBorder borderBefore = ((GridUnit) aFooterFirstRow).borderBefore;
                 borderBefore.leadingTrailing = borderBefore.normal;
                 borderBefore.rest = borderBefore.normal;
                 trailingBorders.add(borderBefore);
@@ -337,8 +337,8 @@ class CollapsingBorderResolver implements BorderResolver {
             // first row of table-footer
             resolveBordersBetweenRows(previousRow, footerFirstRow);
             // See endRow method in ResolverInHeader for an explanation of the hack
-            for (Iterator guIter = footerLastRow.iterator(); guIter.hasNext();) {
-                ConditionalBorder borderAfter = ((GridUnit) guIter.next()).borderAfter;
+            for (Object aFooterLastRow : footerLastRow) {
+                ConditionalBorder borderAfter = ((GridUnit) aFooterLastRow).borderAfter;
                 borderAfter.leadingTrailing = borderAfter.normal;
                 borderAfter.rest = borderAfter.normal;
             }
@@ -364,8 +364,8 @@ class CollapsingBorderResolver implements BorderResolver {
             previousRow = row;
             if (firstInBody) {
                 firstInBody = false;
-                for (Iterator iter = row.iterator(); iter.hasNext();) {
-                    GridUnit gu = (GridUnit) iter.next();
+                for (Object aRow : row) {
+                    GridUnit gu = (GridUnit) aRow;
                     gu.borderBefore.leadingTrailing = gu.borderBefore.normal;
                 }
             }
@@ -378,8 +378,8 @@ class CollapsingBorderResolver implements BorderResolver {
                 // Trailing and rest borders already resolved with integrateTrailingBorders
                 resolveBordersLastRowInTable(previousRow, true, false, false);
             }
-            for (Iterator iter = previousRow.iterator(); iter.hasNext();) {
-                GridUnit gu = (GridUnit) iter.next();
+            for (Object aPreviousRow : previousRow) {
+                GridUnit gu = (GridUnit) aPreviousRow;
                 gu.borderAfter.leadingTrailing = gu.borderAfter.normal;
             }
         }
@@ -422,8 +422,8 @@ class CollapsingBorderResolver implements BorderResolver {
             if (leadingBorders == null || table.omitHeaderAtBreak()) {
                 // No header, leading borders determined by the table
                 leadingBorders = new ArrayList(table.getNumberOfColumns());
-                for (Iterator colIter = table.getColumns().iterator(); colIter.hasNext();) {
-                    ConditionalBorder border = ((TableColumn) colIter.next()).borderBefore;
+                for (Object o : table.getColumns()) {
+                    ConditionalBorder border = ((TableColumn) o).borderBefore;
                     leadingBorders.add(border);
                 }
             }
@@ -434,8 +434,8 @@ class CollapsingBorderResolver implements BorderResolver {
                 if (trailingBorders == null || table.omitFooterAtBreak()) {
                     // No footer, trailing borders determined by the table
                     trailingBorders = new ArrayList(table.getNumberOfColumns());
-                    for (Iterator colIter = table.getColumns().iterator(); colIter.hasNext();) {
-                        ConditionalBorder border = ((TableColumn) colIter.next()).borderAfter;
+                    for (Object o : table.getColumns()) {
+                        ConditionalBorder border = ((TableColumn) o).borderAfter;
                         trailingBorders.add(border);
                     }
                 }
@@ -456,14 +456,14 @@ class CollapsingBorderResolver implements BorderResolver {
         delegate = null;
         /* TODO Temporary hack for resolved borders in header */
         if (headerLastRow != null) {
-            for (Iterator iter = headerLastRow.iterator(); iter.hasNext();) {
-                GridUnit gu = (GridUnit) iter.next();
+            for (Object aHeaderLastRow : headerLastRow) {
+                GridUnit gu = (GridUnit) aHeaderLastRow;
                 gu.borderAfter.leadingTrailing = gu.borderAfter.normal;
             }
         }
         if (footerLastRow != null) {
-            for (Iterator iter = footerLastRow.iterator(); iter.hasNext();) {
-                GridUnit gu = (GridUnit) iter.next();
+            for (Object aFooterLastRow : footerLastRow) {
+                GridUnit gu = (GridUnit) aFooterLastRow;
                 gu.borderAfter.leadingTrailing = gu.borderAfter.normal;
             }
         }
index a5853cd9187b40699e2477e4ae07bfd01944c6f2..450aaec14d892b5b89d2b9367f682aebb7747e86 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.fop.fo.flow.table;
 
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.fop.fo.Constants;
@@ -57,8 +56,7 @@ public class EffRow {
         this.bodyType = bodyType;
         this.gridUnits = gridUnits;
         // TODO this is ugly, but we may eventually be able to do without that index
-        for (Iterator guIter = gridUnits.iterator(); guIter.hasNext();) {
-            Object gu = guIter.next();
+        for (Object gu : gridUnits) {
             if (gu instanceof PrimaryGridUnit) {
                 ((PrimaryGridUnit) gu).setRowIndex(index);
             }
@@ -175,8 +173,8 @@ public class EffRow {
         if (row != null) {
             keep = Keep.getKeep(row.getKeepWithPrevious());
         }
-        for (Iterator iter = gridUnits.iterator(); iter.hasNext();) {
-            GridUnit gu = (GridUnit) iter.next();
+        for (Object gridUnit : gridUnits) {
+            GridUnit gu = (GridUnit) gridUnit;
             if (gu.isPrimary()) {
                 keep = keep.compare(gu.getPrimary().getKeepWithPrevious());
             }
@@ -196,8 +194,8 @@ public class EffRow {
         if (row != null) {
             keep = Keep.getKeep(row.getKeepWithNext());
         }
-        for (Iterator iter = gridUnits.iterator(); iter.hasNext();) {
-            GridUnit gu = (GridUnit) iter.next();
+        for (Object gridUnit : gridUnits) {
+            GridUnit gu = (GridUnit) gridUnit;
             if (!gu.isEmpty() && gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()) {
                 keep = keep.compare(gu.getPrimary().getKeepWithNext());
             }
@@ -233,8 +231,8 @@ public class EffRow {
      */
     public int getBreakBefore() {
         int breakBefore = Constants.EN_AUTO;
-        for (Iterator iter = gridUnits.iterator(); iter.hasNext();) {
-            GridUnit gu = (GridUnit) iter.next();
+        for (Object gridUnit : gridUnits) {
+            GridUnit gu = (GridUnit) gridUnit;
             if (gu.isPrimary()) {
                 breakBefore = BreakUtil.compareBreakClasses(breakBefore,
                         gu.getPrimary().getBreakBefore());
@@ -257,8 +255,8 @@ public class EffRow {
      */
     public int getBreakAfter() {
         int breakAfter = Constants.EN_AUTO;
-        for (Iterator iter = gridUnits.iterator(); iter.hasNext();) {
-            GridUnit gu = (GridUnit) iter.next();
+        for (Object gridUnit : gridUnits) {
+            GridUnit gu = (GridUnit) gridUnit;
             if (!gu.isEmpty() && gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()) {
                 breakAfter = BreakUtil.compareBreakClasses(breakAfter,
                         gu.getPrimary().getBreakAfter());
index c3aa9e71063dd74f99b6985367bd8923578daf5c..7376873bb629cba836bde4909470f980702c4dec 100644 (file)
@@ -20,9 +20,7 @@
 package org.apache.fop.fo.flow.table;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import java.util.ListIterator;
 
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.ValidationException;
@@ -106,8 +104,8 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
     }
 
     private static void setFlagForCols(int flag, List row) {
-        for (ListIterator iter = row.listIterator(); iter.hasNext();) {
-            ((GridUnit) iter.next()).setFlag(flag);
+        for (Object aRow : row) {
+            ((GridUnit) aRow).setFlag(flag);
         }
     }
 
@@ -132,8 +130,8 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
             eventProducer.breakIgnoredDueToRowSpanning(this, currentTableRow.getName(), false,
                     currentTableRow.getLocator());
         }
-        for (Iterator iter = ((List) rows.get(currentRowIndex)).iterator(); iter.hasNext();) {
-            GridUnit gu = (GridUnit) iter.next();
+        for (Object o : ((List) rows.get(currentRowIndex))) {
+            GridUnit gu = (GridUnit) o;
             // The row hasn't been filled with empty grid units yet
             if (gu != null) {
                 gu.setRow(currentTableRow);
index 84b4c37695b507113dae5ec22118ce2f7d74d620..792fb1f15d39f41694c4ea0c9019d41c2d111c09 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.fop.fo.flow.table;
 
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -112,8 +111,8 @@ class VariableColRowGroupBuilder extends RowGroupBuilder {
     /** {@inheritDoc} */
     void endTable() throws ValidationException {
         RowGroupBuilder delegate = new FixedColRowGroupBuilder(table);
-        for (Iterator eventIter = events.iterator(); eventIter.hasNext();) {
-            ((Event) eventIter.next()).play(delegate);
+        for (Object event : events) {
+            ((Event) event).play(delegate);
         }
         delegate.endTable();
     }
index 4860a07acb69ec4c00d64a1c281a0e12f7411e4d..7dc1556e6cf5c465799dff67fe2cdf01bc7cf4b6 100644 (file)
@@ -64,8 +64,8 @@ public class DimensionPropertyMaker extends CorrespondingPropertyMaker {
         if (super.isCorrespondingForced(propertyList)) {
             return true;
         }
-        for (int i = 0; i < extraCorresponding.length; i++) {
-            int wmcorr = extraCorresponding[i][0]; //propertyList.getWritingMode()];
+        for (int[] anExtraCorresponding : extraCorresponding) {
+            int wmcorr = anExtraCorresponding[0]; //propertyList.getWritingMode()];
             if (propertyList.getExplicit(wmcorr) != null) {
                 return true;
             }
index 35231e224c1c0a437990a0968fcd0f6d8c598f4c..d12004e7257c2970331aa5c8e659a083c7003ce9 100644 (file)
@@ -53,9 +53,7 @@ public class CustomFontCollection implements FontCollection {
 
         String internalName = null;
 
-        for (int i = 0; i < embedFontInfoList.size(); i++) {
-            EmbedFontInfo embedFontInfo = embedFontInfoList.get(i);
-
+        for (EmbedFontInfo embedFontInfo : embedFontInfoList) {
             internalName = "F" + num;
             num++;
 
@@ -63,8 +61,7 @@ public class CustomFontCollection implements FontCollection {
             fontInfo.addMetrics(internalName, font);
 
             List<FontTriplet> triplets = embedFontInfo.getFontTriplets();
-            for (int tripletIndex = 0; tripletIndex < triplets.size(); tripletIndex++) {
-                FontTriplet triplet = triplets.get(tripletIndex);
+            for (FontTriplet triplet : triplets) {
                 fontInfo.addFontProperties(internalName, triplet);
             }
         }
index 55a1dfa98168d9df07c3063295e419909267ee71..c8d1c00e274ce827800b61bcc8e7b2b6de39b8c3 100644 (file)
@@ -179,8 +179,7 @@ public class DefaultFontConfigurator implements FontConfigurator<EmbedFontInfo>
             URI embedFile = embedFontInfo.getEmbedURI();
             log.debug("Adding font " + (embedFile != null ? embedFile + ", " : "")
                     + "metrics URI " + embedFontInfo.getMetricsURI());
-            for (int j = 0; j < tripletList.size(); ++j) {
-                FontTriplet triplet = tripletList.get(j);
+            for (FontTriplet triplet : tripletList) {
                 log.debug("  Font triplet "
                         + triplet.getName() + ", "
                         + triplet.getStyle() + ", "
index f585dbfa555a21e07fadb088ead7cffbb40e6219..97336287cee90f80fa005eaf8f0d7d64f133da09 100644 (file)
@@ -64,8 +64,7 @@ public class FontAdder {
             if (embedFontInfos == null) {
                 continue;
             }
-            for (int i = 0, c = embedFontInfos.length; i < c; i++) {
-                EmbedFontInfo fontInfo = embedFontInfos[i];
+            for (EmbedFontInfo fontInfo : embedFontInfos) {
                 if (fontInfo != null) {
                     fontInfoList.add(fontInfo);
                 }
index 8379ac137d9c493c9802f807c32872fb94fb1f7f..dd2450e4d868922303f3aaa9d3916e9bb9125766 100644 (file)
@@ -284,8 +284,7 @@ public final class FontCache implements Serializable {
      * @return file font file
      */
     public static File getFileFromUrls(String[] urls) {
-        for (int i = 0; i < urls.length; i++) {
-            String urlStr = urls[i];
+        for (String urlStr : urls) {
             if (urlStr != null) {
                 File fontFile = null;
                 if (urlStr.startsWith("file:")) {
index b2cf38189456e0eb1fa85c4b4fd8d7c4f5a981b7..e548448291bc6f71d14eeb662b8142d67022487b 100644 (file)
@@ -113,8 +113,8 @@ public class FontInfo {
      * @param weight font weight
      */
     public void addFontProperties(String name, String[] families, String style, int weight) {
-        for (int i = 0; i < families.length; i++) {
-            addFontProperties(name, families[i], style, weight);
+        for (String family : families) {
+            addFontProperties(name, family, style, weight);
         }
     }
 
@@ -382,8 +382,8 @@ public class FontInfo {
     private List<FontTriplet> fontLookup(String[] families, String style, int weight, boolean substitutable) {
         List<FontTriplet> matchingTriplets = new ArrayList<FontTriplet>();
         FontTriplet triplet = null;
-        for (int i = 0; i < families.length; i++) {
-            triplet = fontLookup(families[i], style, weight, substitutable);
+        for (String family : families) {
+            triplet = fontLookup(family, style, weight, substitutable);
             if (triplet != null) {
                 matchingTriplets.add(triplet);
             }
index 266220d14ffc6fc49d3e2be9185257adbd2d3205..049a2640facc07a15402cdd1b36d6deaa2c95fd2 100644 (file)
@@ -159,8 +159,8 @@ public class FontManager {
     public void setup(FontInfo fontInfo, FontCollection[] fontCollections) {
         int startNum = 1;
 
-        for (int i = 0, c = fontCollections.length; i < c; i++) {
-            startNum = fontCollections[i].setup(startNum, fontInfo);
+        for (FontCollection fontCollection : fontCollections) {
+            startNum = fontCollection.setup(startNum, fontInfo);
         }
         // Make any defined substitutions in the font info
         getFontSubstitutions().adjustFontInfo(fontInfo);
index 72c1684b66db462bf089b13fc95818e847412b54..01502c5c2285bf1e59bf1ab7397b3decc8d599d2 100644 (file)
@@ -147,10 +147,10 @@ public class FontManagerConfigurator {
             Configuration cfg, boolean strict) throws FOPException {
         List<FontTriplet.Matcher> matcherList = new java.util.ArrayList<FontTriplet.Matcher>();
         Configuration[] matches = cfg.getChildren("match");
-        for (int i = 0; i < matches.length; i++) {
+        for (Configuration matche : matches) {
             try {
                 matcherList.add(new FontFamilyRegExFontTripletMatcher(
-                        matches[i].getAttribute("font-family")));
+                        matche.getAttribute("font-family")));
             } catch (ConfigurationException ce) {
                 LogUtil.handleException(log, ce, strict);
                 continue;
@@ -189,8 +189,8 @@ public class FontManagerConfigurator {
 
         /** {@inheritDoc} */
         public boolean matches(FontTriplet triplet) {
-            for (int i = 0, c = matchers.length; i < c; i++) {
-                if (matchers[i].matches(triplet)) {
+            for (FontTriplet.Matcher matcher : matchers) {
+                if (matcher.matches(triplet)) {
                     return true;
                 }
             }
index a80a0e3686064d0304bce40ba91a9e3654936f13..66c30b21b54ab78db275630be3b0d144585aca64 100644 (file)
@@ -40,8 +40,8 @@ public final class FontSelector {
             CommonFont commonFont, PercentBaseContext context) {
         FontInfo fi = fonode.getFOEventHandler().getFontInfo();
         FontTriplet[] fontkeys = commonFont.getFontState(fi);
-        for (int i = 0; i < fontkeys.length; i++) {
-            Font font = fi.getFontInstance(fontkeys[i], commonFont.fontSize
+        for (FontTriplet fontkey : fontkeys) {
+            Font font = fi.getFontInstance(fontkey, commonFont.fontSize
                     .getValue(context));
             if (font.hasChar(c)) {
                 return font;
index f9bae3332f166239dc8c9773e923eeae7ed427e2..50586784a93a40e74943c9306d45d77542cdd063 100644 (file)
@@ -208,8 +208,7 @@ public final class FontSetup {
             fontInfo.addMetrics(internalName, font);
 
             List<FontTriplet> triplets = embedFontInfo.getFontTriplets();
-            for (int tripletIndex = 0; tripletIndex < triplets.size(); tripletIndex++) {
-                FontTriplet triplet = triplets.get(tripletIndex);
+            for (FontTriplet triplet : triplets) {
                 fontInfo.addFontProperties(internalName, triplet);
             }
         }
index 1966d9fca7d208853593dfc7efd8491305b18afe..5c95c81bfd4042dd3a72e0440193b33aa547dcf0 100644 (file)
@@ -104,8 +104,8 @@ public final class FontUtil {
      */
     public static String guessStyle(String fontName) {
         if (fontName != null) {
-            for (int i = 0; i < ITALIC_WORDS.length; i++) {
-                if (fontName.indexOf(ITALIC_WORDS[i]) != -1) {
+            for (String word : ITALIC_WORDS) {
+                if (fontName.indexOf(word) != -1) {
                     return Font.STYLE_ITALIC;
                 }
             }
@@ -122,34 +122,34 @@ public final class FontUtil {
         // weight
         int weight = Font.WEIGHT_NORMAL;
 
-        for (int i = 0; i < BOLD_WORDS.length; i++) {
-            if (fontName.indexOf(BOLD_WORDS[i]) != -1) {
+        for (String word : BOLD_WORDS) {
+            if (fontName.indexOf(word) != -1) {
                 weight = Font.WEIGHT_BOLD;
                 break;
             }
         }
-        for (int i = 0; i < MEDIUM_WORDS.length; i++) {
-            if (fontName.indexOf(MEDIUM_WORDS[i]) != -1) {
+        for (String word : MEDIUM_WORDS) {
+            if (fontName.indexOf(word) != -1) {
                 weight = Font.WEIGHT_NORMAL + 100; //500
                 break;
             }
         }
         //Search for "semi/demi" before "light", but after "bold"
         //(normally semi/demi-bold is meant, but it can also be semi/demi-light)
-        for (int i = 0; i < DEMI_WORDS.length; i++) {
-            if (fontName.indexOf(DEMI_WORDS[i]) != -1) {
+        for (String word : DEMI_WORDS) {
+            if (fontName.indexOf(word) != -1) {
                 weight = Font.WEIGHT_BOLD - 100; //600
                 break;
             }
         }
-        for (int i = 0; i < EXTRA_BOLD_WORDS.length; i++) {
-            if (fontName.indexOf(EXTRA_BOLD_WORDS[i]) != -1) {
+        for (String word : EXTRA_BOLD_WORDS) {
+            if (fontName.indexOf(word) != -1) {
                 weight = Font.WEIGHT_EXTRA_BOLD;
                 break;
             }
         }
-        for (int i = 0; i < LIGHT_WORDS.length; i++) {
-            if (fontName.indexOf(LIGHT_WORDS[i]) != -1) {
+        for (String word : LIGHT_WORDS) {
+            if (fontName.indexOf(word) != -1) {
                 weight = Font.WEIGHT_LIGHT;
                 break;
             }
index db72bee0c4d132d7c8ec049941f23ab1e6f9d3b7..2d04e0d35612e0ee3bdf73ea8ba64ee86a2c0793 100644 (file)
@@ -588,10 +588,9 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl
 
     private int[][] scaleAdjustments(int[][] adjustments, int fontSize) {
         if (adjustments != null) {
-            for (int i = 0, n = adjustments.length; i < n; i++) {
-                int[] gpa = adjustments [ i ];
+            for (int[] gpa : adjustments) {
                 for (int k = 0; k < 4; k++) {
-                    gpa [ k ] = (gpa [ k ] * fontSize) / 1000;
+                    gpa[k] = (gpa[k] * fontSize) / 1000;
                 }
             }
             return adjustments;
@@ -710,9 +709,9 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl
         for (int i = 0, n = cs.length(); i < n; i++) {
             int cc = cs.charAt(i);
             int[] da = CharNormalize.decompose(cc, daBuffer);
-            for (int j = 0; j < da.length; j++) {
-                if (da[j] > 0) {
-                    sb.append((char) da[j]);
+            for (int aDa : da) {
+                if (aDa > 0) {
+                    sb.append((char) aDa);
                 } else {
                     break;
                 }
@@ -752,8 +751,7 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl
 
     private static boolean hasElidableControl(GlyphSequence gs) {
         int[] ca = gs.getCharacterArray(false);
-        for (int i = 0, n = ca.length; i < n; ++i) {
-            int ch = ca [ i ];
+        for (int ch : ca) {
             if (isElidableControl(ch)) {
                 return true;
             }
index 9dbd8a5d2cbcd217a2d201c2c000c372feb3a03b..eb273d172d5202c18f4d38891f676b3cde26b518 100644 (file)
@@ -172,12 +172,12 @@ public class SingleByteFont extends CustomFont {
         String charName = Glyphs.charToGlyphName(c);
         String[] charNameAlternatives = Glyphs.getCharNameAlternativesFor(charName);
         if (charNameAlternatives != null && charNameAlternatives.length > 0) {
-            for (int i = 0; i < charNameAlternatives.length; i++) {
+            for (String charNameAlternative : charNameAlternatives) {
                 if (log.isDebugEnabled()) {
                     log.debug("Checking alternative for char " + c + " (charname="
-                            + charName + "): " + charNameAlternatives[i]);
+                            + charName + "): " + charNameAlternative);
                 }
-                String s = Glyphs.getUnicodeSequenceForGlyphName(charNameAlternatives[i]);
+                String s = Glyphs.getUnicodeSequenceForGlyphName(charNameAlternative);
                 if (s != null) {
                     d = lookupChar(s.charAt(0));
                     if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
index 7f3927f24f10482266fb8c218e05f719ae9fd168..dcdbff05ba0556ca1f5f762cc065324a51f72987 100644 (file)
@@ -290,8 +290,8 @@ public class XMLFontMetricsReader extends DefaultHandler {
         } else if ("cid-widths".equals(localName)) {
             int[] wds = new int[cidWidths.size()];
             int j = 0;
-            for (int count = 0; count < cidWidths.size(); count++) {
-                wds[j++] = cidWidths.get(count);
+            for (Integer cidWidth : cidWidths) {
+                wds[j++] = cidWidth;
             }
 
             //multiFont.addCIDWidthEntry(cidWidthIndex, wds);
index 9f723a308b5a7903bce0e0b1af8aec553fbd2bce..d1924033d125dc9f6e559b8d99230d68a04faf19 100644 (file)
@@ -36,8 +36,8 @@ public abstract class NativeFontDirFinder implements FontDirFinder {
         List<File> fontDirList = new java.util.ArrayList<File>();
         String[] searchableDirectories = getSearchableDirectories();
         if (searchableDirectories != null) {
-            for (int i = 0; i < searchableDirectories.length; i++) {
-                File fontDir = new File(searchableDirectories[i]);
+            for (String searchableDirectory : searchableDirectories) {
+                File fontDir = new File(searchableDirectory);
                 if (fontDir.exists() && fontDir.canRead()) {
                     fontDirList.add(fontDir);
                 }
index 820326d11b8d499711028ff5972b04893497c15c..865211a3e135a44c742601ad6d4ff778651aae3d 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.fop.fonts.substitute;
 
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -86,10 +85,9 @@ public class FontQualifier {
     public void setFontWeight(String fontWeight) {
         AttributeValue fontWeightAttribute = AttributeValue.valueOf(fontWeight);
         if (fontWeightAttribute != null) {
-            for (Iterator it = fontWeightAttribute.iterator(); it.hasNext();) {
-                Object weightObj = it.next();
+            for (Object weightObj : fontWeightAttribute) {
                 if (weightObj instanceof String) {
-                    String weightString = ((String)weightObj).trim();
+                    String weightString = ((String) weightObj).trim();
                     try {
                         FontUtil.parseCSS2FontWeight(weightString);
                     } catch (IllegalArgumentException ex) {
@@ -157,14 +155,13 @@ public class FontQualifier {
         List/*<FontTriplet>*/ matchingTriplets = new java.util.ArrayList/*<FontTriplet>*/();
 
         // try to find matching destination font triplet
-        for (Iterator attrIt = fontFamilyValue.iterator(); attrIt.hasNext();) {
-            String fontFamilyString = (String)attrIt.next();
-            Map/*<FontTriplet>*/ triplets = (Map/*<FontTriplet>*/)fontInfo.getFontTriplets();
+        for (Object aFontFamilyValue : fontFamilyValue) {
+            String fontFamilyString = (String) aFontFamilyValue;
+            Map/*<FontTriplet>*/ triplets = (Map/*<FontTriplet>*/) fontInfo.getFontTriplets();
             if (triplets != null) {
                 Set/*<FontTriplet>*/ tripletSet = triplets.keySet();
-                for (Iterator/*<FontTriplet>*/ tripletIt = tripletSet.iterator();
-                        tripletIt.hasNext();) {
-                    FontTriplet triplet = (FontTriplet)tripletIt.next();
+                for (Object aTripletSet : tripletSet) {
+                    FontTriplet triplet = (FontTriplet) aTripletSet;
                     String fontName = triplet.getName();
 
                     // matched font family name
@@ -173,22 +170,21 @@ public class FontQualifier {
                         // try and match font weight
                         boolean weightMatched = false;
                         int fontWeight = triplet.getWeight();
-                        for (Iterator weightIt = weightValue.iterator(); weightIt.hasNext();) {
-                            Object weightObj = weightIt.next();
+                        for (Object weightObj : weightValue) {
                             if (weightObj instanceof FontWeightRange) {
-                                FontWeightRange intRange = (FontWeightRange)weightObj;
+                                FontWeightRange intRange = (FontWeightRange) weightObj;
                                 if (intRange.isWithinRange(fontWeight)) {
                                     weightMatched = true;
                                 }
                             } else if (weightObj instanceof String) {
-                                String fontWeightString = (String)weightObj;
+                                String fontWeightString = (String) weightObj;
                                 int fontWeightValue = FontUtil.parseCSS2FontWeight(
                                         fontWeightString);
                                 if (fontWeightValue == fontWeight) {
                                     weightMatched = true;
                                 }
                             } else if (weightObj instanceof Integer) {
-                                Integer fontWeightInteger = (Integer)weightObj;
+                                Integer fontWeightInteger = (Integer) weightObj;
                                 int fontWeightValue = fontWeightInteger;
                                 if (fontWeightValue == fontWeight) {
                                     weightMatched = true;
@@ -199,8 +195,8 @@ public class FontQualifier {
                         // try and match font style
                         boolean styleMatched = false;
                         String fontStyleString = triplet.getStyle();
-                        for (Iterator styleIt = styleValue.iterator(); styleIt.hasNext();) {
-                            String style = (String)styleIt.next();
+                        for (Object aStyleValue : styleValue) {
+                            String style = (String) aStyleValue;
                             if (fontStyleString.equals(style)) {
                                 styleMatched = true;
                             }
@@ -227,8 +223,8 @@ public class FontQualifier {
         if (matchingTriplets.size() == 1) {
             bestTriplet = (FontTriplet)matchingTriplets.get(0);
         } else {
-            for (Iterator iterator = matchingTriplets.iterator(); iterator.hasNext();) {
-                FontTriplet triplet = (FontTriplet)iterator.next();
+            for (Object matchingTriplet : matchingTriplets) {
+                FontTriplet triplet = (FontTriplet) matchingTriplet;
                 if (bestTriplet == null) {
                     bestTriplet = triplet;
                 } else {
@@ -249,29 +245,27 @@ public class FontQualifier {
         List/*<FontTriplet>*/ triplets = new java.util.ArrayList/*<FontTriplet>*/();
 
         AttributeValue fontFamilyValue = getFontFamily();
-        for (Iterator fontFamilyIt = fontFamilyValue.iterator(); fontFamilyIt.hasNext();) {
-            String name = (String)fontFamilyIt.next();
+        for (Object aFontFamilyValue : fontFamilyValue) {
+            String name = (String) aFontFamilyValue;
 
             AttributeValue styleValue = getFontStyle();
-            for (Iterator styleIt = styleValue.iterator(); styleIt.hasNext();) {
-                String style = (String)styleIt.next();
+            for (Object aStyleValue : styleValue) {
+                String style = (String) aStyleValue;
 
                 AttributeValue weightValue = getFontWeight();
-                for (Iterator weightIt = weightValue.iterator(); weightIt.hasNext();) {
-                    Object weightObj = weightIt.next();
-
+                for (Object weightObj : weightValue) {
                     if (weightObj instanceof FontWeightRange) {
-                        FontWeightRange fontWeightRange = (FontWeightRange)weightObj;
+                        FontWeightRange fontWeightRange = (FontWeightRange) weightObj;
                         int[] weightRange = fontWeightRange.toArray();
-                        for (int i = 0; i < weightRange.length; i++) {
-                            triplets.add(new FontTriplet(name, style, weightRange[i]));
+                        for (int aWeightRange : weightRange) {
+                            triplets.add(new FontTriplet(name, style, aWeightRange));
                         }
                     } else if (weightObj instanceof String) {
-                        String weightString = (String)weightObj;
+                        String weightString = (String) weightObj;
                         int weight = FontUtil.parseCSS2FontWeight(weightString);
                         triplets.add(new FontTriplet(name, style, weight));
                     } else if (weightObj instanceof Integer) {
-                        Integer weightInteger = (Integer)weightObj;
+                        Integer weightInteger = (Integer) weightObj;
                         int weight = weightInteger;
                         triplets.add(new FontTriplet(name, style, weight));
                     }
index e964595774a9efab7c79afe90543c29a2f6afede..20af385207668a8bec3a94f5ab4fbe4edf2d1330 100644 (file)
@@ -58,8 +58,8 @@ public class FontSubstitutions extends java.util.ArrayList/*<Substitutions>*/ {
 
             FontQualifier fromQualifier = substitution.getFromQualifier();
             List/*<FontTriplet>*/ tripletList = fromQualifier.getTriplets();
-            for (Iterator tripletit = tripletList.iterator(); tripletit.hasNext();) {
-                FontTriplet triplet = (FontTriplet) tripletit.next();
+            for (Object aTripletList : tripletList) {
+                FontTriplet triplet = (FontTriplet) aTripletList;
                 fontInfo.addFontProperties(internalFontKey, triplet);
             }
         }
index fb60473fc548a9d3337426c2423b31cbe6b2b931..885a4d2a1549833e883433087573577792e7b3a2 100644 (file)
@@ -66,12 +66,12 @@ public class FontSubstitutionsConfigurator {
      */
     public void configure(FontSubstitutions substitutions) throws FOPException {
         Configuration[] substitutionCfgs = cfg.getChildren("substitution");
-        for (int i = 0; i < substitutionCfgs.length; i++) {
-            Configuration fromCfg = substitutionCfgs[i].getChild("from", false);
+        for (Configuration substitutionCfg : substitutionCfgs) {
+            Configuration fromCfg = substitutionCfg.getChild("from", false);
             if (fromCfg == null) {
                 throw new FOPException("'substitution' element without child 'from' element");
             }
-            Configuration toCfg = substitutionCfgs[i].getChild("to", false);
+            Configuration toCfg = substitutionCfg.getChild("to", false);
             if (fromCfg == null) {
                 throw new FOPException("'substitution' element without child 'to' element");
             }
index 5be2140fe7e375f1c8a9e86e1dbf7216d1da1886..cda3ce5ece9a3e679df18700fec4b1a28b6d2cbc 100644 (file)
@@ -1504,30 +1504,30 @@ public abstract class OpenFont {
         int localXHeight = 0;
         int localAscender = 0;
         int localDescender = 0;
-        for (int i = 0; i < mtxTab.length; i++) {
-            if ("H".equals(mtxTab[i].getName())) {
-                localCapHeight = mtxTab[i].getBoundingBox()[3];
-            } else if ("x".equals(mtxTab[i].getName())) {
-                localXHeight = mtxTab[i].getBoundingBox()[3];
-            } else if ("d".equals(mtxTab[i].getName())) {
-                localAscender = mtxTab[i].getBoundingBox()[3];
-            } else if ("p".equals(mtxTab[i].getName())) {
-                localDescender = mtxTab[i].getBoundingBox()[1];
+        for (OFMtxEntry aMtxTab : mtxTab) {
+            if ("H".equals(aMtxTab.getName())) {
+                localCapHeight = aMtxTab.getBoundingBox()[3];
+            } else if ("x".equals(aMtxTab.getName())) {
+                localXHeight = aMtxTab.getBoundingBox()[3];
+            } else if ("d".equals(aMtxTab.getName())) {
+                localAscender = aMtxTab.getBoundingBox()[3];
+            } else if ("p".equals(aMtxTab.getName())) {
+                localDescender = aMtxTab.getBoundingBox()[1];
             } else {
                 // OpenType Fonts with a version 3.0 "post" table don't have glyph names.
                 // Use Unicode indices instead.
-                List unicodeIndex = mtxTab[i].getUnicodeIndex();
+                List unicodeIndex = aMtxTab.getUnicodeIndex();
                 if (unicodeIndex.size() > 0) {
                     //Only the first index is used
-                    char ch = (char)((Integer)unicodeIndex.get(0)).intValue();
+                    char ch = (char) ((Integer) unicodeIndex.get(0)).intValue();
                     if (ch == 'H') {
-                        localCapHeight = mtxTab[i].getBoundingBox()[3];
+                        localCapHeight = aMtxTab.getBoundingBox()[3];
                     } else if (ch == 'x') {
-                        localXHeight = mtxTab[i].getBoundingBox()[3];
+                        localXHeight = aMtxTab.getBoundingBox()[3];
                     } else if (ch == 'd') {
-                        localAscender = mtxTab[i].getBoundingBox()[3];
+                        localAscender = aMtxTab.getBoundingBox()[3];
                     } else if (ch == 'p') {
-                        localDescender = mtxTab[i].getBoundingBox()[1];
+                        localDescender = aMtxTab.getBoundingBox()[1];
                     }
                 }
             }
@@ -1640,8 +1640,8 @@ public abstract class OpenFont {
                     while (uniMap.hasNext()) {
                         Integer unicodeKey = (Integer)uniMap.next();
                         Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey);
-                        for (int u = 0; u < ansiKeys.length; u++) {
-                            akpx.put(ansiKeys[u], kern);
+                        for (Integer ansiKey : ansiKeys) {
+                            akpx.put(ansiKey, kern);
                         }
                     }
                 }
@@ -1651,8 +1651,8 @@ public abstract class OpenFont {
                     while (uniMap.hasNext()) {
                         Integer unicodeKey = (Integer)uniMap.next();
                         Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey);
-                        for (int u = 0; u < ansiKeys.length; u++) {
-                            ansiKerningTab.put(ansiKeys[u], akpx);
+                        for (Integer ansiKey : ansiKeys) {
+                            ansiKerningTab.put(ansiKey, akpx);
                         }
                     }
                 }
index f61e8a11a4ff105c15bcc7b871ee9eeef78bac4c..e151568ec0500552f9c92bb76cb06d9b59540233 100644 (file)
@@ -264,9 +264,9 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer {
                 if (hstrcmp(word, i, kv.getArray(), lo[p]) == 0) {
                     values = getValues(eq[p]);    // data pointer is in eq[]
                     int j = index;
-                    for (int k = 0; k < values.length; k++) {
-                        if (j < il.length && values[k] > il[j]) {
-                            il[j] = values[k];
+                    for (byte value : values) {
+                        if (j < il.length && value > il[j]) {
+                            il[j] = value;
                         }
                         j++;
                     }
@@ -291,9 +291,9 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer {
                     if (sc[q] == 0) {
                         values = getValues(eq[q]);
                         int j = index;
-                        for (int k = 0; k < values.length; k++) {
-                            if (j < il.length && values[k] > il[j]) {
-                                il[j] = values[k];
+                        for (byte value : values) {
+                            if (j < il.length && value > il[j]) {
+                                il[j] = value;
                             }
                             j++;
                         }
index 2fc5984ad028a30c0a1865cd208adf9ce81b0e77..6bf3391e6d89978de12a276c660c0cbeb9684959 100644 (file)
@@ -195,10 +195,9 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
 
     private ArrayList normalizeException(ArrayList ex) {
         ArrayList res = new ArrayList();
-        for (int i = 0; i < ex.size(); i++) {
-            Object item = ex.get(i);
+        for (Object item : ex) {
             if (item instanceof String) {
-                String str = (String)item;
+                String str = (String) item;
                 StringBuffer buf = new StringBuffer();
                 for (int j = 0; j < str.length(); j++) {
                     char c = str.charAt(j);
@@ -226,13 +225,12 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
 
     private String getExceptionWord(ArrayList ex) {
         StringBuffer res = new StringBuffer();
-        for (int i = 0; i < ex.size(); i++) {
-            Object item = ex.get(i);
+        for (Object item : ex) {
             if (item instanceof String) {
-                res.append((String)item);
+                res.append((String) item);
             } else {
-                if (((Hyphen)item).noBreak != null) {
-                    res.append(((Hyphen)item).noBreak);
+                if (((Hyphen) item).noBreak != null) {
+                    res.append(((Hyphen) item).noBreak);
                 }
             }
         }
index 551e7d3f2708dc156774ac805083d240cd7f248a..c8c6b9052e58a144326e431b9168a2164c185b2d 100644 (file)
@@ -409,9 +409,9 @@ public final class SpaceResolver {
 
     private MinOptMax sum(MinOptMax[] lengths) {
         MinOptMax sum = MinOptMax.ZERO;
-        for (int i = 0; i < lengths.length; i++) {
-            if (lengths[i] != null) {
-                sum = sum.plus(lengths[i]);
+        for (MinOptMax length : lengths) {
+            if (length != null) {
+                sum = sum.plus(length);
             }
         }
         return sum;
index 83b9502f2e9a969d474e49dcb4bc2a756b9e5b9d..c5031cd0f3304a5bc97c06bbc29526681aba51a3 100644 (file)
@@ -20,7 +20,6 @@
 package org.apache.fop.layoutmgr.inline;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
@@ -270,8 +269,8 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
                     Object obj = returnedList.remove(0);
                     if (obj instanceof KnuthSequence) {
                         KnuthSequence ks = (KnuthSequence)obj;
-                        for (Iterator it = ks.iterator(); it.hasNext();) {
-                            contentElement = (KnuthElement)it.next();
+                        for (Object k : ks) {
+                            contentElement = (KnuthElement) k;
                             stackSize += contentElement.getWidth();
                             contentList.add(contentElement);
                         }
index 66a4d1a15124f8a8c352cf4b85ddbee081f79d06..41f0cd5a4667895e15c5bddf48afdf0b188cbc37 100644 (file)
@@ -295,8 +295,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
          * @return true if the sequence contains a box
          */
         public boolean containsBox() {
-            for (int i = 0; i < this.size(); i++) {
-                KnuthElement el = (KnuthElement)this.get(i);
+            for (Object o : this) {
+                KnuthElement el = (KnuthElement) o;
                 if (el.isBox()) {
                     return true;
                 }
index 8fae908494f85bac5b49caace298bcca1f187438..35e8c0c4fc5707cab823e16ff55debc8826b3753 100644 (file)
@@ -211,8 +211,8 @@ public class ColumnSetup {
          * and work out the total number of factors to use to distribute
          * the remaining space (if any)
          */
-        for (Iterator i = colWidths.iterator(); i.hasNext();) {
-            Length colWidth = (Length) i.next();
+        for (Object colWidth1 : colWidths) {
+            Length colWidth = (Length) colWidth1;
             if (colWidth != null) {
                 sumCols += colWidth.getValue(percentBaseContext);
                 if (colWidth instanceof RelativeNumericProperty) {
index ed46d2199d60eee67b480a002647569925f5f22e..3b263b09fc70f515b6c2f1b14fd41926abb13589 100644 (file)
@@ -95,10 +95,10 @@ class RowGroupLayoutManager {
             int bodyType, LinkedList returnList) {
         log.debug("Handling row group with " + rowGroup.length + " rows...");
         EffRow row;
-        for (int rgi = 0; rgi < rowGroup.length; rgi++) {
-            row = rowGroup[rgi];
-            for (Iterator iter = row.getGridUnits().iterator(); iter.hasNext();) {
-                GridUnit gu = (GridUnit) iter.next();
+        for (EffRow aRowGroup : rowGroup) {
+            row = aRowGroup;
+            for (Object o : row.getGridUnits()) {
+                GridUnit gu = (GridUnit) o;
                 if (gu.isPrimary()) {
                     PrimaryGridUnit primary = gu.getPrimary();
                     // TODO a new LM must be created for every new static-content
@@ -118,7 +118,7 @@ class RowGroupLayoutManager {
 
                     //Get the element list for the cell contents
                     List elems = primary.getCellLM().getNextKnuthElements(
-                                            childLC, alignment);
+                            childLC, alignment);
                     ElementListObserver.observe(elems, "table-cell", primary.getCell().getId());
                     primary.setElements(elems);
                 }
@@ -155,8 +155,8 @@ class RowGroupLayoutManager {
                 rowHeights[rgi] = rowBPD.toMinOptMax(tableLM);
                 explicitRowHeight = rowBPD.toMinOptMax(tableLM);
             }
-            for (Iterator iter = row.getGridUnits().iterator(); iter.hasNext();) {
-                GridUnit gu = (GridUnit) iter.next();
+            for (Object o : row.getGridUnits()) {
+                GridUnit gu = (GridUnit) o;
                 if (!gu.isEmpty() && gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()) {
                     PrimaryGridUnit primary = gu.getPrimary();
                     int effectiveCellBPD = 0;
index 3ee6f53b1a9aab298efe90893a2c412515d0746e..85c016537c3caac7955970904c7ba47ed71255b2 100644 (file)
@@ -126,8 +126,8 @@ class RowPainter {
 
         if (tablePartBackground != null) {
             TableLayoutManager tableLM = tclm.getTableLM();
-            for (Iterator iter = tablePartBackgroundAreas.iterator(); iter.hasNext();) {
-                Block backgroundArea = (Block) iter.next();
+            for (Object tablePartBackgroundArea : tablePartBackgroundAreas) {
+                Block backgroundArea = (Block) tablePartBackgroundArea;
                 TraitSetter.addBackground(backgroundArea, tablePartBackground, tableLM,
                         -backgroundArea.getXOffset(), tablePartOffset - backgroundArea.getYOffset(),
                         tableLM.getContentAreaIPD(), currentRowOffset - tablePartOffset);
index 2a4aff24ec5681c51b9b5d6a19e8d71dd91dc18f..42c174d64000b45f7cef3401c97571135395e153 100644 (file)
@@ -291,8 +291,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager {
             return;
         }
         int n = childrenLMs.size();
-        for (int j = 0; j < n; j++) {
-            LayoutManager lm = childrenLMs.get(j);
+        for (LayoutManager lm : childrenLMs) {
             if (lm == null) {
                 return;
             } else if (lm instanceof RetrieveTableMarkerLayoutManager) {
index eb82a05387f6fb794a1580e6767a33c7f6b3b6b9..16eba41fa75058d96cfcb516db6b28b5d45f5d9b 100644 (file)
@@ -564,8 +564,8 @@ public class TableContentLayoutManager implements PercentBaseContext {
             getTableLM().registerMarkers(body.getMarkers(), true, isFirstPos, isLastPos);
         }
         painter.startTablePart(body);
-        for (Iterator iter = positions.iterator(); iter.hasNext();) {
-            painter.handleTableContentPosition((TableContentPosition) iter.next());
+        for (Object position : positions) {
+            painter.handleTableContentPosition((TableContentPosition) position);
         }
         getTableLM().getCurrentPV().registerMarkers(body.getMarkers(),
                 false, isFirstPos, isLastPos);
index ea6cb2b22640a474779838fc40582111fe86541f..9458793c71506beb69a2f254c3759b6084d8db04 100644 (file)
@@ -386,8 +386,8 @@ public class TableLayoutManager extends SpacedBorderedPaddedBlockLayoutManager
         curBlockArea.setBPD(tableHeight);
 
         if (columnBackgroundAreas != null) {
-            for (Iterator iter = columnBackgroundAreas.iterator(); iter.hasNext();) {
-                ColumnBackgroundInfo b = (ColumnBackgroundInfo) iter.next();
+            for (Object columnBackgroundArea : columnBackgroundAreas) {
+                ColumnBackgroundInfo b = (ColumnBackgroundInfo) columnBackgroundArea;
                 TraitSetter.addBackground(b.backgroundArea,
                         b.column.getCommonBorderPaddingBackground(), this,
                         b.xShift, -b.backgroundArea.getYOffset(),
@@ -558,8 +558,7 @@ public class TableLayoutManager extends SpacedBorderedPaddedBlockLayoutManager
         // if we get to this stage then we are at the footer of the table fragment; this means that no more
         // different TCLM need to be saved (we already have all); we flag the list as being complete then
         areAllTCLMsSaved = true;
-        for (int i = 0; i < savedTCLMs.size(); i++) {
-            TableCellLayoutManager tclm = savedTCLMs.get(i);
+        for (TableCellLayoutManager tclm : savedTCLMs) {
             if (this.repeatedHeader) {
                 tclm.setHasRepeatedHeader(true);
             }
index c51c86997d0a2805909d55921f37ba3173976780..93985425b1940a60492c2a9737c88b6ad1790245 100644 (file)
@@ -92,8 +92,8 @@ public class TableRowIterator {
         List rowGroup = (List) rowGroupsIter.next();
         EffRow[] effRowGroup = new EffRow[rowGroup.size()];
         int i = 0;
-        for (Iterator rowIter = rowGroup.iterator(); rowIter.hasNext();) {
-            List gridUnits = (List) rowIter.next();
+        for (Object aRowGroup : rowGroup) {
+            List gridUnits = (List) aRowGroup;
             effRowGroup[i++] = new EffRow(rowIndex++, tablePart, gridUnits);
         }
         return effRowGroup;
index 7c98bd481d529822c5d07b82871246499a5842e4..a6344f4b7b3efb1c80a86af5a75f591c796d1ae0 100644 (file)
@@ -121,8 +121,8 @@ public class TableStepper {
 
     private void calcTotalHeight() {
         totalHeight = 0;
-        for (int i = 0; i < rowGroup.length; i++) {
-            totalHeight += rowGroup[i].getHeight().getOpt();
+        for (EffRow aRowGroup : rowGroup) {
+            totalHeight += aRowGroup.getHeight().getOpt();
         }
         if (log.isDebugEnabled()) {
             log.debug("totalHeight=" + totalHeight);
@@ -131,8 +131,8 @@ public class TableStepper {
 
     private int getMaxRemainingHeight() {
         int maxW = 0;
-        for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
-            ActiveCell activeCell = (ActiveCell) iter.next();
+        for (Object activeCell1 : activeCells) {
+            ActiveCell activeCell = (ActiveCell) activeCell1;
             int remain = activeCell.getRemainingLength();
             PrimaryGridUnit pgu = activeCell.getPrimaryGridUnit();
             for (int i = activeRowIndex + 1; i < pgu.getRowIndex() - rowGroup[0].getIndex()
@@ -202,8 +202,8 @@ public class TableStepper {
             LinkedList footnoteList = new LinkedList();
             //Put all involved grid units into a list
             List cellParts = new java.util.ArrayList(activeCells.size());
-            for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
-                ActiveCell activeCell = (ActiveCell) iter.next();
+            for (Object activeCell2 : activeCells) {
+                ActiveCell activeCell = (ActiveCell) activeCell2;
                 CellPart part = activeCell.createCellPart();
                 cellParts.add(part);
                 activeCell.addFootnotes(footnoteList);
@@ -242,8 +242,8 @@ public class TableStepper {
 
             Keep keep = getTableLM().getKeepTogether();
             int stepPenalty = 0;
-            for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
-                ActiveCell activeCell = (ActiveCell) iter.next();
+            for (Object activeCell1 : activeCells) {
+                ActiveCell activeCell = (ActiveCell) activeCell1;
                 keep = keep.compare(activeCell.getKeepWithNext());
                 stepPenalty = Math.max(stepPenalty, activeCell.getPenaltyValue());
             }
@@ -342,8 +342,8 @@ public class TableStepper {
      * previous rows and spanning over this one)
      */
     private void computeRowFirstStep(List cells) {
-        for (Iterator iter = cells.iterator(); iter.hasNext();) {
-            ActiveCell activeCell = (ActiveCell) iter.next();
+        for (Object cell : cells) {
+            ActiveCell activeCell = (ActiveCell) cell;
             rowFirstStep = Math.max(rowFirstStep, activeCell.getFirstStep());
         }
     }
@@ -356,8 +356,8 @@ public class TableStepper {
     private int computeMinStep() {
         int minStep = Integer.MAX_VALUE;
         boolean stepFound = false;
-        for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
-            ActiveCell activeCell = (ActiveCell) iter.next();
+        for (Object activeCell1 : activeCells) {
+            ActiveCell activeCell = (ActiveCell) activeCell1;
             int nextStep = activeCell.getNextStep();
             if (nextStep >= 0) {
                 stepFound = true;
@@ -378,8 +378,8 @@ public class TableStepper {
      * @see ActiveCell#signalRowFirstStep(int)
      */
     private void signalRowFirstStep() {
-        for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
-            ActiveCell activeCell = (ActiveCell) iter.next();
+        for (Object activeCell1 : activeCells) {
+            ActiveCell activeCell = (ActiveCell) activeCell1;
             activeCell.signalRowFirstStep(rowFirstStep);
         }
     }
@@ -391,8 +391,8 @@ public class TableStepper {
      */
     private void signalNextStep(int step) {
         nextBreakClass = Constants.EN_AUTO;
-        for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
-            ActiveCell activeCell = (ActiveCell) iter.next();
+        for (Object activeCell1 : activeCells) {
+            ActiveCell activeCell = (ActiveCell) activeCell1;
             nextBreakClass = BreakUtil.compareBreakClasses(nextBreakClass,
                     activeCell.signalNextStep(step));
         }
@@ -417,8 +417,8 @@ public class TableStepper {
      */
     private int considerRowLastStep(int step) {
         rowFinished = true;
-        for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
-            ActiveCell activeCell = (ActiveCell) iter.next();
+        for (Object activeCell3 : activeCells) {
+            ActiveCell activeCell = (ActiveCell) activeCell3;
             if (activeCell.endsOnRow(activeRowIndex)) {
                 if (!activeCell.finishes(step)) {
                     rowFinished = false;
@@ -431,8 +431,8 @@ public class TableStepper {
                 log.trace("Row finished, computing last step");
             }
             int maxStep = 0;
-            for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
-                ActiveCell activeCell = (ActiveCell) iter.next();
+            for (Object activeCell2 : activeCells) {
+                ActiveCell activeCell = (ActiveCell) activeCell2;
                 if (activeCell.endsOnRow(activeRowIndex)) {
                     maxStep = Math.max(maxStep, activeCell.getLastStep());
                 }
@@ -440,8 +440,8 @@ public class TableStepper {
             if (log.isTraceEnabled()) {
                 log.trace("Max step: " + maxStep);
             }
-            for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
-                ActiveCell activeCell = (ActiveCell) iter.next();
+            for (Object activeCell1 : activeCells) {
+                ActiveCell activeCell = (ActiveCell) activeCell1;
                 activeCell.endRow(activeRowIndex);
                 if (!activeCell.endsOnRow(activeRowIndex)) {
                     activeCell.signalRowLastStep(maxStep);
@@ -493,8 +493,8 @@ public class TableStepper {
         if (log.isTraceEnabled()) {
             log.trace("Switching to row " + (activeRowIndex + 1));
         }
-        for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
-            ActiveCell activeCell = (ActiveCell) iter.next();
+        for (Object activeCell1 : activeCells) {
+            ActiveCell activeCell = (ActiveCell) activeCell1;
             activeCell.nextRowStarts();
         }
         activeCells.addAll(nextActiveCells);
index 1be4e9af06424bb11c1faafcfad0998688c11d9b..bfcc1c7e0da40555945d38d3f104f06596176f25 100644 (file)
@@ -61,8 +61,8 @@ public class PDFArray extends PDFObject {
         /* generic creation of PDF object */
         super(parent);
 
-        for (int i = 0, c = values.length; i < c; i++) {
-            this.values.add(values[i]);
+        for (int value : values) {
+            this.values.add(value);
         }
     }
 
@@ -75,8 +75,8 @@ public class PDFArray extends PDFObject {
         /* generic creation of PDF object */
         super(parent);
 
-        for (int i = 0, c = values.length; i < c; i++) {
-            this.values.add(values[i]);
+        for (double value : values) {
+            this.values.add(value);
         }
     }
 
@@ -119,8 +119,8 @@ public class PDFArray extends PDFObject {
         /* generic creation of PDF object */
         super(parent);
 
-        for (int i = 0, c = values.length; i < c; i++) {
-            this.values.add(values[i]);
+        for (Object value : values) {
+            this.values.add(value);
         }
     }
 
index 3477ea3e74d18031a1e847db6b995b91cd8f709d..027fedce98ee76f32767ca73d38914c46cbafbb4 100644 (file)
@@ -72,8 +72,7 @@ public class PDFColorHandler {
             ColorWithAlternatives colExt = (ColorWithAlternatives)color;
             //Alternate colors have priority
             Color[] alt = colExt.getAlternativeColors();
-            for (int i = 0, c = alt.length; i < c; i++) {
-                Color col = alt[i];
+            for (Color col : alt) {
                 boolean established = establishColorFromColor(codeBuffer, col, fill);
                 if (established) {
                     return;
@@ -223,8 +222,8 @@ public class PDFColorHandler {
         if (comps.length != componentCount) {
             throw new IllegalStateException("Color with unexpected component count encountered");
         }
-        for (int i = 0, c = comps.length; i < c; i++) {
-            DoubleFormatUtil.formatDouble(comps[i], 4, 4, codeBuffer);
+        for (float comp : comps) {
+            DoubleFormatUtil.formatDouble(comp, 4, 4, codeBuffer);
             codeBuffer.append(" ");
         }
         codeBuffer.append(command).append("\n");
index 19d15d0d2adc293b063c7ca0eeb4f78c0927b8cf..fbb7d57a6db8590c19b68d49a35e9d250c68c080 100644 (file)
@@ -191,8 +191,8 @@ public class PDFFilterList {
                 addFilter(new FlateFilter());
             }
         } else {
-            for (int i = 0; i < filterset.size(); i++) {
-                String v = (String)filterset.get(i);
+            for (Object aFilterset : filterset) {
+                String v = (String) aFilterset;
                 addFilter(v);
             }
         }
@@ -249,8 +249,7 @@ public class PDFFilterList {
     private int populateNamesAndParms(List names, List parms) {
         // run the filters
         int nonNullParams = 0;
-        for (int count = 0; count < filters.size(); count++) {
-            PDFFilter filter = filters.get(count);
+        for (PDFFilter filter : filters) {
             // place the names in our local vector in reverse order
             if (filter.getName().length() > 0) {
                 names.add(0, filter.getName());
@@ -269,8 +268,8 @@ public class PDFFilterList {
     private String buildFilterEntries(List names) {
         int filterCount = 0;
         StringBuffer sb = new StringBuffer(64);
-        for (int i = 0; i < names.size(); i++) {
-            final String name = (String)names.get(i);
+        for (Object name1 : names) {
+            final String name = (String) name1;
             if (name.length() > 0) {
                 filterCount++;
                 sb.append(name);
@@ -290,8 +289,8 @@ public class PDFFilterList {
 
     private void putFilterEntries(PDFDictionary dict, List names) {
         PDFArray array = new PDFArray(dict);
-        for (int i = 0, c = names.size(); i < c; i++) {
-            final String name = (String)names.get(i);
+        for (Object name1 : names) {
+            final String name = (String) name1;
             if (name.length() > 0) {
                 array.add(new PDFName(name));
             }
@@ -313,8 +312,8 @@ public class PDFFilterList {
         if (parms.size() > 1) {
             sb.append("[ ");
         }
-        for (int count = 0; count < parms.size(); count++) {
-            String s = (String)parms.get(count);
+        for (Object parm : parms) {
+            String s = (String) parm;
             if (s != null) {
                 sb.append(s);
                 needParmsEntry = true;
@@ -336,8 +335,7 @@ public class PDFFilterList {
     private void putDecodeParams(PDFDictionary dict, List parms) {
         boolean needParmsEntry = false;
         PDFArray array = new PDFArray(dict);
-        for (int i = 0, c = parms.size(); i < c; i++) {
-            Object obj = parms.get(i);
+        for (Object obj : parms) {
             if (obj != null) {
                 array.add(obj);
                 needParmsEntry = true;
index d335bde525d7e267f289223546aa3212ec663015..4e83c3d53a98a3095262ea2305bc4421eb1f8158 100644 (file)
@@ -110,8 +110,7 @@ public class PDFPages extends PDFObject {
         sb.append("<< /Type /Pages\n/Count ")
                 .append(this.getCount())
                 .append("\n/Kids [");
-        for (int i = 0; i < kids.size(); i++) {
-            Object kid = kids.get(i);
+        for (Object kid : kids) {
             if (kid == null) {
                 throw new IllegalStateException("Gap in the kids list!");
             }
index ce4296a20bba3a8a0c6626f8a59798d225695e4c..fa09ee4e756a42faae5887d5e67fbfab53e0d5d8 100644 (file)
@@ -24,7 +24,6 @@ import java.awt.Paint;
 import java.awt.Shape;
 import java.awt.geom.Area;
 import java.awt.geom.GeneralPath;
-import java.util.Iterator;
 
 import org.apache.xmlgraphics.java2d.color.ColorUtil;
 
@@ -172,8 +171,8 @@ public class PDFPaintingState extends org.apache.fop.util.AbstractPaintingState
         PDFGState state;
         PDFGState newState = new PDFGState();
         newState.addValues(defaultState);
-        for (Iterator it = getStateStack().iterator(); it.hasNext();) {
-            PDFData data = (PDFData)it.next();
+        for (AbstractData abstractData : getStateStack()) {
+            PDFData data = (PDFData) abstractData;
             state = data.gstate;
             if (state != null) {
                 newState.addValues(state);
index a1b3cff1656088822311e7a682a0ef836d3360aa..2d09e27a9bc3f342cea9ce6c9be30aa309452768 100644 (file)
@@ -151,9 +151,9 @@ public class PDFText extends PDFObject {
         if (brackets) {
             sb.append("<");
         }
-        for (int i = 0; i < data.length; i++) {
-            sb.append(DIGITS[(data[i] >>> 4) & 0x0F]);
-            sb.append(DIGITS[data[i] & 0x0F]);
+        for (byte aData : data) {
+            sb.append(DIGITS[(aData >>> 4) & 0x0F]);
+            sb.append(DIGITS[aData & 0x0F]);
         }
         if (brackets) {
             sb.append(">");
@@ -198,9 +198,9 @@ public class PDFText extends PDFObject {
             throw new CascadingRuntimeException("Incompatible VM", uee);
         }
 
-        for (int i = 0; i < uniBytes.length; i++) {
-            buf.append(DIGITS[(uniBytes[i] >>> 4) & 0x0F]);
-            buf.append(DIGITS[uniBytes[i] & 0x0F]);
+        for (byte uniByte : uniBytes) {
+            buf.append(DIGITS[(uniByte >>> 4) & 0x0F]);
+            buf.append(DIGITS[uniByte & 0x0F]);
         }
         return buf.toString();
     }
@@ -287,8 +287,7 @@ public class PDFText extends PDFObject {
     public static final byte[] escapeByteArray(byte[] data) {
         ByteArrayOutputStream bout = new ByteArrayOutputStream(data.length);
         bout.write((int)'(');
-        for (int i = 0; i < data.length; i++) {
-            final int b = data[i];
+        for (final byte b : data) {
             switch (b) {
                 case '\n':
                     bout.write('\\');
index ad6d2ac296c9b2feb617eb6966747d1bf35b019f..32fde7e83764b2114e20cabfe0a97ef1a190b40d 100644 (file)
@@ -100,16 +100,15 @@ public class PDFWArray {
         StringBuffer p = new StringBuffer();
         p.append("[ ");
         int len = entries.size();
-        for (int i = 0; i < len; i++) {
-            Object entry = entries.get(i);
+        for (Object entry : entries) {
             if (entry instanceof int[]) {
-                int[] line = (int[])entry;
-                for (int j = 0; j < line.length; j++) {
-                    p.append(line[j]);
+                int[] line = (int[]) entry;
+                for (int aLine : line) {
+                    p.append(aLine);
                     p.append(" ");
                 }
             } else {
-                ((Entry)entry).fillInPDF(p);
+                ((Entry) entry).fillInPDF(p);
             }
         }
         p.append("]");
@@ -131,8 +130,8 @@ public class PDFWArray {
             // p.setLength(0);
             p.append(start);
             p.append(" [");
-            for (int i = 0; i < metrics.length; i++) {
-                p.append(this.metrics[i]);
+            for (int metric : metrics) {
+                p.append(metric);
                 p.append(" ");
             }
             p.append("] ");
index 0d891efe9b34f986479a4dc6803e7efd221f4c29..335505fec2c0ce77f9562048ef90e5561d369a85 100644 (file)
@@ -58,8 +58,8 @@ public abstract class AbstractFOEventHandlerMaker {
      */
     public boolean isMimeTypeSupported(String mimeType) {
         String[] mimes = getSupportedMimeTypes();
-        for (int i = 0; i < mimes.length; i++) {
-            if (mimes[i].equals(mimeType)) {
+        for (String mime : mimes) {
+            if (mime.equals(mimeType)) {
                 return true;
             }
         }
index 458bed6a3f71a26318d51a0f78df288094a56e13..5b5ed0f3f01dac391ebde5f0c1a7684fbd3b0560 100644 (file)
@@ -202,11 +202,12 @@ public abstract class AbstractRenderer
 
     private String convertToString(List children) {
         StringBuffer sb = new StringBuffer();
-        for (int count = 0; count < children.size(); count++) {
-            InlineArea inline = (InlineArea) children.get(count);
+        for (Object aChildren : children) {
+            InlineArea inline = (InlineArea) aChildren;
             //if (inline instanceof Character) {
             //    sb.append(((Character) inline).getChar());
-            /*} else*/ if (inline instanceof TextArea) {
+            /*} else*/
+            if (inline instanceof TextArea) {
                 sb.append(((TextArea) inline).getText());
             } else if (inline instanceof InlineParent) {
                 sb.append(convertToString(
@@ -413,8 +414,8 @@ public abstract class AbstractRenderer
         int saveBPPos = currentBPPosition;
         int saveSpanBPPos = saveBPPos;
         int saveIPPos = currentIPPosition;
-        for (int count = 0; count < spans.size(); count++) {
-            span = (Span) spans.get(count);
+        for (Object span1 : spans) {
+            span = (Span) span1;
             int level = span.getBidiLevel();
             if (level < 0) {
                 level = 0;
@@ -548,8 +549,7 @@ public abstract class AbstractRenderer
         containingBPPosition = currentBPPosition;
         containingIPPosition = currentIPPosition;
 
-        for (int count = 0; count < blocks.size(); count++) {
-            Object obj = blocks.get(count);
+        for (Object obj : blocks) {
             if (obj instanceof Block) {
                 currentIPPosition = contIP;
                 containingBPPosition = contBP;
@@ -685,8 +685,8 @@ public abstract class AbstractRenderer
         } else {
             currentIPPosition += line.getStartIndent();
         }
-        for (int i = 0, l = children.size(); i < l; i++) {
-            InlineArea inline = (InlineArea) children.get(i);
+        for (Object aChildren : children) {
+            InlineArea inline = (InlineArea) aChildren;
             renderInlineArea(inline);
         }
         currentBPPosition = saveBP;
@@ -755,8 +755,8 @@ public abstract class AbstractRenderer
         List children = text.getChildAreas();
         int saveIP = currentIPPosition;
         int saveBP = currentBPPosition;
-        for (int i = 0, l = children.size(); i < l; i++) {
-            InlineArea inline = (InlineArea) children.get(i);
+        for (Object aChildren : children) {
+            InlineArea inline = (InlineArea) aChildren;
             renderInlineArea(inline);
         }
         currentIPPosition = saveIP + text.getAllocIPD();
@@ -798,8 +798,8 @@ public abstract class AbstractRenderer
         int ipAdjust;
         if ((ip instanceof FilledArea) && ((level & 1) != 0)) {
             int ipdChildren = 0;
-            for (int i = 0, l = children.size(); i < l; i++) {
-                InlineArea inline = (InlineArea) children.get(i);
+            for (Object aChildren : children) {
+                InlineArea inline = (InlineArea) aChildren;
                 ipdChildren += inline.getAllocIPD();
             }
             ipAdjust = ip.getAllocIPD() - ipdChildren;
@@ -817,8 +817,8 @@ public abstract class AbstractRenderer
         }
         currentBPPosition += ip.getBlockProgressionOffset();
         // render children inlines
-        for (int i = 0, l = children.size(); i < l; i++) {
-            InlineArea inline = (InlineArea) children.get(i);
+        for (Object aChildren : children) {
+            InlineArea inline = (InlineArea) aChildren;
             renderInlineArea(inline);
         }
         currentIPPosition = saveIP + ip.getAllocIPD();
index 505a60a1c1749c3f85fbc5dd9bdde298cd7ca440..ac606792f90ce261bf58d719ca91557f1febeaba 100644 (file)
@@ -61,8 +61,8 @@ public abstract class AbstractRendererMaker {
      */
     public boolean isMimeTypeSupported(String mimeType) {
         String[] mimes = getSupportedMimeTypes();
-        for (int i = 0; i < mimes.length; i++) {
-            if (mimes[i].equals(mimeType)) {
+        for (String mime : mimes) {
+            if (mime.equals(mimeType)) {
                 return true;
             }
         }
index 18e5b1272b297803bc3dcc4911d3e0a99281d537..2ef22739f10521dbbb31b351e8754642bc2bd9a0 100644 (file)
@@ -142,8 +142,8 @@ public class ImageHandlerRegistry {
         for (ImageHandler handler : this.handlerList) {
             if (handler.isCompatible(context, null)) {
                 ImageFlavor[] f = handler.getSupportedImageFlavors();
-                for (int i = 0; i < f.length; i++) {
-                    flavors.add(f[i]);
+                for (ImageFlavor aF : f) {
+                    flavors.add(aF);
                 }
             }
         }
index df5213dad172e6c527824a33f8cafca95c7fe206..899beb2936c8820226bde989686682384215cddf 100644 (file)
@@ -85,13 +85,13 @@ public class RendererFactory {
      */
     public void addRendererMaker(AbstractRendererMaker maker) {
         String[] mimes = maker.getSupportedMimeTypes();
-        for (int i = 0; i < mimes.length; i++) {
+        for (String mime : mimes) {
             //This overrides any renderer previously set for a MIME type
-            if (rendererMakerMapping.get(mimes[i]) != null) {
-                log.trace("Overriding renderer for " + mimes[i]
+            if (rendererMakerMapping.get(mime) != null) {
+                log.trace("Overriding renderer for " + mime
                         + " with " + maker.getClass().getName());
             }
-            rendererMakerMapping.put(mimes[i], maker);
+            rendererMakerMapping.put(mime, maker);
         }
     }
 
@@ -102,13 +102,13 @@ public class RendererFactory {
      */
     public void addFOEventHandlerMaker(AbstractFOEventHandlerMaker maker) {
         String[] mimes = maker.getSupportedMimeTypes();
-        for (int i = 0; i < mimes.length; i++) {
+        for (String mime : mimes) {
             //This overrides any event handler previously set for a MIME type
-            if (eventHandlerMakerMapping.get(mimes[i]) != null) {
-                log.trace("Overriding FOEventHandler for " + mimes[i]
+            if (eventHandlerMakerMapping.get(mime) != null) {
+                log.trace("Overriding FOEventHandler for " + mime
                         + " with " + maker.getClass().getName());
             }
-            eventHandlerMakerMapping.put(mimes[i], maker);
+            eventHandlerMakerMapping.put(mime, maker);
         }
     }
 
@@ -119,13 +119,13 @@ public class RendererFactory {
      */
     public void addDocumentHandlerMaker(AbstractIFDocumentHandlerMaker maker) {
         String[] mimes = maker.getSupportedMimeTypes();
-        for (int i = 0; i < mimes.length; i++) {
+        for (String mime : mimes) {
             //This overrides any renderer previously set for a MIME type
-            if (documentHandlerMakerMapping.get(mimes[i]) != null) {
-                log.trace("Overriding document handler for " + mimes[i]
+            if (documentHandlerMakerMapping.get(mime) != null) {
+                log.trace("Overriding document handler for " + mime
                         + " with " + maker.getClass().getName());
             }
-            documentHandlerMakerMapping.put(mimes[i], maker);
+            documentHandlerMakerMapping.put(mime, maker);
         }
     }
 
index 9baed9959a98f3449520c0e799da04bff7c677c7..ac50da273ec5d47127e5e23945a51c84d2df3bc8 100644 (file)
@@ -57,10 +57,10 @@ public class XMLHandlerConfigurator extends AbstractRendererConfigurator {
         Configuration handlerConfig = null;
 
         Configuration[] children = cfg.getChildren("xml-handler");
-        for (int i = 0; i < children.length; ++i) {
+        for (Configuration aChildren : children) {
             try {
-                if (children[i].getAttribute("namespace").equals(namespace)) {
-                    handlerConfig = children[i];
+                if (aChildren.getAttribute("namespace").equals(namespace)) {
+                    handlerConfig = aChildren;
                     break;
                 }
             } catch (ConfigurationException e) {
index cad09bff98da8feadb27ea5b5846973048147700..9eae3d5e80f75a7dd6e90d758d2ffa558aeef4da 100644 (file)
@@ -130,9 +130,9 @@ public class XMLHandlerRegistry {
     private XMLHandler getXMLHandler(Renderer renderer, List<XMLHandler> lst) {
         XMLHandler handler;
         if (lst != null) {
-            for (int i = 0, c = lst.size(); i < c; i++) {
+            for (XMLHandler aLst : lst) {
                 //TODO Maybe add priorities later
-                handler = lst.get(i);
+                handler = aLst;
                 if (handler.supportsRenderer(renderer)) {
                     return handler;
                 }
index a943f5aad40acf44a0add746c6cf8c698f503d45..062933df6bdda5892471a07d628b187de8d35c4d 100644 (file)
@@ -358,8 +358,7 @@ public final class AFPRendererConfig implements RendererConfig {
             if (defaultResourceLevelCfg != null) {
                 AFPResourceLevelDefaults defaults = new AFPResourceLevelDefaults();
                 String[] types = defaultResourceLevelCfg.getAttributeNames();
-                for (int i = 0, c = types.length; i < c; i++) {
-                    String type = types[i];
+                for (String type : types) {
                     try {
                         String level = defaultResourceLevelCfg.getAttribute(type);
                         defaults.setDefaultResourceLevel(type, AFPResourceLevel.valueOf(level));
index 610f522c22205a5ebf5bf61d22ba206a581c4b0f..4963257a042ace7dbcf24608308814316d516b77 100644 (file)
@@ -50,8 +50,8 @@ public abstract class AbstractIFDocumentHandlerMaker {
      */
     public boolean isMimeTypeSupported(String mimeType) {
         String[] mimes = getSupportedMimeTypes();
-        for (int i = 0; i < mimes.length; i++) {
-            if (mimes[i].equals(mimeType)) {
+        for (String mime : mimes) {
+            if (mime.equals(mimeType)) {
                 return true;
             }
         }
index cbe883d3c08a3a84a6d55585eedaac68e24b9f47..694871bd8ff925baa88638b1f8ec0a8b3e0e07eb 100644 (file)
@@ -113,8 +113,8 @@ public abstract class AbstractIFPainter<T extends IFDocumentHandler> implements
 
     private AffineTransform combine(AffineTransform[] transforms) {
         AffineTransform at = new AffineTransform();
-        for (int i = 0, c = transforms.length; i < c; i++) {
-            at.concatenate(transforms[i]);
+        for (AffineTransform transform : transforms) {
+            at.concatenate(transform);
         }
         return at;
     }
index 692e08398989bf0e049ad202d05e4896d62868dd..3ea7fc2cdacc4e7485c0ff64a19d5e18ef0503bc 100644 (file)
@@ -610,9 +610,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
 
     private void processExtensionAttachments(AreaTreeObject area) throws IFException {
         if (area.hasExtensionAttachments()) {
-            for (Iterator iter = area.getExtensionAttachments().iterator();
-                iter.hasNext();) {
-                ExtensionAttachment attachment = (ExtensionAttachment) iter.next();
+            for (ExtensionAttachment attachment : area.getExtensionAttachments()) {
                 this.documentHandler.handleExtensionObject(attachment);
             }
         }
@@ -688,15 +686,15 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
     /** {@inheritDoc} */
     protected void restoreStateStackAfterBreakOut(List breakOutList) {
         log.debug("Block.FIXED --> restoring context after break-out");
-        for (int i = 0, c = breakOutList.size(); i < c; i++) {
+        for (Object aBreakOutList : breakOutList) {
             graphicContextStack.push(graphicContext);
-            this.graphicContext = (IFGraphicContext)breakOutList.get(i);
+            this.graphicContext = (IFGraphicContext) aBreakOutList;
 
             //Handle groups
             IFGraphicContext.Group[] groups = graphicContext.getGroups();
-            for (int j = 0, jc = groups.length; j < jc; j++) {
+            for (IFGraphicContext.Group group : groups) {
                 try {
-                    groups[j].start(painter);
+                    group.start(painter);
                 } catch (IFException ife) {
                     handleIFException(ife);
                 }
index a534ca7298c72f8595caf7bd6a750a33032ee89b..b877abad5dedd499302fcf5707106a70e62d049b 100644 (file)
@@ -307,8 +307,8 @@ public final class IFUtil {
         if (dp == null) {
             return true;
         } else {
-            for (int i = 0, n = dp.length; i < n; i++) {
-                if (!isPAIdentity(dp[i])) {
+            for (int[] aDp : dp) {
+                if (!isPAIdentity(aDp)) {
                     return false;
                 }
             }
@@ -330,8 +330,7 @@ public final class IFUtil {
         if (dp == null) {
             return false;
         } else {
-            for (int i = 0, n = dp.length; i < n; i++) {
-                int[] pa = dp[i];
+            for (int[] pa : dp) {
                 if ((pa != null) && (pa[0] != pa[2])) {
                     return false;
                 }
index afb22a8831664e3ffc352cae7ddf032e9cfa475a..14ce695681fb5d39b13eea00150ec84d233c0e1a 100644 (file)
@@ -77,8 +77,7 @@ public class InstalledFontCollection implements FontCollection {
         GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
 
         java.awt.Font[] fonts = env.getAllFonts();
-        for (int i = 0; i < fonts.length; i++) {
-            java.awt.Font f = fonts[i];
+        for (java.awt.Font f : fonts) {
             if (HARDCODED_FONT_NAMES.contains(f.getName())) {
                 continue; //skip
             }
index 6a4f3215e053ca689d2bb4f721fd163bb18618ad..119ec857c5e71d4b2ac2c96e4bd7929b4a68b438 100644 (file)
@@ -108,8 +108,8 @@ public class PCLGenerator {
     public PCLGenerator(OutputStream out, int maxResolution) {
         this(out);
         boolean found = false;
-        for (int i = 0; i < PCL_RESOLUTIONS.length; i++) {
-            if (PCL_RESOLUTIONS[i] == maxResolution) {
+        for (int pclResolutions : PCL_RESOLUTIONS) {
+            if (pclResolutions == maxResolution) {
                 found = true;
                 break;
             }
index c679d7d75b6c3c0b8df1f21ad7d8f30ef59c0726..b034fa79ee6f1fe7be185c18b85849c2e20d2089 100644 (file)
@@ -293,8 +293,8 @@ public class PSImageHandlerSVG implements ImageHandler {
                 if (curNode.getAttributes().getNamedItem("style") != null) {
                     String[] stylePairs = curNode.getAttributes().getNamedItem("style").getNodeValue()
                             .split(";");
-                    for (int styleAtt = 0; styleAtt < stylePairs.length; styleAtt++) {
-                        String[] style = stylePairs[styleAtt].split(":");
+                    for (String stylePair : stylePairs) {
+                        String[] style = stylePair.split(":");
                         if (style[0].equalsIgnoreCase("stop-opacity")) {
                             if (Double.parseDouble(style[1]) < 1) {
                                 return true;
index 052c6fc26342876e31a300f385cf279363928131..b94a07e0b8362acb27d2fb7afe27c0d166dfd07a 100644 (file)
@@ -1757,9 +1757,9 @@ public class RTFHandler extends FOEventHandler {
               //Calculation for column-widths which are not set
               prepareTable(table);
 
-              for (Iterator it = table.getColumns().iterator(); it.hasNext();) {
-                  recurseFONode((FONode) it.next());
-              }
+                for (Object o : table.getColumns()) {
+                    recurseFONode((FONode) o);
+                }
             } else {
                 //TODO Implement implicit column setup handling!
                 RTFEventProducer eventProducer = RTFEventProducer.Provider.get(
index 605db7150b54ec2e06315461352427fe0ebaa2db..3b7535c2a9b5d5a31298922a25083aa74c010388 100644 (file)
@@ -191,8 +191,8 @@ public final class RtfColorTable {
 
         int len = colorTable.size();
 
-        for (int i = 0; i < len; i++) {
-            int identifier = (Integer) colorTable.get(i);
+        for (Object aColorTable : colorTable) {
+            int identifier = (Integer) aColorTable;
 
             header.newLine();
             header.write("\\red" + determineColorLevel(identifier, RED));
index a42d25b69a00e71b3c6189f033bb2ff45e0c1ee5..46dd3d0eebe060faa750d505174ef962689bd798 100644 (file)
@@ -28,7 +28,6 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc;
 
 import java.io.IOException;
 import java.io.Writer;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -113,16 +112,16 @@ public class RtfContainer extends RtfElement {
     }
 
     private int findChildren(RtfElement aChild, int iStart) {
-        for (Iterator it = this.getChildren().iterator(); it.hasNext();) {
-          final RtfElement e = (RtfElement)it.next();
-          if (aChild == e) {
-              return iStart;
-          } else if (e instanceof RtfContainer) {
-              int iFound = ((RtfContainer)e).findChildren(aChild, (iStart + 1));
-              if (iFound != -1) {
-                  return iFound;
-              }
-          }
+        for (Object o : this.getChildren()) {
+            final RtfElement e = (RtfElement) o;
+            if (aChild == e) {
+                return iStart;
+            } else if (e instanceof RtfContainer) {
+                int iFound = ((RtfContainer) e).findChildren(aChild, (iStart + 1));
+                if (iFound != -1) {
+                    return iFound;
+                }
+            }
         }
         return -1;
     }
@@ -157,8 +156,8 @@ public class RtfContainer extends RtfElement {
      */
     protected void writeRtfContent()
     throws IOException {
-        for (Iterator it = children.iterator(); it.hasNext();) {
-            final RtfElement e = (RtfElement)it.next();
+        for (Object aChildren : children) {
+            final RtfElement e = (RtfElement) aChildren;
             e.writeRtf();
         }
     }
@@ -171,12 +170,12 @@ public class RtfContainer extends RtfElement {
     /** true if this (recursively) contains at least one RtfText object */
     boolean containsText() {
         boolean result = false;
-        for (Iterator it = children.iterator(); it.hasNext();) {
-            final RtfElement e = (RtfElement)it.next();
+        for (Object aChildren : children) {
+            final RtfElement e = (RtfElement) aChildren;
             if (e instanceof RtfText) {
                 result = !e.isEmpty();
             } else if (e instanceof RtfContainer) {
-                if (((RtfContainer)e).containsText()) {
+                if (((RtfContainer) e).containsText()) {
                     result = true;
                 }
             }
@@ -191,8 +190,8 @@ public class RtfContainer extends RtfElement {
     void dump(Writer w, int indent)
     throws IOException {
         super.dump(w, indent);
-        for (Iterator it = children.iterator(); it.hasNext();) {
-            final RtfElement e = (RtfElement)it.next();
+        for (Object aChildren : children) {
+            final RtfElement e = (RtfElement) aChildren;
             e.dump(w, indent + 1);
         }
     }
@@ -222,8 +221,8 @@ public class RtfContainer extends RtfElement {
      */
     public boolean isEmpty() {
         boolean result = true;
-        for (Iterator it = children.iterator(); it.hasNext();) {
-            final RtfElement e = (RtfElement)it.next();
+        for (Object aChildren : children) {
+            final RtfElement e = (RtfElement) aChildren;
             if (!e.isEmpty()) {
                 result = false;
                 break;
index b9f0b501d6837c394b9d9727bad397f2001aa4a4..27d10e7105356159c21d48fcae652b7d50f8bd17 100644 (file)
@@ -190,8 +190,7 @@ public abstract class RtfElement {
 
         if (nameList != null) {
             // process only given attribute names
-            for (int i = 0; i < nameList.length; i++) {
-                final String name = nameList[i];
+            for (final String name : nameList) {
                 if (attr.isSet(name)) {
                     writeOneAttribute(name, attr.getValue(name));
                 }
index aa3a403fae9952b70042ea65e956100fad7db0c8..e936305f9a4ff85571d809b0129396b36759d178 100644 (file)
@@ -405,8 +405,8 @@ public class RtfExternalGraphic extends RtfElement {
         writeSizeInfo();
         writeAttributes(getRtfAttributes(), null);
 
-        for (int i = 0; i < imagedata.length; i++) {
-            int iData = imagedata [i];
+        for (byte anImagedata : imagedata) {
+            int iData = anImagedata;
 
             // Make positive byte
             if (iData < 0) {
index 55f8cbf27cd265b797a82fbcb9f3a95c7af84519..8996fe96bc8c141d06897d827adeaaf061585740 100644 (file)
@@ -29,7 +29,6 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc;
 import java.io.IOException;
 import java.io.Writer;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -140,10 +139,10 @@ public class RtfExtraRowSet extends RtfContainer {
      */
     int addTable(RtfTable tbl, int rowIndex, int xOffset) {
         // process all rows of the table
-        for (Iterator it = tbl.getChildren().iterator(); it.hasNext();) {
-            final RtfElement e = (RtfElement)it.next();
+        for (Object o : tbl.getChildren()) {
+            final RtfElement e = (RtfElement) o;
             if (e instanceof RtfTableRow) {
-                addRow((RtfTableRow)e, rowIndex, xOffset);
+                addRow((RtfTableRow) e, rowIndex, xOffset);
                 rowIndex++;
                 maxRowIndex = Math.max(rowIndex, maxRowIndex);
             }
@@ -153,10 +152,10 @@ public class RtfExtraRowSet extends RtfContainer {
 
     /** add all cells of given row to this set */
     private void addRow(RtfTableRow row, int rowIndex, int xOffset) {
-        for (Iterator it = row.getChildren().iterator(); it.hasNext();) {
-            final RtfElement e = (RtfElement)it.next();
+        for (Object o : row.getChildren()) {
+            final RtfElement e = (RtfElement) o;
             if (e instanceof RtfTableCell) {
-                final RtfTableCell c = (RtfTableCell)e;
+                final RtfTableCell c = (RtfTableCell) e;
                 cells.add(new PositionedCell(c, rowIndex, xOffset));
                 xOffset += c.getCellWidth();
             }
@@ -188,8 +187,8 @@ public class RtfExtraRowSet extends RtfContainer {
         // process all extra cells by rendering them into extra rows
         List rowCells = null;
         int rowIndex = -1;
-        for (Iterator it = cells.iterator(); it.hasNext();) {
-            final PositionedCell pc = (PositionedCell)it.next();
+        for (Object cell : cells) {
+            final PositionedCell pc = (PositionedCell) cell;
             if (pc.rowIndex != rowIndex) {
                 // starting a new row, render previous one
                 if (rowCells != null) {
@@ -225,24 +224,24 @@ public class RtfExtraRowSet extends RtfContainer {
         float xOffset = 0;
         float xOffsetOfLastPositionedCell = 0;
 
-        for (Iterator it = cells.iterator(); it.hasNext();) {
-            final PositionedCell pc = (PositionedCell)it.next();
+        for (Object cell : cells) {
+            final PositionedCell pc = (PositionedCell) cell;
 
             // if first cell is not at offset 0, add placeholder cell
             // TODO should be merged with the cell that is above it
             if (cellIndex == 0 && pc.xOffset > 0) {
-               /**
-                * Added by Boris Poudérous
-                */
-               // Add empty cells merged vertically with the cells above and with the same widths
-               // (BEFORE the cell that contains the nested table)
+                /**
+                 * Added by Boris Poudérous
+                 */
+                // Add empty cells merged vertically with the cells above and with the same widths
+                // (BEFORE the cell that contains the nested table)
                 for (int i = 0; (xOffset < pc.xOffset)
                         && (i < parentITableColumnsInfo.getNumberOfColumns()); i++) {
                     // Get the width of the cell above
                     xOffset += parentITableColumnsInfo.getColumnWidth();
                     // Create the empty cell merged vertically
-                    row.newTableCellMergedVertically((int)parentITableColumnsInfo.getColumnWidth(),
-                           pc.cell.attrib);
+                    row.newTableCellMergedVertically((int) parentITableColumnsInfo.getColumnWidth(),
+                            pc.cell.attrib);
                     // Select next column in order to have its width
                     parentITableColumnsInfo.selectNextColumn();
                 }
@@ -286,8 +285,8 @@ public class RtfExtraRowSet extends RtfContainer {
      */
     private static boolean allCellsEmpty(List cells) {
         boolean empty = true;
-        for (Iterator it = cells.iterator(); it.hasNext();) {
-            final PositionedCell pc = (PositionedCell)it.next();
+        for (Object cell : cells) {
+            final PositionedCell pc = (PositionedCell) cell;
             if (pc.cell.containsText()) {
                 empty = false;
                 break;
index 845ee1d28547f993be84596fc90f618c8912e02a..85fbbb8ff83eb0d970b5281850c041d04f3eaf3c 100644 (file)
@@ -29,7 +29,6 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc;
 import java.io.IOException;
 import java.io.Writer;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 /**
@@ -69,8 +68,8 @@ class RtfHeader extends RtfContainer {
         if (userProperties.size() > 0) {
             writeGroupMark(true);
             writeStarControlWord("userprops");
-            for (Iterator it = userProperties.entrySet().iterator(); it.hasNext();) {
-                final Map.Entry entry = (Map.Entry)it.next();
+            for (Object o : userProperties.entrySet()) {
+                final Map.Entry entry = (Map.Entry) o;
                 writeGroupMark(true);
                 writeControlWord("propname");
                 RtfStringConverter.getInstance().writeRtfString(writer,
index ff65c4fe100dfda43b13d21f34f0b66d0e87afcf..a8e4a571f09764700f9d40515fc687e07a29154c 100644 (file)
@@ -28,7 +28,6 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc;
 
 import java.io.IOException;
 import java.io.Writer;
-import java.util.Iterator;
 import java.util.LinkedList;
 
 /**
@@ -134,8 +133,8 @@ public class RtfListTable extends RtfContainer {
             writeGroupMark(true);
             writeStarControlWordNS(LIST_TABLE);
             newLine();
-            for (Iterator it = lists.iterator(); it.hasNext();) {
-                final RtfList list = (RtfList)it.next();
+            for (Object list1 : lists) {
+                final RtfList list = (RtfList) list1;
                 writeListTableEntry(list);
                 newLine();
             }
@@ -147,8 +146,8 @@ public class RtfListTable extends RtfContainer {
             writeStarControlWordNS(LIST_OVR_TABLE);
             int z = 1;
             newLine();
-            for (Iterator it = styles.iterator(); it.hasNext();) {
-                final RtfListStyle style = (RtfListStyle)it.next();
+            for (Object style1 : styles) {
+                final RtfListStyle style = (RtfListStyle) style1;
 
                 writeGroupMark(true);
                 writeStarControlWordNS(LIST_OVR);
index e38a78c953e7c45e5097e3705efaca481ef2c8a9..a9a2e8a1d17b9d24c6546fe3b2baee2eaae99033 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.fop.render.rtf.rtflib.rtfdoc;
 
-import java.util.Iterator;
 import java.util.LinkedList;
 
 /**
@@ -54,8 +53,8 @@ public class RtfSpaceManager {
      * candidate presence.
      */
     public void stopUpdatingSpaceBefore() {
-        for (Iterator it = blockAttributes.iterator(); it.hasNext();) {
-            RtfSpaceSplitter splitter = (RtfSpaceSplitter) it.next();
+        for (Object blockAttribute : blockAttributes) {
+            RtfSpaceSplitter splitter = (RtfSpaceSplitter) blockAttribute;
             if (splitter.isBeforeCadidateSet()) {
                 splitter.stopUpdatingSpaceBefore();
             }
@@ -68,8 +67,8 @@ public class RtfSpaceManager {
      * @param attrs  attributes to set
      */
     public void setCandidate(RtfAttributes attrs) {
-        for (Iterator it = blockAttributes.iterator(); it.hasNext();) {
-            RtfSpaceSplitter splitter = (RtfSpaceSplitter) it.next();
+        for (Object blockAttribute : blockAttributes) {
+            RtfSpaceSplitter splitter = (RtfSpaceSplitter) blockAttribute;
             splitter.setSpaceBeforeCandidate(attrs);
             splitter.setSpaceAfterCandidate(attrs);
         }
index 5203d0a79ae4964c4666ba0e32ecdc6fe937653a..263f6d1ac2a72327853dae1a3d8c53343acbe3fc 100644 (file)
@@ -28,7 +28,6 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc;
 
 import java.io.IOException;
 import java.io.Writer;
-import java.util.Iterator;
 
 /**
  * <p>A cell in an RTF table, container for paragraphs, lists, etc.</p>
@@ -491,14 +490,13 @@ public class RtfTableCell
         // true if there is at least one non-empty paragraph after p in our children
         boolean pFound = false;
         boolean result = false;
-        for (Iterator it = getChildren().iterator(); it.hasNext();) {
-            final Object o = it.next();
+        for (final Object o : getChildren()) {
             if (!pFound) {
                 // set pFound when p is found in the list
-                pFound =  (o == p);
+                pFound = (o == p);
             } else {
                 if (o instanceof RtfParagraph) {
-                    final RtfParagraph p2 = (RtfParagraph)o;
+                    final RtfParagraph p2 = (RtfParagraph) o;
                     if (!p2.isEmpty()) {
                         // found a non-empty paragraph after p
                         result = true;
index 10039e40d7e215886bba2241de760b9e3c2b32fb..566e2c7ce91205eff73e0d8c6c02c9b58909d2c3 100644 (file)
@@ -28,7 +28,6 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc;
 
 import java.io.IOException;
 import java.io.Writer;
-import java.util.Iterator;
 
 import org.apache.fop.apps.FOPException;
 
@@ -199,11 +198,11 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
         RtfAttributes tableBorderAttributes = getTable().getBorderAttributes();
 
         int index = 0;
-        for (Iterator it = getChildren().iterator(); it.hasNext();) {
-            final RtfElement e = (RtfElement)it.next();
+        for (Object o : getChildren()) {
+            final RtfElement e = (RtfElement) o;
             if (e instanceof RtfTableCell) {
 
-                RtfTableCell rtfcell = (RtfTableCell)e;
+                RtfTableCell rtfcell = (RtfTableCell) e;
 
                 // Adjust the cell's display attributes so the table's/row's borders
                 // are drawn properly.
@@ -214,7 +213,7 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
                         String border = ITableAttributes.CELL_BORDER_LEFT;
                         if (!rtfcell.getRtfAttributes().isSet(border)) {
                             rtfcell.getRtfAttributes().set(border,
-                                (RtfAttributes) tableBorderAttributes.getValue(border));
+                                    (RtfAttributes) tableBorderAttributes.getValue(border));
                         }
                     }
 
@@ -222,7 +221,7 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
                         String border = ITableAttributes.CELL_BORDER_RIGHT;
                         if (!rtfcell.getRtfAttributes().isSet(border)) {
                             rtfcell.getRtfAttributes().set(border,
-                                (RtfAttributes) tableBorderAttributes.getValue(border));
+                                    (RtfAttributes) tableBorderAttributes.getValue(border));
                         }
                     }
 
@@ -230,7 +229,7 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
                         String border = ITableAttributes.CELL_BORDER_TOP;
                         if (!rtfcell.getRtfAttributes().isSet(border)) {
                             rtfcell.getRtfAttributes().set(border,
-                                (RtfAttributes) tableBorderAttributes.getValue(border));
+                                    (RtfAttributes) tableBorderAttributes.getValue(border));
                         }
                     }
 
@@ -238,7 +237,7 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
                         String border = ITableAttributes.CELL_BORDER_BOTTOM;
                         if (!rtfcell.getRtfAttributes().isSet(border)) {
                             rtfcell.getRtfAttributes().set(border,
-                                (RtfAttributes) tableBorderAttributes.getValue(border));
+                                    (RtfAttributes) tableBorderAttributes.getValue(border));
                         }
                     }
                 }
@@ -247,35 +246,35 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes {
                 if (index == 0) {
                     if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_LEFT)) {
                         rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_LEFT,
-                            (String) attrib.getValue(ITableAttributes.ROW_BORDER_LEFT));
+                                (String) attrib.getValue(ITableAttributes.ROW_BORDER_LEFT));
                     }
                 }
 
                 if (index == this.getChildCount() - 1) {
                     if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_RIGHT)) {
                         rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_RIGHT,
-                            (String) attrib.getValue(ITableAttributes.ROW_BORDER_RIGHT));
+                                (String) attrib.getValue(ITableAttributes.ROW_BORDER_RIGHT));
                     }
                 }
 
                 if (isFirstRow()) {
                     if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_TOP)) {
                         rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_TOP,
-                            (String) attrib.getValue(ITableAttributes.ROW_BORDER_TOP));
+                                (String) attrib.getValue(ITableAttributes.ROW_BORDER_TOP));
                     }
                 }
 
                 if ((parentTable != null) && (parentTable.isHighestRow(id))) {
                     if (!rtfcell.getRtfAttributes().isSet(ITableAttributes.CELL_BORDER_BOTTOM)) {
                         rtfcell.getRtfAttributes().set(ITableAttributes.CELL_BORDER_BOTTOM,
-                            (String) attrib.getValue(ITableAttributes.ROW_BORDER_BOTTOM));
+                                (String) attrib.getValue(ITableAttributes.ROW_BORDER_BOTTOM));
                     }
                 }
 
                 // write cell's definition
                 xPos = rtfcell.writeCellDef(xPos);
             }
-          index++; // Added by Boris POUDEROUS on 2002/07/02
+            index++; // Added by Boris POUDEROUS on 2002/07/02
         }
 
         newLine();
index aa1b226f62f4aee97031979ed7d71c723a90ecf8..9758ab0b4dd1bbfd3f262079dd04a55c671c371f 100644 (file)
@@ -418,14 +418,14 @@ public class RtfTextrun extends RtfContainer {
         RtfParagraphBreak lastParagraphBreak = null;
         if (bLast) {
             RtfElement aBefore = null;
-            for (Iterator it = getChildren().iterator(); it.hasNext();) {
-                final RtfElement e = (RtfElement)it.next();
+            for (Object o : getChildren()) {
+                final RtfElement e = (RtfElement) o;
                 if (e instanceof RtfParagraphBreak) {
                     //If the element before was a paragraph break or a bookmark
                     //they will be hidden and are therefore not considered as visible
                     if (!(aBefore instanceof RtfParagraphBreak)
-                     && !(aBefore instanceof RtfBookmark)) {
-                      lastParagraphBreak = (RtfParagraphBreak)e;
+                            && !(aBefore instanceof RtfBookmark)) {
+                        lastParagraphBreak = (RtfParagraphBreak) e;
                     }
                 } else {
                     if (!(e instanceof RtfOpenGroupMark)
@@ -449,8 +449,8 @@ public class RtfTextrun extends RtfContainer {
         boolean bPrevPar = false;
         boolean bBookmark = false;
         boolean bFirst = true;
-        for (Iterator it = getChildren().iterator(); it.hasNext();) {
-            final RtfElement e = (RtfElement)it.next();
+        for (Object o : getChildren()) {
+            final RtfElement e = (RtfElement) o;
             final boolean bRtfParagraphBreak = (e instanceof RtfParagraphBreak);
 
             if (bHasTableCellParent) {
@@ -471,12 +471,12 @@ public class RtfTextrun extends RtfContainer {
             boolean bHide = false;
             bHide = bRtfParagraphBreak;
             bHide = bHide
-                && (bPrevPar
+                    && (bPrevPar
                     || bFirst
                     || (bSuppressLastPar && bLast && lastParagraphBreak != null
-                        && e == lastParagraphBreak)
+                    && e == lastParagraphBreak)
                     || bBookmark)
-                && ((RtfParagraphBreak)e).canHide();
+                    && ((RtfParagraphBreak) e).canHide();
 
             if (!bHide) {
                 newLine();
@@ -489,7 +489,7 @@ public class RtfTextrun extends RtfContainer {
 
             if (e instanceof RtfParagraphBreak) {
                 bPrevPar = true;
-            } else if (e instanceof RtfBookmark)  {
+            } else if (e instanceof RtfBookmark) {
                 bBookmark = true;
             } else if (e instanceof RtfCloseGroupMark) {
                 //do nothing
index abe903a736b4bafaebc2eaf76e84e4eaf31d1e52..dcb5c0843fc1dc8a87e939a9f5c93156593fafe0 100644 (file)
@@ -26,7 +26,6 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc;
  * the FOP project.
  */
 
-import java.util.Iterator;
 import java.util.StringTokenizer;
 
 /**
@@ -46,13 +45,12 @@ final class WhitespaceCollapser {
      */
     WhitespaceCollapser(RtfContainer c) {
         // process all texts
-        for (Iterator it = c.getChildren().iterator(); it.hasNext();) {
-            final Object kid = it.next();
+        for (final Object kid : c.getChildren()) {
             if (kid instanceof RtfText) {
-                RtfText current = (RtfText)kid;
+                RtfText current = (RtfText) kid;
                 processText(current);
             } else if (kid instanceof RtfString) {
-                RtfString current = (RtfString)kid;
+                RtfString current = (RtfString) kid;
                 processString(current);
             } else {
                 // if there is something between two texts, it counts for a space
index 09abc2515bffc71c25503d496e343c6abdbd8f53..839fe1bc2cad9fe015aa9dda4976040b922b68b5 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.render.txt;
 
 import java.awt.Point;
 import java.awt.geom.Rectangle2D;
-import java.util.Iterator;
 import java.util.LinkedList;
 
 import org.apache.fop.area.CTM;
@@ -62,8 +61,8 @@ public class TXTState {
      */
     private void calcResultCTM() {
         resultCTM = new CTM();
-        for (Iterator i = stackCTM.iterator(); i.hasNext();) {
-            updateResultCTM((CTM) i.next());
+        for (Object aStackCTM : stackCTM) {
+            updateResultCTM((CTM) aStackCTM);
         }
     }
 
index e226c88dd50a97c9a931e3be608b8862430ccab3..e1a1233223493dc3bdef3a5df147ab71682d6bf8 100644 (file)
@@ -466,8 +466,8 @@ public class XMLRenderer extends AbstractXMLRenderer {
             startElement("title");
             List children = seqTitle.getInlineAreas();
 
-            for (int count = 0; count < children.size(); count++) {
-                InlineArea inline = (InlineArea) children.get(count);
+            for (Object aChildren : children) {
+                InlineArea inline = (InlineArea) aChildren;
                 renderInlineArea(inline);
             }
 
@@ -603,8 +603,8 @@ public class XMLRenderer extends AbstractXMLRenderer {
 
         Span span = null;
         List spans = mr.getSpans();
-        for (int count = 0; count < spans.size(); count++) {
-            span = (Span) spans.get(count);
+        for (Object span1 : spans) {
+            span = (Span) span1;
             atts.clear();
             if (span.getColumnCount() != 1) {
                 addAttribute("columnCount", span.getColumnCount());
index 983a184c44f8e115992165d07a0732dd2db10ec9..b5bbd27bc3be602a5c3c83f533a72d51a3fd399f 100644 (file)
@@ -182,8 +182,8 @@ public abstract class NativeTextPainter extends StrokingTextPainter {
             super.paintTextRuns(textRuns, g2d);
             return;
         }
-        for (int i = 0; i < textRuns.size(); i++) {
-            TextRun textRun = (TextRun) textRuns.get(i);
+        for (Object textRun1 : textRuns) {
+            TextRun textRun = (TextRun) textRun1;
             try {
                 paintTextRun(textRun, g2d);
             } catch (IOException ioe) {
index a73cdc243e64a867fb5cec73edcbbeda386b766a..3fa6d3149f66c23caca661cf57917ac1a382f72d 100644 (file)
@@ -947,8 +947,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
         List<Double> theMatrix = new java.util.ArrayList<Double>();
         double [] mat = new double[6];
         transform.getMatrix(mat);
-        for (int idx = 0; idx < mat.length; idx++) {
-            theMatrix.add(mat[idx]);
+        for (double aMat : mat) {
+            theMatrix.add(aMat);
         }
 
         /** @todo see if pdfDoc and res can be linked here,
index 7fa588e23720659aea2baba21e1894cb662266c6..931f02819a5c1003b2ae9ee68761723a0cfd3812 100644 (file)
@@ -173,9 +173,9 @@ public class FileCompare {
             PrintWriter results
                 = new PrintWriter(new java.io.FileWriter("results.html"), true);
             this.writeHeader(results);
-            for (int i = 0; i < filenameList.length; i++) {
-                oldFile = new File(referenceDirectory + filenameList[i]);
-                newFile = new File(testDirectory + filenameList[i]);
+            for (String aFilenameList : filenameList) {
+                oldFile = new File(referenceDirectory + aFilenameList);
+                newFile = new File(testDirectory + aFilenameList);
                 if (filesExist(oldFile, newFile)) {
                     identical = compareFileSize(oldFile, newFile);
                     if (identical) {
@@ -183,28 +183,28 @@ public class FileCompare {
                     }
                     if (!identical) {
                         System.out.println("Task Compare: \nFiles "
-                                           + referenceDirectory
-                                           + oldFile.getName() + " - "
-                                           + testDirectory
-                                           + newFile.getName()
-                                           + " are *not* identical.");
+                                + referenceDirectory
+                                + oldFile.getName() + " - "
+                                + testDirectory
+                                + newFile.getName()
+                                + " are *not* identical.");
                         results.println("<tr><td><a href='"
-                                        + referenceDirectory
-                                        + oldFile.getName() + "'>"
-                                        + oldFile.getName()
-                                        + "</a> </td><td> <a href='"
-                                        + testDirectory + newFile.getName()
-                                        + "'>" + newFile.getName() + "</a>"
-                                        + " </td><td><font color='red'>No</font></td></tr>");
+                                + referenceDirectory
+                                + oldFile.getName() + "'>"
+                                + oldFile.getName()
+                                + "</a> </td><td> <a href='"
+                                + testDirectory + newFile.getName()
+                                + "'>" + newFile.getName() + "</a>"
+                                + " </td><td><font color='red'>No</font></td></tr>");
                     } else {
                         results.println("<tr><td><a href='"
-                                        + referenceDirectory
-                                        + oldFile.getName() + "'>"
-                                        + oldFile.getName()
-                                        + "</a> </td><td> <a href='"
-                                        + testDirectory + newFile.getName()
-                                        + "'>" + newFile.getName() + "</a>"
-                                        + " </td><td>Yes</td></tr>");
+                                + referenceDirectory
+                                + oldFile.getName() + "'>"
+                                + oldFile.getName()
+                                + "</a> </td><td> <a href='"
+                                + testDirectory + newFile.getName()
+                                + "'>" + newFile.getName() + "</a>"
+                                + " </td><td>Yes</td></tr>");
                     }
                 }
             }
index 8460e5964c6296a46570ed94694bdaa6fd1db1cb..d35c00436485e8819f9582bcdaf21854852d77c5 100644 (file)
@@ -446,9 +446,9 @@ class FOPTaskStarter {
         if (format == null) {
             return MimeConstants.MIME_PDF;
         }
-        for (int i = 0; i < SHORT_NAMES.length; i++) {
-            if (SHORT_NAMES[i][0].equals(format)) {
-                return SHORT_NAMES[i][1];
+        for (String[] shortName : SHORT_NAMES) {
+            if (shortName[0].equals(format)) {
+                return shortName[1];
             }
         }
         return format; //no change
@@ -477,9 +477,9 @@ class FOPTaskStarter {
     };
 
     private String determineExtension(String outputFormat) {
-        for (int i = 0; i < EXTENSIONS.length; i++) {
-            if (EXTENSIONS[i][0].equals(outputFormat)) {
-                String ext = EXTENSIONS[i][1];
+        for (String[] extension : EXTENSIONS) {
+            if (extension[0].equals(outputFormat)) {
+                String ext = extension[1];
                 if (ext == null) {
                     throw new RuntimeException("Output format '"
                             + outputFormat + "' does not produce a file.");
@@ -575,18 +575,18 @@ class FOPTaskStarter {
             DirectoryScanner ds = fs.getDirectoryScanner(task.getProject());
             String[] files = ds.getIncludedFiles();
 
-            for (int j = 0; j < files.length; j++) {
-                File f = new File(fs.getDir(task.getProject()), files[j]);
+            for (String file : files) {
+                File f = new File(fs.getDir(task.getProject()), file);
 
                 File outf = null;
-                if (task.getOutdir() != null && files[j].endsWith(inputExtension)) {
-                  String[] sa = mapper.mapFileName(files[j]);
-                  outf = new File(task.getOutdir(), sa[0]);
+                if (task.getOutdir() != null && file.endsWith(inputExtension)) {
+                    String[] sa = mapper.mapFileName(file);
+                    outf = new File(task.getOutdir(), sa[0]);
                 } else {
-                  outf = replaceExtension(f, inputExtension, newExtension);
-                  if (task.getOutdir() != null) {
-                      outf = new File(task.getOutdir(), outf.getName());
-                  }
+                    outf = replaceExtension(f, inputExtension, newExtension);
+                    if (task.getOutdir() != null) {
+                        outf = new File(task.getOutdir(), outf.getName());
+                    }
                 }
                 File dir = outf.getParentFile();
                 if (!dir.exists()) {
@@ -608,7 +608,7 @@ class FOPTaskStarter {
                 // OR output file doesn't exist OR
                 // output file is older than input file
                 if (task.getForce() || !outf.exists()
-                    || (f.lastModified() > outf.lastModified())) {
+                        || (f.lastModified() > outf.lastModified())) {
                     if (xsltFile != null) {
                         render(f, xsltFile, outf, outputFormat);
                     } else {
index 2f274df2277f8850e270e00525efcd593f0fa1f7..19825dc806791907a9a77c7a8643cfd4c6bda8de 100644 (file)
@@ -72,9 +72,9 @@ public final class BorderStyle extends TraitEnum {
      * @return the enumeration object
      */
     public static BorderStyle valueOf(String name) {
-        for (int i = 0; i < STYLES.length; i++) {
-            if (STYLES[i].getName().equalsIgnoreCase(name)) {
-                return STYLES[i];
+        for (BorderStyle style : STYLES) {
+            if (style.getName().equalsIgnoreCase(name)) {
+                return style;
             }
         }
         throw new IllegalArgumentException("Illegal border style: " + name);
@@ -86,9 +86,9 @@ public final class BorderStyle extends TraitEnum {
      * @return the enumeration object
      */
     public static BorderStyle valueOf(int enumValue) {
-        for (int i = 0; i < STYLES.length; i++) {
-            if (STYLES[i].getEnumValue() == enumValue) {
-                return STYLES[i];
+        for (BorderStyle style : STYLES) {
+            if (style.getEnumValue() == enumValue) {
+                return style;
             }
         }
         throw new IllegalArgumentException("Illegal border style: " + enumValue);
index 378c8dd2a648c57636c9d0e513a9b307fcc7e449..6c70d1945110868740c633b00ca249cd72b5ec2d 100644 (file)
@@ -74,9 +74,9 @@ public final class Direction extends TraitEnum {
      * @return the enumeration object
      */
     public static Direction valueOf(String name) {
-        for (int i = 0; i < DIRECTIONS.length; i++) {
-            if (DIRECTIONS[i].getName().equalsIgnoreCase(name)) {
-                return DIRECTIONS[i];
+        for (Direction direction : DIRECTIONS) {
+            if (direction.getName().equalsIgnoreCase(name)) {
+                return direction;
             }
         }
         throw new IllegalArgumentException("Illegal direction: " + name);
@@ -88,9 +88,9 @@ public final class Direction extends TraitEnum {
      * @return the enumeration object
      */
     public static Direction valueOf(int enumValue) {
-        for (int i = 0; i < DIRECTIONS.length; i++) {
-            if (DIRECTIONS[i].getEnumValue() == enumValue) {
-                return DIRECTIONS[i];
+        for (Direction direction : DIRECTIONS) {
+            if (direction.getEnumValue() == enumValue) {
+                return direction;
             }
         }
         throw new IllegalArgumentException("Illegal direction: " + enumValue);
index 19b57d76f17509170c98f75cf59997636af44994..db2921fbcab8ff2964152990286617d1434160df 100644 (file)
@@ -64,9 +64,9 @@ public final class RuleStyle extends TraitEnum {
      * @return the enumeration object
      */
     public static RuleStyle valueOf(String name) {
-        for (int i = 0; i < STYLES.length; i++) {
-            if (STYLES[i].getName().equalsIgnoreCase(name)) {
-                return STYLES[i];
+        for (RuleStyle style : STYLES) {
+            if (style.getName().equalsIgnoreCase(name)) {
+                return style;
             }
         }
         throw new IllegalArgumentException("Illegal rule style: " + name);
@@ -78,9 +78,9 @@ public final class RuleStyle extends TraitEnum {
      * @return the enumeration object
      */
     public static RuleStyle valueOf(int enumValue) {
-        for (int i = 0; i < STYLES.length; i++) {
-            if (STYLES[i].getEnumValue() == enumValue) {
-                return STYLES[i];
+        for (RuleStyle style : STYLES) {
+            if (style.getEnumValue() == enumValue) {
+                return style;
             }
         }
         throw new IllegalArgumentException("Illegal rule style: " + enumValue);
index f8c784941d7eef68fe7b77528e11edb6cc1d0ee8..ca1ee7445a19d9eea5022d12f631a016e5c78566 100644 (file)
@@ -133,9 +133,9 @@ public final class WritingMode extends TraitEnum {
      * @return the enumeration object
      */
     public static WritingMode valueOf(String name) {
-        for (int i = 0; i < WRITING_MODES.length; i++) {
-            if (WRITING_MODES[i].getName().equalsIgnoreCase(name)) {
-                return WRITING_MODES[i];
+        for (WritingMode writingMode : WRITING_MODES) {
+            if (writingMode.getName().equalsIgnoreCase(name)) {
+                return writingMode;
             }
         }
         throw new IllegalArgumentException("Illegal writing mode: " + name);
@@ -147,9 +147,9 @@ public final class WritingMode extends TraitEnum {
      * @return the enumeration object
      */
     public static WritingMode valueOf(int enumValue) {
-        for (int i = 0; i < WRITING_MODES.length; i++) {
-            if (WRITING_MODES[i].getEnumValue() == enumValue) {
-                return WRITING_MODES[i];
+        for (WritingMode writingMode : WRITING_MODES) {
+            if (writingMode.getEnumValue() == enumValue) {
+                return writingMode;
             }
         }
         throw new IllegalArgumentException("Illegal writing mode: " + enumValue);
index a910a54dd04a90df82d246e20866b8438696cdfb..cbb50c511323372e29079e7a13efb716d84ae6ce 100644 (file)
@@ -242,9 +242,9 @@ public final class ColorExt extends Color {
             sb.append("\"" + this.iccProfileSrc + "\"");
         }
         float[] colorComponents = this.getColorComponents(null);
-        for (int ix = 0; ix < colorComponents.length; ix++) {
+        for (float colorComponent : colorComponents) {
             sb.append(",");
-            sb.append(colorComponents[ix]);
+            sb.append(colorComponent);
         }
         sb.append(")");
         return sb.toString();
index ceedf9f1294399f4a90a2af3c6733c3cfb12be72..395433369e37c7cc2483beb2ad96636df1d40a67 100644 (file)
@@ -78,8 +78,8 @@ public class ContentHandlerFactoryRegistry {
      */
     public void addContentHandlerFactory(ContentHandlerFactory factory) {
         String[] ns = factory.getSupportedNamespaces();
-        for (int i = 0; i < ns.length; i++) {
-            factories.put(ns[i], factory);
+        for (String n : ns) {
+            factories.put(n, factory);
         }
     }
 
index 39d2af4a122f7c2d158ddadee822772310f811b4..486877ad0ee22879c03665cf431617712cd15a9f 100644 (file)
@@ -274,8 +274,8 @@ public class DOM2SAX {
 
             // Generate endPrefixMapping() for all pushed prefixes
             final int nPushedPrefixes = pushedPrefixes.size();
-            for (int i = 0; i < nPushedPrefixes; i++) {
-                endPrefixMapping((String)pushedPrefixes.get(i));
+            for (Object pushedPrefixe : pushedPrefixes) {
+                endPrefixMapping((String) pushedPrefixe);
             }
             break;
 
index 679b65aeef9cbee2f6de1f58b331c64ed2e168cd..17aae677626e810d25dd70c2e576eb2e5df6e327 100644 (file)
@@ -64,8 +64,7 @@ public class DigestFilterTestCase {
 
     private String digestToString(byte[] digest) {
         StringBuffer buffer = new StringBuffer(2 * digest.length);
-        for (int i = 0; i < digest.length; i++) {
-            int val = digest[i];
+        for (byte val : digest) {
             int hi = (val >> 4) & 0xF;
             int lo = val & 0xF;
             if (hi < 10) {
index a4c80cc65c9df4ca4567c1e8a8fccaefe46c2342..74257833a0fbfb17f8d4f83abebefceef2b09a0a 100644 (file)
@@ -138,12 +138,12 @@ public abstract class AbstractAFPObjectTest<S extends AbstractAFPObject> {
        byte[] actual = baos.toByteArray();
 
        int index = 0;
-       for (int i = 0; i < expected.length; i++) {
-           for (int j = 0; j < expected[i].length; j++) {
-               assertTrue("" + index, actual[index] == expected[i][j]);
-               index++;
-           }
-       }
+        for (byte[] anExpected : expected) {
+            for (int j = 0; j < anExpected.length; j++) {
+                assertTrue("" + index, actual[index] == anExpected[j]);
+                index++;
+            }
+        }
     }
 
     /**
@@ -222,8 +222,8 @@ public abstract class AbstractAFPObjectTest<S extends AbstractAFPObject> {
 
     private void checkHeaderAndData(byte[] header, byte[] data, byte[] testData, int expectedIndex,
             int testIndex, int chunkSize) {
-        for (int i = 0; i < header.length; i++) {
-            assertEquals(testData[expectedIndex++], header[i]);
+        for (byte aHeader : header) {
+            assertEquals(testData[expectedIndex++], aHeader);
         }
         for (int i = 0; i < chunkSize; i++) {
             assertEquals(testData[expectedIndex++], data[i + testIndex]);
index c251ba3b230889bb7e115374e69d9e63b69e8eec..41155613873d5d1d77ea2b677772111d4e3d6809 100644 (file)
@@ -2817,8 +2817,8 @@ public class TTXFile {
         private boolean hasMissingCoverage(GlyphCoverageTable[] gca) {
             assert gca != null;
             int nc = 0;
-            for (int i = 0, n = gca.length; i < n; i++) {
-                if (gca [ i ] != null) {
+            for (GlyphCoverageTable aGca : gca) {
+                if (aGca != null) {
                     nc++;
                 }
             }
@@ -3131,8 +3131,7 @@ public class TTXFile {
         }
         private Integer computeClassCount(Anchor[][] am) {
             int ncMax = 0;
-            for (int i = 0, n = am.length; i < n; i++) {
-                Anchor[] aa = am [ i ];
+            for (Anchor[] aa : am) {
                 if (aa != null) {
                     int nc = aa.length;
                     if (nc > ncMax) {
index 88411644164817b1bc1981800ef4d94ab56876b8..b669d9c11d019df29a1fadbbfaaad283c158cc21 100644 (file)
@@ -47,10 +47,10 @@ public class RowGroupBuilderTestCase extends AbstractTableTest {
      */
     private void checkTablePartRowGroups(TablePart part, int[] expectedRowLengths) {
         Iterator rowGroupIter = part.getRowGroups().iterator();
-        for (int i = 0; i < expectedRowLengths.length; i++) {
+        for (int expectedRowLength : expectedRowLengths) {
             assertTrue(rowGroupIter.hasNext());
             List rowGroup = (List) rowGroupIter.next();
-            assertEquals(expectedRowLengths[i], rowGroup.size());
+            assertEquals(expectedRowLength, rowGroup.size());
         }
         assertFalse(rowGroupIter.hasNext());
     }
@@ -78,9 +78,9 @@ public class RowGroupBuilderTestCase extends AbstractTableTest {
             checkTablePartRowGroups(table.getTableFooter(), expectedFooterRowLengths);
         }
         Iterator bodyIter = table.getChildNodes();
-        for (int i = 0; i < expectedBodyRowLengths.length; i++) {
+        for (int[] expectedBodyRowLength : expectedBodyRowLengths) {
             assertTrue(bodyIter.hasNext());
-            checkTablePartRowGroups((TableBody) bodyIter.next(), expectedBodyRowLengths[i]);
+            checkTablePartRowGroups((TableBody) bodyIter.next(), expectedBodyRowLength);
         }
     }
 
index 23eb999f0c801dfcde7bcb3bc3e77b8875d7a789..664b4ab0d9654ed99220797fe61e4c489ac1333f 100644 (file)
@@ -140,8 +140,8 @@ public class FOTreeTestCase {
 
             List<String> results = collector.getResults();
             if (results.size() > 0) {
-                for (int i = 0; i < results.size(); i++) {
-                    System.out.println(results.get(i));
+                for (String result : results) {
+                    System.out.println(result);
                 }
                 throw new IllegalStateException(results.get(0));
             }
index 7f17514ef5d680229406c90f6d44ca434c92187c..15a8ba84893c13562dd0ca6cab8e640d03642845 100644 (file)
@@ -61,8 +61,8 @@ public class CreateTestDocuments {
             throw new IOException("output directory (" + outDir + ") must exist and be writable");
         }
 
-        for (int i = 0; i < CLASS_NAMES.length; i++) {
-            createOneTestDocument(CLASS_NAMES[i], outDir);
+        for (String className : CLASS_NAMES) {
+            createOneTestDocument(className, outDir);
         }
     }
 
index 7b08b7cd1db76853457606aae2698b7932b1b5c0..7b03ada612d1bdf1f1b3688a4c0828630b9bc996 100644 (file)
@@ -71,8 +71,8 @@ public class FOPTestbed extends AbstractLogEnabled
         Configuration tasks = configuration.getChild("tasks");
         this.repeat = tasks.getAttributeAsInteger("repeat", 1);
         Configuration[] entries = tasks.getChildren("task");
-        for (int i = 0; i < entries.length; i++) {
-            this.taskList.add(new TaskDef(entries[i]));
+        for (Configuration entry : entries) {
+            this.taskList.add(new TaskDef(entry));
         }
         this.fopCfg = configuration.getChild("processor");
     }
index 9e62fdc1c9c1c68894441977df14714fd4c74d6f..fb5f2dcb0cbbd9dadcce7c587c951fe11b6fc6a8 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.util;
 
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.TreeMap;
 
@@ -57,8 +56,7 @@ public class DigestFilter extends XMLFilterImpl {
     public String getDigestString() {
         if (value != null) {
             StringBuffer buffer = new StringBuffer(2 * value.length);
-            for (int i = 0; i < value.length; i++) {
-                int val = value[i];
+            for (byte val : value) {
                 int hi = (val >> 4) & 0xF;
                 int lo = val & 0xF;
                 if (hi < 10) {
@@ -116,10 +114,10 @@ public class DigestFilter extends XMLFilterImpl {
                 map.put(attr.getQName(i), attr.getValue(i));
             }
         }
-        for (Iterator i = map.entrySet().iterator(); i.hasNext();) {
-            Map.Entry entry = (Map.Entry)i.next();
-            digest.update(((String)entry.getKey()).getBytes());
-            digest.update(((String)entry.getValue()).getBytes());
+        for (Object o : map.entrySet()) {
+            Map.Entry entry = (Map.Entry) o;
+            digest.update(((String) entry.getKey()).getBytes());
+            digest.update(((String) entry.getValue()).getBytes());
         }
         super.startElement(url, localName, qName, attr);
     }
index f2157176bd4d913814fc92d93628ca75e46d4ba3..ea2e67895ca456f5226d0cb7a61e474bb0ef3515 100644 (file)
@@ -132,13 +132,13 @@ public final class BitmapComparator {
         g.setPaint(Color.white);
         g.fillRect(0, 0, cmp.getWidth(), cmp.getHeight());
         int lastWidth = 0;
-        for (int i = 0; i < images.length; i++) {
+        for (BufferedImage image : images) {
             if (lastWidth > 0) {
                 g.translate(lastWidth, 0);
             }
-            if (images[i] != null) {
-                g.drawImage(images[i], 0, 0, null);
-                lastWidth = images[i].getWidth();
+            if (image != null) {
+                g.drawImage(image, 0, 0, null);
+                lastWidth = image.getWidth();
             } else {
                 lastWidth = 20; //Maybe add a special placeholder image instead later
             }
index 596a0a86b7fc18a162e8a3c4c1f7c09856a64a52..24499ea35189fd3da91986080afd802d36399b48 100644 (file)
@@ -104,8 +104,8 @@ public class DefaultEventBroadcaster implements EventBroadcaster {
     }
 
     private static synchronized EventProducerModel getEventProducerModel(Class clazz) {
-        for (int i = 0, c = eventModels.size(); i < c; i++) {
-            EventModel eventModel = (EventModel)eventModels.get(i);
+        for (Object eventModel1 : eventModels) {
+            EventModel eventModel = (EventModel) eventModel1;
             EventProducerModel producerModel = eventModel.getProducer(clazz);
             if (producerModel != null) {
                 return producerModel;
index 7151f5a9c2de23c26bd0053284b3597994a0b1b4..2351fc870cba060bb601fd21ae40afc1fb2ca818 100644 (file)
@@ -93,8 +93,7 @@ class EventProducerCollector {
         builder.addSource(src);
         JavaClass[] classes = builder.getClasses();
         boolean eventProducerFound = false;
-        for (int i = 0, c = classes.length; i < c; i++) {
-            JavaClass clazz = classes[i];
+        for (JavaClass clazz : classes) {
             if (clazz.isInterface() && implementsInterface(clazz, CLASSNAME_EVENT_PRODUCER)) {
                 processEventProducerInterface(clazz);
                 eventProducerFound = true;
@@ -105,8 +104,7 @@ class EventProducerCollector {
 
     private boolean implementsInterface(JavaClass clazz, String intf) {
         JavaClass[] classes = clazz.getImplementedInterfaces();
-        for (int i = 0, c = classes.length; i < c; i++) {
-            JavaClass cl = classes[i];
+        for (JavaClass cl : classes) {
             if (cl.getFullyQualifiedName().equals(intf)) {
                 return true;
             }
@@ -124,8 +122,7 @@ class EventProducerCollector {
                 throws EventConventionException, ClassNotFoundException {
         EventProducerModel prodMeta = new EventProducerModel(clazz.getFullyQualifiedName());
         JavaMethod[] methods = clazz.getMethods(true);
-        for (int i = 0, c = methods.length; i < c; i++) {
-            JavaMethod method = methods[i];
+        for (JavaMethod method : methods) {
             EventMethodModel methodMeta = createMethodModel(method);
             prodMeta.addMethod(methodMeta);
         }
index 85c10f09aa609bf002f271b5e8c20155f7eb40a4..f56eea2e4f7005447c66828ba29bb9ca78d84b73 100644 (file)
@@ -67,8 +67,7 @@ public class EventProducerCollectorTask extends Task {
         try {
             EventProducerCollector collector = new EventProducerCollector();
             long lastModified = processFileSets(collector);
-            for (Iterator iter = collector.getModels().iterator(); iter.hasNext();) {
-                EventModel model = (EventModel) iter.next();
+            for (EventModel model : collector.getModels()) {
                 File parentDir = getParentDir(model);
                 if (!parentDir.exists() && !parentDir.mkdirs()) {
                     throw new BuildException(
@@ -208,8 +207,7 @@ public class EventProducerCollectorTask extends Task {
             DirectoryScanner ds = fs.getDirectoryScanner(getProject());
             String[] srcFiles = ds.getIncludedFiles();
             File directory = fs.getDir(getProject());
-            for (int i = 0, c = srcFiles.length; i < c; i++) {
-                String filename = srcFiles[i];
+            for (String filename : srcFiles) {
                 File src = new File(directory, filename);
                 boolean eventProducerFound = collector.scanFile(src);
                 if (eventProducerFound) {