diff options
132 files changed, 708 insertions, 840 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/afp/AFPGraphics2D.java b/fop-core/src/main/java/org/apache/fop/afp/AFPGraphics2D.java index f6db94458..e42b07fc5 100644 --- a/fop-core/src/main/java/org/apache/fop/afp/AFPGraphics2D.java +++ b/fop-core/src/main/java/org/apache/fop/afp/AFPGraphics2D.java @@ -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]), diff --git a/fop-core/src/main/java/org/apache/fop/afp/DataStream.java b/fop-core/src/main/java/org/apache/fop/afp/DataStream.java index e9e574a6f..5244d9212 100644 --- a/fop-core/src/main/java/org/apache/fop/afp/DataStream.java +++ b/fop-core/src/main/java/org/apache/fop/afp/DataStream.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java b/fop-core/src/main/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java index 39d2be845..4174f31d8 100644 --- a/fop-core/src/main/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java +++ b/fop-core/src/main/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java @@ -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); } diff --git a/fop-core/src/main/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java b/fop-core/src/main/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java index f5808bda6..d4b3c68ec 100644 --- a/fop-core/src/main/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java +++ b/fop-core/src/main/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/afp/modca/MapPageOverlay.java b/fop-core/src/main/java/org/apache/fop/afp/modca/MapPageOverlay.java index cde2e031d..67a1ae1b8 100644 --- a/fop-core/src/main/java/org/apache/fop/afp/modca/MapPageOverlay.java +++ b/fop-core/src/main/java/org/apache/fop/afp/modca/MapPageOverlay.java @@ -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) diff --git a/fop-core/src/main/java/org/apache/fop/apps/FOUserAgent.java b/fop-core/src/main/java/org/apache/fop/apps/FOUserAgent.java index 43d2b9d80..2aaa2ad22 100644 --- a/fop-core/src/main/java/org/apache/fop/apps/FOUserAgent.java +++ b/fop-core/src/main/java/org/apache/fop/apps/FOUserAgent.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java b/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java index a42ef1549..c68226db5 100644 --- a/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java +++ b/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/area/LineArea.java b/fop-core/src/main/java/org/apache/fop/area/LineArea.java index 8639b8201..f659c2d78 100644 --- a/fop-core/src/main/java/org/apache/fop/area/LineArea.java +++ b/fop-core/src/main/java/org/apache/fop/area/LineArea.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/area/Span.java b/fop-core/src/main/java/org/apache/fop/area/Span.java index e0f8633be..41610f355 100644 --- a/fop-core/src/main/java/org/apache/fop/area/Span.java +++ b/fop-core/src/main/java/org/apache/fop/area/Span.java @@ -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; } diff --git a/fop-core/src/main/java/org/apache/fop/area/Trait.java b/fop-core/src/main/java/org/apache/fop/area/Trait.java index 51bf5cad0..cfde0c83b 100644 --- a/fop-core/src/main/java/org/apache/fop/area/Trait.java +++ b/fop-core/src/main/java/org/apache/fop/area/Trait.java @@ -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=")) { diff --git a/fop-core/src/main/java/org/apache/fop/area/inline/InlineParent.java b/fop-core/src/main/java/org/apache/fop/area/inline/InlineParent.java index 2e03f4d80..66075b641 100644 --- a/fop-core/src/main/java/org/apache/fop/area/inline/InlineParent.java +++ b/fop-core/src/main/java/org/apache/fop/area/inline/InlineParent.java @@ -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(); } } diff --git a/fop-core/src/main/java/org/apache/fop/area/inline/TextArea.java b/fop-core/src/main/java/org/apache/fop/area/inline/TextArea.java index 5a1b31c98..3081a38eb 100644 --- a/fop-core/src/main/java/org/apache/fop/area/inline/TextArea.java +++ b/fop-core/src/main/java/org/apache/fop/area/inline/TextArea.java @@ -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; } diff --git a/fop-core/src/main/java/org/apache/fop/cli/CommandLineOptions.java b/fop-core/src/main/java/org/apache/fop/cli/CommandLineOptions.java index 8bc16fec4..f62b38670 100644 --- a/fop-core/src/main/java/org/apache/fop/cli/CommandLineOptions.java +++ b/fop-core/src/main/java/org/apache/fop/cli/CommandLineOptions.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/cli/Main.java b/fop-core/src/main/java/org/apache/fop/cli/Main.java index b4c294e6e..e082265f1 100644 --- a/fop-core/src/main/java/org/apache/fop/cli/Main.java +++ b/fop-core/src/main/java/org/apache/fop/cli/Main.java @@ -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()); } } } diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/BidiResolver.java b/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/BidiResolver.java index e458e781c..6c9c6fbbc 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/BidiResolver.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/BidiResolver.java @@ -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); } diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/DelimitedTextRange.java b/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/DelimitedTextRange.java index 67bb0aae1..75de90b5e 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/DelimitedTextRange.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/DelimitedTextRange.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/InlineRun.java b/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/InlineRun.java index 828da13e3..2fafbe233 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/InlineRun.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/InlineRun.java @@ -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(); diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/UnflattenProcessor.java b/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/UnflattenProcessor.java index 456aa52ad..23b34f169 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/UnflattenProcessor.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/bidi/UnflattenProcessor.java @@ -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()) { diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphClassTable.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphClassTable.java index 25ff6034f..b15fcbead 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphClassTable.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphClassTable.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphCoverageTable.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphCoverageTable.java index a4251e9ef..aecebc3f0 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphCoverageTable.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphCoverageTable.java @@ -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++; diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionTable.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionTable.java index 2ed1c2875..aaba89636 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionTable.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphDefinitionTable.java @@ -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 { diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphMappingTable.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphMappingTable.java index 469bb6211..5511670b8 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphMappingTable.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphMappingTable.java @@ -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; } diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphPositioningState.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphPositioningState.java index 08c533860..7dfc54454 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphPositioningState.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphPositioningState.java @@ -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) { diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java index 705c0ff67..4713f02cf 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java @@ -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(); diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionState.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionState.java index da40bbd87..0be47b8c1 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionState.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionState.java @@ -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) { diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java index 35df1f48f..26e3a35c7 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubtable.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubtable.java index a53fdfd34..135901735 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubtable.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubtable.java @@ -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); } diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphTable.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphTable.java index de5d8f824..46a724b88 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphTable.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphTable.java @@ -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); } diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java index ca51e9a24..74bf803d8 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java @@ -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(); diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/IndicScriptProcessor.java b/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/IndicScriptProcessor.java index 01d5c6d70..9e7721121 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/IndicScriptProcessor.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/IndicScriptProcessor.java @@ -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) { diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/ScriptProcessor.java b/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/ScriptProcessor.java index d492045f1..82dc822be 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/ScriptProcessor.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/ScriptProcessor.java @@ -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; } diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/util/CharAssociation.java b/fop-core/src/main/java/org/apache/fop/complexscripts/util/CharAssociation.java index 23aebbb9a..f5d15b303 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/util/CharAssociation.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/util/CharAssociation.java @@ -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 ]; diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/util/CharScript.java b/fop-core/src/main/java/org/apache/fop/complexscripts/util/CharScript.java index e82bb4779..dbe98f19f 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/util/CharScript.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/util/CharScript.java @@ -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) { diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/util/GlyphSequence.java b/fop-core/src/main/java/org/apache/fop/complexscripts/util/GlyphSequence.java index 2b1d636e1..72fc357f0 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/util/GlyphSequence.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/util/GlyphSequence.java @@ -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()); } diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/util/NumberConverter.java b/fop-core/src/main/java/org/apache/fop/complexscripts/util/NumberConverter.java index 817f70a18..6a21851fa 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/util/NumberConverter.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/util/NumberConverter.java @@ -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; } } diff --git a/fop-core/src/main/java/org/apache/fop/datatypes/URISpecification.java b/fop-core/src/main/java/org/apache/fop/datatypes/URISpecification.java index 9beb817d0..718d84695 100644 --- a/fop-core/src/main/java/org/apache/fop/datatypes/URISpecification.java +++ b/fop-core/src/main/java/org/apache/fop/datatypes/URISpecification.java @@ -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."); diff --git a/fop-core/src/main/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java b/fop-core/src/main/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java index 0af17996d..1a7e6fe3f 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java +++ b/fop-core/src/main/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java @@ -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; } } diff --git a/fop-core/src/main/java/org/apache/fop/fo/flow/table/EffRow.java b/fop-core/src/main/java/org/apache/fop/fo/flow/table/EffRow.java index a5853cd91..450aaec14 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/flow/table/EffRow.java +++ b/fop-core/src/main/java/org/apache/fop/fo/flow/table/EffRow.java @@ -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()); diff --git a/fop-core/src/main/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java b/fop-core/src/main/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java index c3aa9e710..7376873bb 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java +++ b/fop-core/src/main/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java b/fop-core/src/main/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java index 84b4c3769..792fb1f15 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java +++ b/fop-core/src/main/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java @@ -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(); } diff --git a/fop-core/src/main/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java b/fop-core/src/main/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java index 4860a07ac..7dc1556e6 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java +++ b/fop-core/src/main/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java @@ -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; } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/CustomFontCollection.java b/fop-core/src/main/java/org/apache/fop/fonts/CustomFontCollection.java index 35231e224..d12004e72 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/CustomFontCollection.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/CustomFontCollection.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfigurator.java b/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfigurator.java index 55a1dfa98..c8d1c00e2 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfigurator.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfigurator.java @@ -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() + ", " diff --git a/fop-core/src/main/java/org/apache/fop/fonts/FontAdder.java b/fop-core/src/main/java/org/apache/fop/fonts/FontAdder.java index f585dbfa5..97336287c 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/FontAdder.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/FontAdder.java @@ -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); } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/FontCache.java b/fop-core/src/main/java/org/apache/fop/fonts/FontCache.java index 8379ac137..dd2450e4d 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/FontCache.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/FontCache.java @@ -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:")) { diff --git a/fop-core/src/main/java/org/apache/fop/fonts/FontInfo.java b/fop-core/src/main/java/org/apache/fop/fonts/FontInfo.java index b2cf38189..e54844829 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/FontInfo.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/FontInfo.java @@ -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); } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/FontManager.java b/fop-core/src/main/java/org/apache/fop/fonts/FontManager.java index 266220d14..049a2640f 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/FontManager.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/FontManager.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/fonts/FontManagerConfigurator.java b/fop-core/src/main/java/org/apache/fop/fonts/FontManagerConfigurator.java index 72c1684b6..01502c5c2 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/FontManagerConfigurator.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/FontManagerConfigurator.java @@ -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; } } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/FontSelector.java b/fop-core/src/main/java/org/apache/fop/fonts/FontSelector.java index a80a0e368..66c30b21b 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/FontSelector.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/FontSelector.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/fonts/FontSetup.java b/fop-core/src/main/java/org/apache/fop/fonts/FontSetup.java index f9bae3332..50586784a 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/FontSetup.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/FontSetup.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/FontUtil.java b/fop-core/src/main/java/org/apache/fop/fonts/FontUtil.java index 1966d9fca..5c95c81bf 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/FontUtil.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/FontUtil.java @@ -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; } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/MultiByteFont.java b/fop-core/src/main/java/org/apache/fop/fonts/MultiByteFont.java index db72bee0c..2d04e0d35 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/MultiByteFont.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/MultiByteFont.java @@ -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; } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/SingleByteFont.java b/fop-core/src/main/java/org/apache/fop/fonts/SingleByteFont.java index 9dbd8a5d2..eb273d172 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/SingleByteFont.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/SingleByteFont.java @@ -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) { diff --git a/fop-core/src/main/java/org/apache/fop/fonts/XMLFontMetricsReader.java b/fop-core/src/main/java/org/apache/fop/fonts/XMLFontMetricsReader.java index 7f3927f24..dcdbff05b 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/XMLFontMetricsReader.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/XMLFontMetricsReader.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java b/fop-core/src/main/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java index 9f723a308..d1924033d 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java @@ -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); } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/substitute/FontQualifier.java b/fop-core/src/main/java/org/apache/fop/fonts/substitute/FontQualifier.java index 820326d11..865211a3e 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/substitute/FontQualifier.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/substitute/FontQualifier.java @@ -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)); } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/substitute/FontSubstitutions.java b/fop-core/src/main/java/org/apache/fop/fonts/substitute/FontSubstitutions.java index e96459577..20af38520 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/substitute/FontSubstitutions.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/substitute/FontSubstitutions.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java b/fop-core/src/main/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java index fb60473fc..885a4d2a1 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java @@ -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"); } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java index 5be2140fe..cda3ce5ec 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java @@ -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); } } } diff --git a/fop-core/src/main/java/org/apache/fop/hyphenation/HyphenationTree.java b/fop-core/src/main/java/org/apache/fop/hyphenation/HyphenationTree.java index f61e8a11a..e151568ec 100644 --- a/fop-core/src/main/java/org/apache/fop/hyphenation/HyphenationTree.java +++ b/fop-core/src/main/java/org/apache/fop/hyphenation/HyphenationTree.java @@ -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++; } diff --git a/fop-core/src/main/java/org/apache/fop/hyphenation/PatternParser.java b/fop-core/src/main/java/org/apache/fop/hyphenation/PatternParser.java index 2fc5984ad..6bf3391e6 100644 --- a/fop-core/src/main/java/org/apache/fop/hyphenation/PatternParser.java +++ b/fop-core/src/main/java/org/apache/fop/hyphenation/PatternParser.java @@ -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); } } } diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/SpaceResolver.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/SpaceResolver.java index 551e7d3f2..c8c6b9052 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/SpaceResolver.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/SpaceResolver.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java index 83b9502f2..c5031cd0f 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java @@ -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); } diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index 66a4d1a15..41f0cd5a4 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -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; } diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/ColumnSetup.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/ColumnSetup.java index 8fae90849..35e8c0c4f 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/ColumnSetup.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/ColumnSetup.java @@ -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) { diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java index ed46d2199..3b263b09f 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/RowPainter.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/RowPainter.java index 3ee6f53b1..85c016537 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/RowPainter.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/RowPainter.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index 2a4aff24e..42c174d64 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -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) { diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index eb82a0538..16eba41fa 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index ea6cb2b22..9458793c7 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -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); } diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableRowIterator.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableRowIterator.java index c51c86997..93985425b 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableRowIterator.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableRowIterator.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableStepper.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableStepper.java index 7c98bd481..a6344f4b7 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFArray.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFArray.java index 1be4e9af0..bfcc1c7e0 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFArray.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFArray.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFColorHandler.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFColorHandler.java index 3477ea3e7..027fedce9 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFColorHandler.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFColorHandler.java @@ -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"); diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFFilterList.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFFilterList.java index 19d15d0d2..fbb7d57a6 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFFilterList.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFFilterList.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFPages.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFPages.java index d335bde52..4e83c3d53 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFPages.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFPages.java @@ -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!"); } diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFPaintingState.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFPaintingState.java index ce4296a20..fa09ee4e7 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFPaintingState.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFPaintingState.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFText.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFText.java index a1b3cff16..2d09e27a9 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFText.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFText.java @@ -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('\\'); diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFWArray.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFWArray.java index ad6d2ac29..32fde7e83 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFWArray.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFWArray.java @@ -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("] "); diff --git a/fop-core/src/main/java/org/apache/fop/render/AbstractFOEventHandlerMaker.java b/fop-core/src/main/java/org/apache/fop/render/AbstractFOEventHandlerMaker.java index 0d891efe9..335505fec 100644 --- a/fop-core/src/main/java/org/apache/fop/render/AbstractFOEventHandlerMaker.java +++ b/fop-core/src/main/java/org/apache/fop/render/AbstractFOEventHandlerMaker.java @@ -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; } } diff --git a/fop-core/src/main/java/org/apache/fop/render/AbstractRenderer.java b/fop-core/src/main/java/org/apache/fop/render/AbstractRenderer.java index 458bed6a3..5b5ed0f3f 100644 --- a/fop-core/src/main/java/org/apache/fop/render/AbstractRenderer.java +++ b/fop-core/src/main/java/org/apache/fop/render/AbstractRenderer.java @@ -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(); diff --git a/fop-core/src/main/java/org/apache/fop/render/AbstractRendererMaker.java b/fop-core/src/main/java/org/apache/fop/render/AbstractRendererMaker.java index 505a60a1c..ac606792f 100644 --- a/fop-core/src/main/java/org/apache/fop/render/AbstractRendererMaker.java +++ b/fop-core/src/main/java/org/apache/fop/render/AbstractRendererMaker.java @@ -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; } } diff --git a/fop-core/src/main/java/org/apache/fop/render/ImageHandlerRegistry.java b/fop-core/src/main/java/org/apache/fop/render/ImageHandlerRegistry.java index 18e5b1272..2ef22739f 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ImageHandlerRegistry.java +++ b/fop-core/src/main/java/org/apache/fop/render/ImageHandlerRegistry.java @@ -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); } } } diff --git a/fop-core/src/main/java/org/apache/fop/render/RendererFactory.java b/fop-core/src/main/java/org/apache/fop/render/RendererFactory.java index df5213dad..899beb293 100644 --- a/fop-core/src/main/java/org/apache/fop/render/RendererFactory.java +++ b/fop-core/src/main/java/org/apache/fop/render/RendererFactory.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/render/XMLHandlerConfigurator.java b/fop-core/src/main/java/org/apache/fop/render/XMLHandlerConfigurator.java index 9baed9959..ac50da273 100644 --- a/fop-core/src/main/java/org/apache/fop/render/XMLHandlerConfigurator.java +++ b/fop-core/src/main/java/org/apache/fop/render/XMLHandlerConfigurator.java @@ -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) { diff --git a/fop-core/src/main/java/org/apache/fop/render/XMLHandlerRegistry.java b/fop-core/src/main/java/org/apache/fop/render/XMLHandlerRegistry.java index cad09bff9..9eae3d5e8 100644 --- a/fop-core/src/main/java/org/apache/fop/render/XMLHandlerRegistry.java +++ b/fop-core/src/main/java/org/apache/fop/render/XMLHandlerRegistry.java @@ -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; } diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/AFPRendererConfig.java b/fop-core/src/main/java/org/apache/fop/render/afp/AFPRendererConfig.java index a943f5aad..062933df6 100644 --- a/fop-core/src/main/java/org/apache/fop/render/afp/AFPRendererConfig.java +++ b/fop-core/src/main/java/org/apache/fop/render/afp/AFPRendererConfig.java @@ -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)); diff --git a/fop-core/src/main/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandlerMaker.java b/fop-core/src/main/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandlerMaker.java index 610f522c2..4963257a0 100644 --- a/fop-core/src/main/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandlerMaker.java +++ b/fop-core/src/main/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandlerMaker.java @@ -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; } } diff --git a/fop-core/src/main/java/org/apache/fop/render/intermediate/AbstractIFPainter.java b/fop-core/src/main/java/org/apache/fop/render/intermediate/AbstractIFPainter.java index cbe883d3c..694871bd8 100644 --- a/fop-core/src/main/java/org/apache/fop/render/intermediate/AbstractIFPainter.java +++ b/fop-core/src/main/java/org/apache/fop/render/intermediate/AbstractIFPainter.java @@ -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; } diff --git a/fop-core/src/main/java/org/apache/fop/render/intermediate/IFRenderer.java b/fop-core/src/main/java/org/apache/fop/render/intermediate/IFRenderer.java index 692e08398..3ea7fc2cd 100644 --- a/fop-core/src/main/java/org/apache/fop/render/intermediate/IFRenderer.java +++ b/fop-core/src/main/java/org/apache/fop/render/intermediate/IFRenderer.java @@ -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); } diff --git a/fop-core/src/main/java/org/apache/fop/render/intermediate/IFUtil.java b/fop-core/src/main/java/org/apache/fop/render/intermediate/IFUtil.java index a534ca729..b877abad5 100644 --- a/fop-core/src/main/java/org/apache/fop/render/intermediate/IFUtil.java +++ b/fop-core/src/main/java/org/apache/fop/render/intermediate/IFUtil.java @@ -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; } diff --git a/fop-core/src/main/java/org/apache/fop/render/java2d/InstalledFontCollection.java b/fop-core/src/main/java/org/apache/fop/render/java2d/InstalledFontCollection.java index afb22a883..14ce69568 100644 --- a/fop-core/src/main/java/org/apache/fop/render/java2d/InstalledFontCollection.java +++ b/fop-core/src/main/java/org/apache/fop/render/java2d/InstalledFontCollection.java @@ -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 } diff --git a/fop-core/src/main/java/org/apache/fop/render/pcl/PCLGenerator.java b/fop-core/src/main/java/org/apache/fop/render/pcl/PCLGenerator.java index 6a4f3215e..119ec857c 100644 --- a/fop-core/src/main/java/org/apache/fop/render/pcl/PCLGenerator.java +++ b/fop-core/src/main/java/org/apache/fop/render/pcl/PCLGenerator.java @@ -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; } diff --git a/fop-core/src/main/java/org/apache/fop/render/ps/PSImageHandlerSVG.java b/fop-core/src/main/java/org/apache/fop/render/ps/PSImageHandlerSVG.java index c679d7d75..b034fa79e 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ps/PSImageHandlerSVG.java +++ b/fop-core/src/main/java/org/apache/fop/render/ps/PSImageHandlerSVG.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java b/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java index 052c6fc26..b94a07e0b 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java @@ -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( diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java index 605db7150..3b7535c2a 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java @@ -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)); diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfContainer.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfContainer.java index a42d25b69..46dd3d0ee 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfContainer.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfContainer.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java index b9f0b501d..27d10e710 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java @@ -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)); } diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java index aa3a403fa..e936305f9 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java @@ -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) { diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java index 55f8cbf27..8996fe96b 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java index 845ee1d28..85fbbb8ff 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java @@ -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, diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListTable.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListTable.java index ff65c4fe1..a8e4a571f 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListTable.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListTable.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceManager.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceManager.java index e38a78c95..a9a2e8a1d 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceManager.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSpaceManager.java @@ -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); } diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java index 5203d0a79..263f6d1ac 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java @@ -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; diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java index 10039e40d..566e2c7ce 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java @@ -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(); diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java index aa1b226f6..9758ab0b4 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java @@ -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 diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java index abe903a73..dcb5c0843 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java @@ -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 diff --git a/fop-core/src/main/java/org/apache/fop/render/txt/TXTState.java b/fop-core/src/main/java/org/apache/fop/render/txt/TXTState.java index 09abc2515..839fe1bc2 100644 --- a/fop-core/src/main/java/org/apache/fop/render/txt/TXTState.java +++ b/fop-core/src/main/java/org/apache/fop/render/txt/TXTState.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/render/xml/XMLRenderer.java b/fop-core/src/main/java/org/apache/fop/render/xml/XMLRenderer.java index e226c88dd..e1a123322 100644 --- a/fop-core/src/main/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/fop-core/src/main/java/org/apache/fop/render/xml/XMLRenderer.java @@ -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()); diff --git a/fop-core/src/main/java/org/apache/fop/svg/NativeTextPainter.java b/fop-core/src/main/java/org/apache/fop/svg/NativeTextPainter.java index 983a184c4..b5bbd27bc 100644 --- a/fop-core/src/main/java/org/apache/fop/svg/NativeTextPainter.java +++ b/fop-core/src/main/java/org/apache/fop/svg/NativeTextPainter.java @@ -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) { diff --git a/fop-core/src/main/java/org/apache/fop/svg/PDFGraphics2D.java b/fop-core/src/main/java/org/apache/fop/svg/PDFGraphics2D.java index a73cdc243..3fa6d3149 100644 --- a/fop-core/src/main/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/fop-core/src/main/java/org/apache/fop/svg/PDFGraphics2D.java @@ -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, diff --git a/fop-core/src/main/java/org/apache/fop/tools/anttasks/FileCompare.java b/fop-core/src/main/java/org/apache/fop/tools/anttasks/FileCompare.java index 7fa588e23..931f02819 100644 --- a/fop-core/src/main/java/org/apache/fop/tools/anttasks/FileCompare.java +++ b/fop-core/src/main/java/org/apache/fop/tools/anttasks/FileCompare.java @@ -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>"); } } } diff --git a/fop-core/src/main/java/org/apache/fop/tools/anttasks/Fop.java b/fop-core/src/main/java/org/apache/fop/tools/anttasks/Fop.java index 8460e5964..d35c00436 100644 --- a/fop-core/src/main/java/org/apache/fop/tools/anttasks/Fop.java +++ b/fop-core/src/main/java/org/apache/fop/tools/anttasks/Fop.java @@ -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 { diff --git a/fop-core/src/main/java/org/apache/fop/traits/BorderStyle.java b/fop-core/src/main/java/org/apache/fop/traits/BorderStyle.java index 2f274df22..19825dc80 100644 --- a/fop-core/src/main/java/org/apache/fop/traits/BorderStyle.java +++ b/fop-core/src/main/java/org/apache/fop/traits/BorderStyle.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/traits/Direction.java b/fop-core/src/main/java/org/apache/fop/traits/Direction.java index 378c8dd2a..6c70d1945 100644 --- a/fop-core/src/main/java/org/apache/fop/traits/Direction.java +++ b/fop-core/src/main/java/org/apache/fop/traits/Direction.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/traits/RuleStyle.java b/fop-core/src/main/java/org/apache/fop/traits/RuleStyle.java index 19b57d76f..db2921fbc 100644 --- a/fop-core/src/main/java/org/apache/fop/traits/RuleStyle.java +++ b/fop-core/src/main/java/org/apache/fop/traits/RuleStyle.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/traits/WritingMode.java b/fop-core/src/main/java/org/apache/fop/traits/WritingMode.java index f8c784941..ca1ee7445 100644 --- a/fop-core/src/main/java/org/apache/fop/traits/WritingMode.java +++ b/fop-core/src/main/java/org/apache/fop/traits/WritingMode.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/util/ColorExt.java b/fop-core/src/main/java/org/apache/fop/util/ColorExt.java index a910a54dd..cbb50c511 100644 --- a/fop-core/src/main/java/org/apache/fop/util/ColorExt.java +++ b/fop-core/src/main/java/org/apache/fop/util/ColorExt.java @@ -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(); diff --git a/fop-core/src/main/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java b/fop-core/src/main/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java index ceedf9f12..395433369 100644 --- a/fop-core/src/main/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java +++ b/fop-core/src/main/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/util/DOM2SAX.java b/fop-core/src/main/java/org/apache/fop/util/DOM2SAX.java index 39d2af4a1..486877ad0 100644 --- a/fop-core/src/main/java/org/apache/fop/util/DOM2SAX.java +++ b/fop-core/src/main/java/org/apache/fop/util/DOM2SAX.java @@ -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; diff --git a/fop-core/src/test/java/org/apache/fop/DigestFilterTestCase.java b/fop-core/src/test/java/org/apache/fop/DigestFilterTestCase.java index 679b65aee..17aae6776 100644 --- a/fop-core/src/test/java/org/apache/fop/DigestFilterTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/DigestFilterTestCase.java @@ -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) { diff --git a/fop-core/src/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java b/fop-core/src/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java index a4c80cc65..74257833a 100644 --- a/fop-core/src/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java +++ b/fop-core/src/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java @@ -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]); diff --git a/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java b/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java index c251ba3b2..411556138 100644 --- a/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java +++ b/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/ttx/TTXFile.java @@ -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) { diff --git a/fop-core/src/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java b/fop-core/src/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java index 884116441..b669d9c11 100644 --- a/fop-core/src/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java @@ -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); } } diff --git a/fop-core/src/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java b/fop-core/src/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java index 23eb999f0..664b4ab0d 100644 --- a/fop-core/src/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/fotreetest/FOTreeTestCase.java @@ -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)); } diff --git a/fop-core/src/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java b/fop-core/src/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java index 7f17514ef..15a8ba848 100644 --- a/fop-core/src/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java +++ b/fop-core/src/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java @@ -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); } } diff --git a/fop-core/src/test/java/org/apache/fop/threading/FOPTestbed.java b/fop-core/src/test/java/org/apache/fop/threading/FOPTestbed.java index 7b08b7cd1..7b03ada61 100644 --- a/fop-core/src/test/java/org/apache/fop/threading/FOPTestbed.java +++ b/fop-core/src/test/java/org/apache/fop/threading/FOPTestbed.java @@ -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"); } diff --git a/fop-core/src/test/java/org/apache/fop/util/DigestFilter.java b/fop-core/src/test/java/org/apache/fop/util/DigestFilter.java index 9e62fdc1c..fb5f2dcb0 100644 --- a/fop-core/src/test/java/org/apache/fop/util/DigestFilter.java +++ b/fop-core/src/test/java/org/apache/fop/util/DigestFilter.java @@ -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); } diff --git a/fop-core/src/test/java/org/apache/fop/visual/BitmapComparator.java b/fop-core/src/test/java/org/apache/fop/visual/BitmapComparator.java index f2157176b..ea2e67895 100644 --- a/fop-core/src/test/java/org/apache/fop/visual/BitmapComparator.java +++ b/fop-core/src/test/java/org/apache/fop/visual/BitmapComparator.java @@ -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 } diff --git a/fop-events/src/main/java/org/apache/fop/events/DefaultEventBroadcaster.java b/fop-events/src/main/java/org/apache/fop/events/DefaultEventBroadcaster.java index 596a0a86b..24499ea35 100644 --- a/fop-events/src/main/java/org/apache/fop/events/DefaultEventBroadcaster.java +++ b/fop-events/src/main/java/org/apache/fop/events/DefaultEventBroadcaster.java @@ -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; diff --git a/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java b/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java index 7151f5a9c..2351fc870 100644 --- a/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java +++ b/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java @@ -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); } diff --git a/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollectorTask.java b/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollectorTask.java index 85c10f09a..f56eea2e4 100644 --- a/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollectorTask.java +++ b/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollectorTask.java @@ -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) { |