commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1416981 - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/ main/java/org/apache/commons/imaging/common/ main/java/org/apache/commons/imaging/common/itu_t4/ main/java/org/apache/commons/imaging/formats/dcx/ main/j...
Date Tue, 04 Dec 2012 15:11:29 GMT
Author: ggregory
Date: Tue Dec  4 15:11:16 2012
New Revision: 1416981

URL: http://svn.apache.org/viewvc?rev=1416981&view=rev
Log:
Use Java 5 enhanced 'for' loops.

Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/FormatCompliance.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageDump.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryConstant.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/Debug.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/color/ColorConversionsTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/png/PngMultipleRoundtripTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/png/PngWriteReadTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/FormatCompliance.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/FormatCompliance.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/FormatCompliance.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/FormatCompliance.java Tue Dec  4 15:11:16 2012
@@ -130,8 +130,8 @@ public class FormatCompliance {
 
     public boolean compare(String name, int valid[], int actual)
             throws ImageReadException {
-        for (int i = 0; i < valid.length; i++) {
-            if (actual == valid[i]) {
+        for (int element : valid) {
+            if (actual == element) {
                 return true;
             }
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageDump.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageDump.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageDump.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageDump.java Tue Dec  4 15:11:16 2012
@@ -90,8 +90,7 @@ public class ImageDump {
             System.out.println(prefix + ": no props");
             return;
         }
-        for (int i = 0; i < keys.length; i++) {
-            String key = keys[i];
+        for (String key : keys) {
             System.out.println(prefix + ": " + key + ": "
                     + src.getProperty(key));
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageParser.java Tue Dec  4 15:11:16 2012
@@ -922,8 +922,8 @@ public abstract class ImageParser extend
     public boolean canAcceptType(ImageFormat type) {
         ImageFormat types[] = getAcceptedTypes();
 
-        for (int i = 0; i < types.length; i++) {
-            if (types[i].equals(type)) {
+        for (ImageFormat type2 : types) {
+            if (type2.equals(type)) {
                 return true;
             }
         }
@@ -957,8 +957,8 @@ public abstract class ImageParser extend
             String ext = filename.substring(index);
             ext = ext.toLowerCase();
 
-            for (int i = 0; i < exts.length; i++) {
-                if (exts[i].toLowerCase().equals(ext)) {
+            for (String ext2 : exts) {
+                if (ext2.toLowerCase().equals(ext)) {
                     return true;
                 }
             }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java Tue Dec  4 15:11:16 2012
@@ -119,12 +119,10 @@ public abstract class Imaging implements
         filename = filename.toLowerCase();
 
         ImageParser imageParsers[] = ImageParser.getAllImageParsers();
-        for (int i = 0; i < imageParsers.length; i++) {
-            ImageParser imageParser = imageParsers[i];
+        for (ImageParser imageParser : imageParsers) {
             String exts[] = imageParser.getAcceptedExtensions();
 
-            for (int j = 0; j < exts.length; j++) {
-                String ext = exts[j];
+            for (String ext : exts) {
                 if (filename.endsWith(ext.toLowerCase())) {
                     return true;
                 }
@@ -704,9 +702,7 @@ public abstract class Imaging implements
 
             ImageParser imageParsers[] = ImageParser.getAllImageParsers();
 
-            for (int i = 0; i < imageParsers.length; i++) {
-                ImageParser imageParser = imageParsers[i];
-
+            for (ImageParser imageParser : imageParsers) {
                 if (imageParser.canAcceptType(format)) {
                     return imageParser;
                 }
@@ -717,9 +713,7 @@ public abstract class Imaging implements
         if (filename != null) {
             ImageParser imageParsers[] = ImageParser.getAllImageParsers();
 
-            for (int i = 0; i < imageParsers.length; i++) {
-                ImageParser imageParser = imageParsers[i];
-
+            for (ImageParser imageParser : imageParsers) {
                 if (imageParser.canAcceptExtension(filename)) {
                     return imageParser;
                 }
@@ -1489,8 +1483,8 @@ public abstract class Imaging implements
 
         params.put(PARAM_KEY_FORMAT, format);
 
-        for (int i = 0; i < imageParsers.length; i++) {
-            ImageParser imageParser = imageParsers[i];
+        for (ImageParser imageParser2 : imageParsers) {
+            ImageParser imageParser = imageParser2;
 
             if (!imageParser.canAcceptType(format)) {
                 continue;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BasicCParser.java Tue Dec  4 15:11:16 2012
@@ -230,16 +230,16 @@ public class BasicCParser {
     public static String[] tokenizeRow(String row) {
         String[] tokens = row.split("[ \t]");
         int numLiveTokens = 0;
-        for (int i = 0; i < tokens.length; i++) {
-            if (tokens[i] != null && tokens[i].length() > 0) {
+        for (String token : tokens) {
+            if (token != null && token.length() > 0) {
                 ++numLiveTokens;
             }
         }
         String[] liveTokens = new String[numLiveTokens];
         int next = 0;
-        for (int i = 0; i < tokens.length; i++) {
-            if (tokens[i] != null && tokens[i].length() > 0) {
-                liveTokens[next++] = tokens[i];
+        for (String token : tokens) {
+            if (token != null && token.length() > 0) {
+                liveTokens[next++] = token;
             }
         }
         return liveTokens;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryConstant.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryConstant.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryConstant.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryConstant.java Tue Dec  4 15:11:16 2012
@@ -78,8 +78,8 @@ public class BinaryConstant implements C
     }
 
     public void writeTo(OutputStream os) throws IOException {
-        for (int i = 0; i < value.length; i++) {
-            os.write(value[i]);
+        for (byte element : value) {
+            os.write(element);
         }
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java Tue Dec  4 15:11:16 2012
@@ -108,7 +108,7 @@ public class BinaryFileFunctions {
 
     public final void readAndVerifyBytes(InputStream is, byte expected[],
             String exception) throws ImageReadException, IOException {
-        for (int i = 0; i < expected.length; i++) {
+        for (byte element : expected) {
             int data = is.read();
             byte b = (byte) (0xff & data);
 
@@ -116,7 +116,7 @@ public class BinaryFileFunctions {
                 throw new ImageReadException("Unexpected EOF.");
             }
 
-            if (b != expected[i]) {
+            if (b != element) {
                 // System.out.println("i" + ": " + i);
 
                 // this.debugByteArray("expected", expected);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/itu_t4/T4AndT6Compression.java Tue Dec  4 15:11:16 2012
@@ -23,6 +23,7 @@ import org.apache.commons.imaging.ImageR
 import org.apache.commons.imaging.ImageWriteException;
 import org.apache.commons.imaging.common.BitArrayOutputStream;
 import org.apache.commons.imaging.common.BitInputStreamFlexible;
+import org.apache.commons.imaging.common.itu_t4.T4_T6_Tables.Entry;
 import org.apache.commons.imaging.util.Debug;
 
 public class T4AndT6Compression {
@@ -35,24 +36,19 @@ public class T4AndT6Compression {
 
     static {
         try {
-            for (int i = 0; i < T4_T6_Tables.whiteTerminatingCodes.length; i++) {
-                T4_T6_Tables.Entry entry = T4_T6_Tables.whiteTerminatingCodes[i];
+            for (Entry entry : T4_T6_Tables.whiteTerminatingCodes) {
                 whiteRunLengths.insert(entry.bitString, entry.value);
             }
-            for (int i = 0; i < T4_T6_Tables.whiteMakeUpCodes.length; i++) {
-                T4_T6_Tables.Entry entry = T4_T6_Tables.whiteMakeUpCodes[i];
+            for (Entry entry : T4_T6_Tables.whiteMakeUpCodes) {
                 whiteRunLengths.insert(entry.bitString, entry.value);
             }
-            for (int i = 0; i < T4_T6_Tables.blackTerminatingCodes.length; i++) {
-                T4_T6_Tables.Entry entry = T4_T6_Tables.blackTerminatingCodes[i];
+            for (Entry entry : T4_T6_Tables.blackTerminatingCodes) {
                 blackRunLengths.insert(entry.bitString, entry.value);
             }
-            for (int i = 0; i < T4_T6_Tables.blackMakeUpCodes.length; i++) {
-                T4_T6_Tables.Entry entry = T4_T6_Tables.blackMakeUpCodes[i];
+            for (Entry entry : T4_T6_Tables.blackMakeUpCodes) {
                 blackRunLengths.insert(entry.bitString, entry.value);
             }
-            for (int i = 0; i < T4_T6_Tables.additionalMakeUpCodes.length; i++) {
-                T4_T6_Tables.Entry entry = T4_T6_Tables.additionalMakeUpCodes[i];
+            for (Entry entry : T4_T6_Tables.additionalMakeUpCodes) {
                 whiteRunLengths.insert(entry.bitString, entry.value);
                 blackRunLengths.insert(entry.bitString, entry.value);
             }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java Tue Dec  4 15:11:16 2012
@@ -189,10 +189,10 @@ public class DcxImageParser extends Imag
         DcxHeader dcxHeader = readDcxHeader(byteSource);
         List<BufferedImage> images = new ArrayList<BufferedImage>();
         PcxImageParser pcxImageParser = new PcxImageParser();
-        for (int i = 0; i < dcxHeader.pageTable.length; i++) {
+        for (int element : dcxHeader.pageTable) {
             InputStream stream = null;
             try {
-                stream = byteSource.getInputStream(dcxHeader.pageTable[i]);
+                stream = byteSource.getInputStream(element);
                 ByteSourceInputStream pcxSource = new ByteSourceInputStream(
                         stream, null);
                 BufferedImage image = pcxImageParser.getBufferedImage(

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java Tue Dec  4 15:11:16 2012
@@ -22,6 +22,7 @@ import java.util.List;
 
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.common.ImageBuilder;
+import org.apache.commons.imaging.formats.icns.IcnsImageParser.IcnsElement;
 
 public class IcnsDecoder {
     private static final int[] palette_4bpp = { 0xffffffff, 0xfffcf305,
@@ -197,8 +198,7 @@ public class IcnsDecoder {
             IcnsImageParser.IcnsElement[] icnsElements)
             throws ImageReadException {
         List<BufferedImage> result = new ArrayList<BufferedImage>();
-        for (int i = 0; i < icnsElements.length; i++) {
-            IcnsImageParser.IcnsElement imageElement = icnsElements[i];
+        for (IcnsElement imageElement : icnsElements) {
             IcnsType imageType = IcnsType.findImageType(imageElement.type);
             if (imageType == null) {
                 continue;
@@ -212,9 +212,9 @@ public class IcnsDecoder {
             } else {
                 maskType = IcnsType.find8BPPMaskType(imageType);
                 if (maskType != null) {
-                    for (int j = 0; j < icnsElements.length; j++) {
-                        if (icnsElements[j].type == maskType.getType()) {
-                            maskElement = icnsElements[j];
+                    for (IcnsElement icnsElement : icnsElements) {
+                        if (icnsElement.type == maskType.getType()) {
+                            maskElement = icnsElement;
                             break;
                         }
                     }
@@ -222,9 +222,9 @@ public class IcnsDecoder {
                 if (maskElement == null) {
                     maskType = IcnsType.find1BPPMaskType(imageType);
                     if (maskType != null) {
-                        for (int j = 0; j < icnsElements.length; j++) {
-                            if (icnsElements[j].type == maskType.getType()) {
-                                maskElement = icnsElements[j];
+                        for (IcnsElement icnsElement : icnsElements) {
+                            if (icnsElement.type == maskType.getType()) {
+                                maskElement = icnsElement;
                                 break;
                             }
                         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java Tue Dec  4 15:11:16 2012
@@ -270,8 +270,8 @@ public class IcnsImageParser extends Ima
             throws ImageReadException, IOException {
         IcnsContents icnsContents = readImage(byteSource);
         icnsContents.icnsHeader.dump(pw);
-        for (int i = 0; i < icnsContents.icnsElements.length; i++) {
-            icnsContents.icnsElements[i].dump(pw);
+        for (IcnsElement icnsElement : icnsContents.icnsElements) {
+            icnsElement.dump(pw);
         }
         return true;
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java Tue Dec  4 15:11:16 2012
@@ -130,45 +130,45 @@ public class IcnsType {
     }
 
     public static IcnsType findAnyType(int type) {
-        for (int i = 0; i < allImageTypes.length; i++) {
-            if (allImageTypes[i].getType() == type) {
-                return allImageTypes[i];
+        for (IcnsType allImageType : allImageTypes) {
+            if (allImageType.getType() == type) {
+                return allImageType;
             }
         }
-        for (int i = 0; i < allMaskTypes.length; i++) {
-            if (allMaskTypes[i].getType() == type) {
-                return allMaskTypes[i];
+        for (IcnsType allMaskType : allMaskTypes) {
+            if (allMaskType.getType() == type) {
+                return allMaskType;
             }
         }
         return null;
     }
 
     public static IcnsType findImageType(int type) {
-        for (int i = 0; i < allImageTypes.length; i++) {
-            if (allImageTypes[i].getType() == type) {
-                return allImageTypes[i];
+        for (IcnsType allImageType : allImageTypes) {
+            if (allImageType.getType() == type) {
+                return allImageType;
             }
         }
         return null;
     }
 
     public static IcnsType find8BPPMaskType(IcnsType imageType) {
-        for (int i = 0; i < allMaskTypes.length; i++) {
-            if (allMaskTypes[i].getBitsPerPixel() == 8
-                    && allMaskTypes[i].getWidth() == imageType.getWidth()
-                    && allMaskTypes[i].getHeight() == imageType.getHeight()) {
-                return allMaskTypes[i];
+        for (IcnsType allMaskType : allMaskTypes) {
+            if (allMaskType.getBitsPerPixel() == 8
+                    && allMaskType.getWidth() == imageType.getWidth()
+                    && allMaskType.getHeight() == imageType.getHeight()) {
+                return allMaskType;
             }
         }
         return null;
     }
 
     public static IcnsType find1BPPMaskType(IcnsType imageType) {
-        for (int i = 0; i < allMaskTypes.length; i++) {
-            if (allMaskTypes[i].getBitsPerPixel() == 1
-                    && allMaskTypes[i].getWidth() == imageType.getWidth()
-                    && allMaskTypes[i].getHeight() == imageType.getHeight()) {
-                return allMaskTypes[i];
+        for (IcnsType allMaskType : allMaskTypes) {
+            if (allMaskType.getBitsPerPixel() == 1
+                    && allMaskType.getWidth() == imageType.getWidth()
+                    && allMaskType.getHeight() == imageType.getHeight()) {
+                return allMaskType;
             }
         }
         return null;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java Tue Dec  4 15:11:16 2012
@@ -587,8 +587,8 @@ public class IcoImageParser extends Imag
             throws ImageReadException, IOException {
         ImageContents contents = readImage(byteSource);
         contents.fileHeader.dump(pw);
-        for (int i = 0; i < contents.iconDatas.length; i++) {
-            contents.iconDatas[i].dump(pw);
+        for (IconData iconData : contents.iconDatas) {
+            iconData.dump(pw);
         }
         return true;
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java Tue Dec  4 15:11:16 2012
@@ -100,8 +100,8 @@ public class JpegImageParser extends Ima
             return true;
         }
 
-        for (int i = 0; i < markers.length; i++) {
-            if (markers[i] == marker) {
+        for (int marker2 : markers) {
+            if (marker2 == marker) {
                 return true;
             }
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java Tue Dec  4 15:11:16 2012
@@ -100,8 +100,8 @@ public class PcxWriter implements PcxCon
             if (encoding == PcxImageParser.PcxHeader.ENCODING_RLE) {
                 int previousByte = -1;
                 int repeatCount = 0;
-                for (int i = 0; i < scanline.length; i++) {
-                    if ((scanline[i] & 0xff) == previousByte
+                for (byte element : scanline) {
+                    if ((element & 0xff) == previousByte
                             && repeatCount < 63) {
                         ++repeatCount;
                     } else {
@@ -114,7 +114,7 @@ public class PcxWriter implements PcxCon
                                 bos.write(previousByte);
                             }
                         }
-                        previousByte = 0xff & scanline[i];
+                        previousByte = 0xff & element;
                         repeatCount = 1;
                     }
                 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java Tue Dec  4 15:11:16 2012
@@ -147,8 +147,8 @@ public class PngImageParser extends Imag
             return true;
         }
 
-        for (int i = 0; i < chunkTypes.length; i++) {
-            if (chunkTypes[i] == ChunkType) {
+        for (int chunkType2 : chunkTypes) {
+            if (chunkType2 == ChunkType) {
                 return true;
             }
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java Tue Dec  4 15:11:16 2012
@@ -22,9 +22,9 @@ public class PsdConstants {
     static final ImageResourceType fImageResourceTypes[];
 
     public String getDescription(int id) {
-        for (int i = 0; i < fImageResourceTypes.length; i++) {
-            if (fImageResourceTypes[i].ID == id) {
-                return fImageResourceTypes[i].Description;
+        for (ImageResourceType fImageResourceType : fImageResourceTypes) {
+            if (fImageResourceType.ID == id) {
+                return fImageResourceType.Description;
             }
         }
         return "Unknown";

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java Tue Dec  4 15:11:16 2012
@@ -177,8 +177,8 @@ public class PsdImageParser extends Imag
             return true;
         }
 
-        for (int i = 0; i < imageResourceIDs.length; i++) {
-            if (ID == imageResourceIDs[i]) {
+        for (int imageResourceID : imageResourceIDs) {
+            if (ID == imageResourceID) {
                 return true;
             }
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java Tue Dec  4 15:11:16 2012
@@ -724,22 +724,22 @@ public class TiffField implements TiffCo
         } else if (o instanceof Number[]) {
             Number numbers[] = (Number[]) o;
             int sum = 0;
-            for (int i = 0; i < numbers.length; i++) {
-                sum += numbers[i].intValue();
+            for (Number number : numbers) {
+                sum += number.intValue();
             }
             return sum;
         } else if (o instanceof short[]) {
             short[] numbers = (short[]) o;
             int sum = 0;
-            for (int i = 0; i < numbers.length; i++) {
-                sum += numbers[i];
+            for (short number : numbers) {
+                sum += number;
             }
             return sum;
         } else if (o instanceof int[]) {
             int numbers[] = (int[]) o;
             int sum = 0;
-            for (int i = 0; i < numbers.length; i++) {
-                sum += numbers[i];
+            for (int number : numbers) {
+                sum += number;
             }
             return sum;
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java Tue Dec  4 15:11:16 2012
@@ -28,15 +28,15 @@ public class TagConstantsUtils implement
 
     public static List<TagInfo> mergeTagLists(List<?>... tagLists) {
         int count = 0;
-        for (int i = 0; i < tagLists.length; i++) {
-            count += tagLists[i].size();
+        for (List<?> tagList : tagLists) {
+            count += tagList.size();
         }
 
         ArrayList<TagInfo> result = new ArrayList<TagInfo>(count);
 
-        for (int i = 0; i < tagLists.length; i++) {
-            for (int j = 0; j < tagLists[i].size(); j++) {
-                result.add((TagInfo)tagLists[i].get(j));
+        for (List<?> tagList : tagLists) {
+            for (int j = 0; j < tagList.size(); j++) {
+                result.add((TagInfo)tagList.get(j));
             }
         }
 
@@ -45,9 +45,9 @@ public class TagConstantsUtils implement
 
     public static TiffDirectoryType getExifDirectoryType(int type) {
 
-        for (int i = 0; i < tiffDirectoryTypes.length; i++) {
-            if (tiffDirectoryTypes[i].directoryType == type) {
-                return tiffDirectoryTypes[i];
+        for (TiffDirectoryType tiffDirectoryType : tiffDirectoryTypes) {
+            if (tiffDirectoryType.directoryType == type) {
+                return tiffDirectoryType;
             }
         }
         return TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java Tue Dec  4 15:11:16 2012
@@ -101,8 +101,8 @@ public final class DataReaderStrips exte
 
         // verify that all samples are one byte in size
         boolean allSamplesAreOneByte = true;
-        for (int i = 0; i < bitsPerSample.length; i++) {
-            if (bitsPerSample[i] != 8) {
+        for (int element : bitsPerSample) {
+            if (element != 8) {
                 allSamplesAreOneByte = false;
                 break;
             }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java Tue Dec  4 15:11:16 2012
@@ -24,6 +24,7 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.ByteOrder;
 import org.apache.commons.imaging.common.ImageBuilder;
 import org.apache.commons.imaging.formats.tiff.TiffDirectory;
+import org.apache.commons.imaging.formats.tiff.TiffElement.DataElement;
 import org.apache.commons.imaging.formats.tiff.TiffImageData;
 import org.apache.commons.imaging.formats.tiff.photometricinterpreters.PhotometricInterpreter;
 import org.apache.commons.imaging.formats.tiff.photometricinterpreters.PhotometricInterpreterRgb;
@@ -70,8 +71,8 @@ public final class DataReaderTiled exten
 
         // verify that all samples are one byte in size
         boolean allSamplesAreOneByte = true;
-        for (int i = 0; i < bitsPerSample.length; i++) {
-            if (bitsPerSample[i] != 8) {
+        for (int element : bitsPerSample) {
+            if (element != 8) {
                 allSamplesAreOneByte = false;
                 break;
             }
@@ -164,8 +165,8 @@ public final class DataReaderTiled exten
         int bytesPerTile = bytesPerRow * tileLength;
         int x = 0, y = 0;
 
-        for (int tile = 0; tile < imageData.tiles.length; tile++) {
-            byte compressed[] = imageData.tiles[tile].getData();
+        for (DataElement tile2 : imageData.tiles) {
+            byte compressed[] = tile2.getData();
 
             byte decompressed[] = decompress(compressed, compression,
                     bytesPerTile, tileWidth, tileLength);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java Tue Dec  4 15:11:16 2012
@@ -94,10 +94,10 @@ public class FieldTypeAscii extends Fiel
         } else if (o instanceof String[]) {
             String[] strings = (String[]) o;
             int totalLength = 0;
-            for (int i = 0; i < strings.length; i++) {
+            for (String string : strings) {
                 byte[] bytes = null;
                 try {
-                    bytes = strings[i].getBytes("UTF-8");
+                    bytes = string.getBytes("UTF-8");
                 } catch (UnsupportedEncodingException cannotHappen) {
                     throw new IllegalArgumentException("Your Java doesn't support UTF-8");
                 }
@@ -105,10 +105,10 @@ public class FieldTypeAscii extends Fiel
             }
             byte[] result = new byte[totalLength];
             int position = 0;
-            for (int i = 0; i < strings.length; i++) {
+            for (String string : strings) {
                 byte[] bytes = null;
                 try {
-                    bytes = strings[i].getBytes("UTF-8");
+                    bytes = string.getBytes("UTF-8");
                 } catch (UnsupportedEncodingException cannotHappen) {
                     throw new IllegalArgumentException("Your Java doesn't support UTF-8");
                 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java Tue Dec  4 15:11:16 2012
@@ -161,8 +161,7 @@ public final class TagInfoGpsText extend
             }
         }
 
-        for (int i = 0; i < TEXT_ENCODINGS.length; i++) {
-            TagInfoGpsText.TextEncoding encoding = TEXT_ENCODINGS[i];
+        for (TextEncoding encoding : TEXT_ENCODINGS) {
             if (BinaryFileFunctions.compareBytes(bytes, 0, encoding.prefix, 0,
                     encoding.prefix.length)) {
                 try {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java Tue Dec  4 15:11:16 2012
@@ -36,6 +36,7 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.TiffContents;
 import org.apache.commons.imaging.formats.tiff.TiffDirectory;
 import org.apache.commons.imaging.formats.tiff.TiffElement;
+import org.apache.commons.imaging.formats.tiff.TiffElement.DataElement;
 import org.apache.commons.imaging.formats.tiff.TiffField;
 import org.apache.commons.imaging.formats.tiff.TiffImageData;
 import org.apache.commons.imaging.formats.tiff.TiffReader;
@@ -135,8 +136,8 @@ public class TiffImageWriterLossless ext
                 if (tiffImageData != null) {
                     TiffElement.DataElement data[] = tiffImageData
                             .getImageData();
-                    for (int i = 0; i < data.length; i++) {
-                        elements.add(data[i]);
+                    for (DataElement element : data) {
+                        elements.add(element);
                     }
                 }
             }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java Tue Dec  4 15:11:16 2012
@@ -631,8 +631,8 @@ public final class TiffOutputDirectory e
         }
 
         if (null != imageDataInfo) {
-            for (int i = 0; i < imageDataInfo.outputItems.length; i++) {
-                result.add(imageDataInfo.outputItems[i]);
+            for (TiffOutputItem outputItem : imageDataInfo.outputItems) {
+                result.add(outputItem);
             }
 
             outputSummary.addTiffImageData(imageDataInfo);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java Tue Dec  4 15:11:16 2012
@@ -31,8 +31,8 @@ import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.UUID;
 
@@ -155,20 +155,18 @@ public class XbmImageParser extends Imag
             int height = -1;
             int xHot = -1;
             int yHot = -1;
-            for (Iterator<Map.Entry<String, String>> it = defines.entrySet()
-                    .iterator(); it.hasNext();) {
-                Map.Entry<String, String> entry = it.next();
-                String name = entry.getKey();
-                if (name.endsWith("_width")) {
-                    width = Integer.parseInt(entry.getValue());
-                } else if (name.endsWith("_height")) {
-                    height = Integer.parseInt(entry.getValue());
-                } else if (name.endsWith("_x_hot")) {
-                    xHot = Integer.parseInt(entry.getValue());
-                } else if (name.endsWith("_y_hot")) {
-                    yHot = Integer.parseInt(entry.getValue());
-                }
+            for (Entry<String, String> entry : defines.entrySet()) {
+            String name = entry.getKey();
+            if (name.endsWith("_width")) {
+            width = Integer.parseInt(entry.getValue());
+            } else if (name.endsWith("_height")) {
+            height = Integer.parseInt(entry.getValue());
+            } else if (name.endsWith("_x_hot")) {
+            xHot = Integer.parseInt(entry.getValue());
+            } else if (name.endsWith("_y_hot")) {
+            yHot = Integer.parseInt(entry.getValue());
             }
+         }
             if (width == -1) {
                 throw new ImageReadException("width not found");
             }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java Tue Dec  4 15:11:16 2012
@@ -34,8 +34,8 @@ import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.UUID;
 
@@ -143,20 +143,19 @@ public class XpmImageParser extends Imag
         XpmHeader xpmHeader = readXpmHeader(byteSource);
         boolean isTransparent = false;
         int colorType = ImageInfo.COLOR_TYPE_BW;
-        for (Iterator<Map.Entry<Object, PaletteEntry>> it = xpmHeader.palette
-                .entrySet().iterator(); it.hasNext();) {
-            Map.Entry<Object, PaletteEntry> entry = it.next();
-            PaletteEntry paletteEntry = entry.getValue();
-            if ((paletteEntry.getBestARGB() & 0xff000000) != 0xff000000) {
-                isTransparent = true;
-            }
-            if (paletteEntry.haveColor) {
-                colorType = ImageInfo.COLOR_TYPE_RGB;
-            } else if (colorType != ImageInfo.COLOR_TYPE_RGB
-                    && (paletteEntry.haveGray || paletteEntry.haveGray4Level)) {
-                colorType = ImageInfo.COLOR_TYPE_GRAYSCALE;
-            }
-        }
+        for (Entry<Object, PaletteEntry> entry : xpmHeader.palette
+                .entrySet()) {
+         PaletteEntry paletteEntry = entry.getValue();
+         if ((paletteEntry.getBestARGB() & 0xff000000) != 0xff000000) {
+        isTransparent = true;
+         }
+         if (paletteEntry.haveColor) {
+        colorType = ImageInfo.COLOR_TYPE_RGB;
+         } else if (colorType != ImageInfo.COLOR_TYPE_RGB
+            && (paletteEntry.haveGray || paletteEntry.haveGray4Level)) {
+        colorType = ImageInfo.COLOR_TYPE_GRAYSCALE;
+         }
+      }
         return new ImageInfo("XPM version 3", xpmHeader.numCharsPerPixel * 8,
                 new ArrayList<String>(), ImageFormat.IMAGE_FORMAT_XPM,
                 "X PixMap", xpmHeader.height, "image/x-xpixmap", 1, 0, 0, 0, 0,
@@ -525,12 +524,11 @@ public class XpmImageParser extends Imag
         int bpp;
         if (xpmHeader.palette.size() <= (1 << 8)) {
             int[] palette = new int[xpmHeader.palette.size()];
-            for (Iterator<Map.Entry<Object, PaletteEntry>> it = xpmHeader.palette
-                    .entrySet().iterator(); it.hasNext();) {
-                Map.Entry<Object, PaletteEntry> entry = it.next();
-                PaletteEntry paletteEntry = entry.getValue();
-                palette[paletteEntry.index] = paletteEntry.getBestARGB();
-            }
+            for (Entry<Object, PaletteEntry> entry : xpmHeader.palette
+                    .entrySet()) {
+            PaletteEntry paletteEntry = entry.getValue();
+            palette[paletteEntry.index] = paletteEntry.getBestARGB();
+         }
             colorModel = new IndexColorModel(8, xpmHeader.palette.size(),
                     palette, 0, true, -1, DataBuffer.TYPE_BYTE);
             raster = WritableRaster.createInterleavedRaster(
@@ -539,12 +537,11 @@ public class XpmImageParser extends Imag
             bpp = 8;
         } else if (xpmHeader.palette.size() <= (1 << 16)) {
             int[] palette = new int[xpmHeader.palette.size()];
-            for (Iterator<Map.Entry<Object, PaletteEntry>> it = xpmHeader.palette
-                    .entrySet().iterator(); it.hasNext();) {
-                Map.Entry<Object, PaletteEntry> entry = it.next();
-                PaletteEntry paletteEntry = entry.getValue();
-                palette[paletteEntry.index] = paletteEntry.getBestARGB();
-            }
+            for (Entry<Object, PaletteEntry> entry : xpmHeader.palette
+                    .entrySet()) {
+            PaletteEntry paletteEntry = entry.getValue();
+            palette[paletteEntry.index] = paletteEntry.getBestARGB();
+         }
             colorModel = new IndexColorModel(16, xpmHeader.palette.size(),
                     palette, 0, true, -1, DataBuffer.TYPE_USHORT);
             raster = WritableRaster.createInterleavedRaster(

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java Tue Dec  4 15:11:16 2012
@@ -76,8 +76,7 @@ public class IccProfileParser extends Bi
             is.close();
             is = null;
 
-            for (int i = 0; i < result.tags.length; i++) {
-                IccTag tag = result.tags[i];
+            for (IccTag tag : result.tags) {
                 byte bytes[] = byteSource.getBlock(tag.offset, tag.length);
                 // Debug.debug("bytes: " + bytes.length);
                 tag.setData(bytes);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java Tue Dec  4 15:11:16 2012
@@ -60,8 +60,8 @@ public class PaletteFactory {
         }
 
         int count = 0;
-        for (int i = 0; i < rgbmap.length; i++) {
-            int eight = 0xff & rgbmap[i];
+        for (byte element : rgbmap) {
+            int eight = 0xff & element;
             count += Integer.bitCount(eight);
         }
 
@@ -498,8 +498,7 @@ public class PaletteFactory {
     public int countTrasparentColors(int rgbs[]) {
         int first = -1;
 
-        for (int i = 0; i < rgbs.length; i++) {
-            int rgb = rgbs[i];
+        for (int rgb : rgbs) {
             int alpha = 0xff & (rgb >> 24);
             if (alpha < 0xff) {
                 if (first < 0) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/Debug.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/Debug.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/Debug.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/Debug.java Tue Dec  4 15:11:16 2012
@@ -82,8 +82,8 @@ public final class Debug {
             result.append(message + " (" + null + ")" + newline);
         } else {
             result.append(message + " (" + v.length + ")" + newline);
-            for (int i = 0; i < v.length; i++) {
-                result.append("\t" + v[i] + newline);
+            for (int element : v) {
+                result.append("\t" + element + newline);
             }
             result.append(newline);
         }
@@ -132,8 +132,8 @@ public final class Debug {
             result.append(getDebug(message + " (" + null + ")") + newline);
         } else {
             result.append(getDebug(message + " (" + v.length + ")") + newline);
-            for (int i = 0; i < v.length; i++) {
-                result.append(getDebug("\t" + v[i] + " (" + (0xff & v[i]))
+            for (char element : v) {
+                result.append(getDebug("\t" + element + " (" + (0xff & element))
                         + ")" + newline);
             }
             result.append(newline);

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/color/ColorConversionsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/color/ColorConversionsTest.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/color/ColorConversionsTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/color/ColorConversionsTest.java Tue Dec  4 15:11:16 2012
@@ -26,9 +26,7 @@ public class ColorConversionsTest extend
             0xff00ffff, 0x00000000, 0xff7f7f7f, };
 
     public void testRGBtoCMYK() throws Exception {
-        for (int i = 0; i < SAMPLE_RGBS.length; i++) {
-            int rgb = SAMPLE_RGBS[i];
-
+        for (int rgb : SAMPLE_RGBS) {
             ColorCmy cmy = ColorConversions.convertRGBtoCMY(rgb);
             ColorCmyk cmyk = ColorConversions.convertCMYtoCMYK(cmy);
             ColorCmy cmyk_cmy = ColorConversions.convertCMYKtoCMY(cmyk);
@@ -46,9 +44,7 @@ public class ColorConversionsTest extend
     }
 
     public void testRGBtoHSL() throws Exception {
-        for (int i = 0; i < SAMPLE_RGBS.length; i++) {
-            int rgb = SAMPLE_RGBS[i];
-
+        for (int rgb : SAMPLE_RGBS) {
             ColorHsl hsl = ColorConversions.convertRGBtoHSL(rgb);
             int hsl_rgb = ColorConversions.convertHSLtoRGB(hsl);
 
@@ -61,9 +57,7 @@ public class ColorConversionsTest extend
     }
 
     public void testRGBtoHSV() throws Exception {
-        for (int i = 0; i < SAMPLE_RGBS.length; i++) {
-            int rgb = SAMPLE_RGBS[i];
-
+        for (int rgb : SAMPLE_RGBS) {
             ColorHsv hsv = ColorConversions.convertRGBtoHSV(rgb);
             int hsv_rgb = ColorConversions.convertHSVtoRGB(hsv);
 
@@ -76,9 +70,7 @@ public class ColorConversionsTest extend
     }
 
     public void testXYZ() throws Exception {
-        for (int i = 0; i < SAMPLE_RGBS.length; i++) {
-            int rgb = SAMPLE_RGBS[i];
-
+        for (int rgb : SAMPLE_RGBS) {
             ColorXyz xyz = ColorConversions.convertRGBtoXYZ(rgb);
             int xyz_rgb = ColorConversions.convertXYZtoRGB(xyz);
 

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java Tue Dec  4 15:11:16 2012
@@ -105,8 +105,7 @@ public class RationalNumberTest extends 
                 -(Long.MAX_VALUE - 0.1), //
         };
 
-        for (int i = 0; i < testValues.length; i++) {
-            double value = testValues[i];
+        for (double value : testValues) {
             RationalNumber rational = RationalNumberUtilities
                     .getRationalNumber(value);
             double difference = Math.abs(value - rational.doubleValue());

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java Tue Dec  4 15:11:16 2012
@@ -140,12 +140,8 @@ public class ByteSourceDataTest extends 
 
         byte testByteArrays[][] = getTestByteArrays();
 
-        for (int i = 0; i < testByteArrays.length; i++) {
-            byte testByteArray[] = testByteArrays[i];
-
-            for (int j = 0; j < byteSourceFactories.length; j++) {
-                ByteSourceFactory byteSourceFactory = byteSourceFactories[j];
-
+        for (byte[] testByteArray : testByteArrays) {
+            for (ByteSourceFactory byteSourceFactory : byteSourceFactories) {
                 writeAndReadBytes(byteSourceFactory, testByteArray);
             }
         }

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java Tue Dec  4 15:11:16 2012
@@ -166,8 +166,8 @@ public class ByteSourceImageTest extends
         assertNotNull(imageInfoBytes);
 
         Method methods[] = ImageInfo.class.getMethods();
-        for (int i = 0; i < methods.length; i++) {
-            Method method = methods[i];
+        for (Method method2 : methods) {
+            Method method = method2;
             method.getModifiers();
             if (!Modifier.isPublic(method.getModifiers()))
                 continue;

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java Tue Dec  4 15:11:16 2012
@@ -401,8 +401,8 @@ public class ExifRewriteTest extends Exi
                     // so if the source had that, all bets are off.
                     byte[] rawBytes = oldField.fieldType.getRawBytes(oldField);
                     boolean hasInvalidByte = false;
-                    for (int k = 0; k < rawBytes.length; k++) {
-                        if ((rawBytes[k] & 0x80) != 0) {
+                    for (byte rawByte : rawBytes) {
+                        if ((rawByte & 0x80) != 0) {
                             hasInvalidByte = true;
                             break;
                         }

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/png/PngMultipleRoundtripTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/png/PngMultipleRoundtripTest.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/png/PngMultipleRoundtripTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/png/PngMultipleRoundtripTest.java Tue Dec  4 15:11:16 2012
@@ -36,8 +36,8 @@ public class PngMultipleRoundtripTest ex
         assertTrue(imagesFolder.exists() && imagesFolder.isDirectory());
 
         File files[] = imagesFolder.listFiles();
-        for (int i = 0; i < files.length; i++) {
-            File imageFile = files[i];
+        for (File file : files) {
+            File imageFile = file;
             if (!imageFile.isFile())
                 continue;
             if (!imageFile.getName().toLowerCase().endsWith(".png"))

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/png/PngWriteReadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/png/PngWriteReadTest.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/png/PngWriteReadTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/png/PngWriteReadTest.java Tue Dec  4 15:11:16 2012
@@ -82,8 +82,7 @@ public class PngWriteReadTest extends Im
                 smallRedPixels, singleRedPixel, smallAscendingPixels,
                 smallRandomPixels, };
 
-        for (int i = 0; i < testData.length; i++) {
-            int rawData[][] = testData[i];
+        for (int[][] rawData : testData) {
             writeAndReadImageData(rawData);
         }
     }

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java?rev=1416981&r1=1416980&r2=1416981&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java (original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java Tue Dec  4 15:11:16 2012
@@ -276,11 +276,9 @@ public class RoundtripTest extends Imagi
                 createBitmapBitmapImage(300, 300), // larger than 256
         };
 
-        for (int j = 0; j < testImages.length; j++) {
-            BufferedImage testImage = testImages[j];
-
-            for (int i = 0; i < FORMAT_INFOS.length; i++) {
-                FormatInfo formatInfo = FORMAT_INFOS[i];
+        for (BufferedImage testImage : testImages) {
+            for (FormatInfo element : FORMAT_INFOS) {
+                FormatInfo formatInfo = element;
                 if ((!formatInfo.canRead) || (!formatInfo.canWrite))
                     continue;
 
@@ -305,11 +303,9 @@ public class RoundtripTest extends Imagi
                 createGrayscaleGrayscaleImage(300, 300), // larger than 256
         };
 
-        for (int j = 0; j < testImages.length; j++) {
-            BufferedImage testImage = testImages[j];
-
-            for (int i = 0; i < FORMAT_INFOS.length; i++) {
-                FormatInfo formatInfo = FORMAT_INFOS[i];
+        for (BufferedImage testImage : testImages) {
+            for (FormatInfo element : FORMAT_INFOS) {
+                FormatInfo formatInfo = element;
                 if ((!formatInfo.canRead) || (!formatInfo.canWrite))
                     continue;
 
@@ -333,11 +329,9 @@ public class RoundtripTest extends Imagi
                 createLimitedColorImage(300, 300), // larger than 256
         };
 
-        for (int j = 0; j < testImages.length; j++) {
-            BufferedImage testImage = testImages[j];
-
-            for (int i = 0; i < FORMAT_INFOS.length; i++) {
-                FormatInfo formatInfo = FORMAT_INFOS[i];
+        for (BufferedImage testImage : testImages) {
+            for (FormatInfo element : FORMAT_INFOS) {
+                FormatInfo formatInfo = element;
                 if ((!formatInfo.canRead) || (!formatInfo.canWrite))
                     continue;
 
@@ -363,11 +357,9 @@ public class RoundtripTest extends Imagi
                 createFullColorImage(300, 300), // larger than 256
         };
 
-        for (int j = 0; j < testImages.length; j++) {
-            BufferedImage testImage = testImages[j];
-
-            for (int i = 0; i < FORMAT_INFOS.length; i++) {
-                FormatInfo formatInfo = FORMAT_INFOS[i];
+        for (BufferedImage testImage : testImages) {
+            for (FormatInfo element : FORMAT_INFOS) {
+                FormatInfo formatInfo = element;
                 if ((!formatInfo.canRead) || (!formatInfo.canWrite))
                     continue;
 



Mime
View raw message