]> source.dussan.org Git - poi.git/commitdiff
Eclipse automated refactor/cleanup: convert for loops to for-each loops
authorJaven O'Neal <onealj@apache.org>
Wed, 19 Oct 2016 22:28:07 +0000 (22:28 +0000)
committerJaven O'Neal <onealj@apache.org>
Wed, 19 Oct 2016 22:28:07 +0000 (22:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1765728 13f79535-47bb-0310-9956-ffa450edef68

34 files changed:
src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java
src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFEventBasedExcelExtractor.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java
src/testcases/org/apache/poi/hpsf/basic/AllDataFilesTester.java
src/testcases/org/apache/poi/hpsf/basic/TestReadAllFiles.java
src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
src/testcases/org/apache/poi/hpsf/basic/TestWriteWellKnown.java
src/testcases/org/apache/poi/hpsf/basic/Util.java
src/testcases/org/apache/poi/hssf/eventusermodel/TestEventWorkbookBuilder.java
src/testcases/org/apache/poi/hssf/eventusermodel/TestFormatTrackingHSSFListener.java
src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java
src/testcases/org/apache/poi/hssf/eventusermodel/TestMissingRecordAwareHSSFListener.java
src/testcases/org/apache/poi/hssf/model/TestSheet.java
src/testcases/org/apache/poi/hssf/record/TestRecordFactory.java
src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java
src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java
src/testcases/org/apache/poi/hssf/usermodel/SanityChecker.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
src/testcases/org/apache/poi/hssf/util/TestAreaReference.java
src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java
src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java
src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java
src/testcases/org/apache/poi/poifs/storage/TestBATBlock.java
src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableWriter.java
src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java
src/testcases/org/apache/poi/ss/formula/TestEvaluationCache.java
src/testcases/org/apache/poi/ss/formula/function/ExcelFileFormatDocFunctionExtractor.java
src/testcases/org/apache/poi/ss/formula/ptg/TestAreaPtg.java
src/testcases/org/apache/poi/ss/util/NumberComparingSpreadsheetGenerator.java
src/testcases/org/apache/poi/ss/util/NumberRenderingSpreadsheetGenerator.java

index e807c69d9d853682f00c9452a9dde348fb0ebe1c..447684ca903540871ccbb0a4d1f9881f11d61170 100644 (file)
@@ -30,9 +30,9 @@ public class CombinedIteratorTest {
 
         Iterator<String> iter = iterable.iterator();
 
-        for (int i = 0; i < expected.length; i++) {
+        for (String element : expected) {
             Assert.assertEquals(true, iter.hasNext());
-            Assert.assertEquals(expected[i], iter.next());
+            Assert.assertEquals(element, iter.next());
         }
 
         Assert.assertEquals(false, iter.hasNext());
index 2be777d6f08bfd2cbc75e141656a62b4fcf566dc..b223804e92e10aef67246e93f022fa7aba432d41 100644 (file)
@@ -155,10 +155,8 @@ public class TestXSSFEventBasedExcelExtractor extends TestCase {
                
                POITextExtractor[] extractors =
                        new POITextExtractor[] { ooxmlExtractor, ole2Extractor };
-               for (int i = 0; i < extractors.length; i++) {
-            POITextExtractor extractor = extractors[i];
-                       
-                       String text = extractor.getText().replaceAll("[\r\t]", "");
+               for (POITextExtractor extractor : extractors) {
+            String text = extractor.getText().replaceAll("[\r\t]", "");
                        assertTrue(text.startsWith("First Sheet\nTest spreadsheet\n2nd row2nd row 2nd column\n"));
                        Pattern pattern = Pattern.compile(".*13(\\.0+)?\\s+Sheet3.*", Pattern.DOTALL);
                        Matcher m = pattern.matcher(text);
index d9cbec5dd161d048015287fc1d409603a2b7183e..e0da16ba2980fafd3e3f78f2984f61bc77b47f5d 100644 (file)
@@ -190,8 +190,7 @@ public class TestXSSFDataValidation extends BaseTestDataValidation {
                                }
                        }
 
-                       for (int j = 0; j < doubleOperandOperatorTypes.length; j++) {
-                               int operatorType = doubleOperandOperatorTypes[j];
+                       for (int operatorType : doubleOperandOperatorTypes) {
                                final Row row1 = sheet.createRow(offset++);
                                
                                cell_10 = row1.createCell(0);
index 431526e56d40f755a67ea2a88bbc4077e0673bfc..0377b248a5e599247d5927a51fd06877d24be566 100644 (file)
@@ -69,14 +69,14 @@ public final class TestStreamBugs extends StreamTest {
 
                // Get without recursing
                Pointer[] ptrs = trailer.getChildPointers();
-               for(int i=0; i<ptrs.length; i++) {
-                       Stream.createStream(ptrs[i], contents, chunkFactory, ptrFactory);
+               for (Pointer ptr : ptrs) {
+                       Stream.createStream(ptr, contents, chunkFactory, ptrFactory);
                }
 
                // Get with recursing into chunks
-               for(int i=0; i<ptrs.length; i++) {
+               for (Pointer ptr : ptrs) {
                        Stream stream =
-                               Stream.createStream(ptrs[i], contents, chunkFactory, ptrFactory);
+                               Stream.createStream(ptr, contents, chunkFactory, ptrFactory);
                        if(stream instanceof ChunkStream) {
                                ChunkStream cStream = (ChunkStream)stream;
                                cStream.findChunks();
@@ -84,9 +84,9 @@ public final class TestStreamBugs extends StreamTest {
                }
 
                // Get with recursing into chunks and pointers
-               for(int i=0; i<ptrs.length; i++) {
+               for (Pointer ptr : ptrs) {
                        Stream stream =
-                               Stream.createStream(ptrs[i], contents, chunkFactory, ptrFactory);
+                               Stream.createStream(ptr, contents, chunkFactory, ptrFactory);
                        if(stream instanceof PointerContainingStream) {
                                PointerContainingStream pStream =
                                        (PointerContainingStream)stream;
index de5ee42b7cf8a3071e63f16934c79427459c3584..0ee7478d6a04fd55a44b37c7e4bae0abd05471d8 100644 (file)
@@ -117,8 +117,7 @@ public final class TestExHyperlink extends TestCase {
 
                // Within that, grab out the Hyperlink atoms
                List<ExHyperlink> linksA = new ArrayList<ExHyperlink>();
-               for(int i=0; i<exObjList._children.length; i++) {
-                       Record ch = exObjList._children[i];
+               for (Record ch : exObjList._children) {
                        if(ch instanceof ExHyperlink) {
                                linksA.add((ExHyperlink) ch);
                        }
index 2e2998c68b1473a022e9c500a8c5adddbd9649b4..75247a75bd698d1f25b2e86b846950baba6ead43 100644 (file)
@@ -75,8 +75,7 @@ public final class TestAddingSlides extends TestCase {
         //grab UserEditAtom
         UserEditAtom usredit = null;
         Record[] _records = hss_empty.getRecords();
-        for (int i = 0; i < _records.length; i++) {
-            Record record = _records[i];
+        for (Record record : _records) {
             if(record.getRecordType() == RecordTypes.UserEditAtom.typeID) {
                 usredit = (UserEditAtom)record;
             }
@@ -169,10 +168,9 @@ public final class TestAddingSlides extends TestCase {
         //grab UserEditAtom
         UserEditAtom usredit = null;
         Record[] _records = hss_two.getRecords();
-        for (int i = 0; i < _records.length; i++) {
-            Record record = _records[i];
-            if(_records[i].getRecordType() == RecordTypes.UserEditAtom.typeID) {
-                usredit = (UserEditAtom)_records[i];
+        for (Record record : _records) {
+            if(record.getRecordType() == RecordTypes.UserEditAtom.typeID) {
+                usredit = (UserEditAtom)record;
             }
        }
        assertNotNull(usredit);
index cbaa02ec7e926fd3ed001624449bd792e9795aff..6cb0a76869834d9bfbe057b6395a28ec1cc82438 100644 (file)
@@ -47,8 +47,8 @@ public final class TestRecordSetup {
        @Test
        public void testHandleParentAwareRecords() {
                Record[] records = hss.getRecords();
-               for(int i=0; i<records.length; i++) {
-                       ensureParentAware(records[i],null);
+               for (Record record : records) {
+                       ensureParentAware(record,null);
                }
        }
        private void ensureParentAware(Record r,RecordContainer parent) {
index 155664b37ac791d860b0b28fb782f022495beb92..a0db23085aa16b9399b6290cd5c43b9d99046d80 100644 (file)
@@ -62,9 +62,7 @@ public class AllDataFilesTester {
             {
                 return file.isFile() && file.getName().startsWith("Test");
             }});
-        for (int i = 0; i < docs.length; i++)
-        {
-            final File doc = docs[i];
+        for (final File doc : docs) {
             final Logger logger = Logger.getLogger(getClass().getName());
             logger.info("Processing file \" " + doc.toString() + "\".");
 
index d29cc803476beba5db589be71091f2858b51b920..b419ad1da623084aafa81256b675a4dd08fccd4d 100644 (file)
@@ -58,9 +58,7 @@ public class TestReadAllFiles extends TestCase {
                 }
             });
 
-        for (int i = 0; i < fileList.length; i++)
-        {
-            final File f = fileList[i];
+        for (final File f : fileList) {
             /* Read the POI filesystem's property set streams: */
             final POIFile[] psf1 = Util.readPropertySets(f);
 
index 7acede2fb76b28973859cf2e0c47442d10e6b587..1312cf8aa3a29e9a914df62fe666ce9251e11f26 100644 (file)
@@ -473,9 +473,7 @@ public class TestWrite
         Throwable thr = null;
         final int[] validCodepages = new int[]
             {CODEPAGE_DEFAULT, CODEPAGE_UTF8, CODEPAGE_UTF16, CODEPAGE_1252};
-        for (int i = 0; i < validCodepages.length; i++)
-        {
-            final int cp = validCodepages[i];
+        for (final int cp : validCodepages) {
             if (cp == -1 && !hasProperDefaultCharset())
             {
                 System.err.println(IMPROPER_DEFAULT_CHARSET_MESSAGE +
@@ -512,9 +510,7 @@ public class TestWrite
         }
 
         final int[] invalidCodepages = new int[] {0, 1, 2, 4711, 815};
-        for (int i = 0; i < invalidCodepages.length; i++)
-        {
-            int cp = invalidCodepages[i];
+        for (int cp : invalidCodepages) {
             final long type = cp == CODEPAGE_UTF16 ? Variant.VT_LPWSTR
                                                    : Variant.VT_LPSTR;
             try
index 6769861e46a7ed647b80c34110048a474979d5a4..b47417ec4cdcb193ee7e9a8b60729da8acb35122 100644 (file)
@@ -643,12 +643,11 @@ public class TestWriteWellKnown {
             }
         });
 
-        for (int i = 0; i < docs.length; i++)
-        {
+        for (File doc : docs) {
             try {
-                task.runTest(docs[i]);
+                task.runTest(doc);
             } catch (Exception e) {
-                throw new IOException("While handling file " + docs[i], e);
+                throw new IOException("While handling file " + doc, e);
             }
         }
     }
index 14f1977b1ed336367cd86046f84001e1c13e904b..299f69797a2df4d43ab95ef3404d1f4c114f14c2 100644 (file)
@@ -159,10 +159,8 @@ final class Util {
             /* Register the listener for all POI files. */
             r.registerListener(pfl);
         else
-            /* Register the listener for the specified POI files
-             * only. */
-            for (int i = 0; i < poiFiles.length; i++)
-                r.registerListener(pfl, poiFiles[i]);
+            for (String poiFile : poiFiles)
+                r.registerListener(pfl, poiFile);
 
         /* Read the POI filesystem. */
         FileInputStream stream = new FileInputStream(poiFs);
@@ -257,9 +255,7 @@ final class Util {
         for (Iterator<String> i = p.stringPropertyNames().iterator(); i.hasNext();)
             names.add(i.next());
         Collections.sort(names);
-        for (final Iterator<String> i = names.iterator(); i.hasNext();)
-        {
-            String name = i.next();
+        for (String name : names) {
             String value = p.getProperty(name);
             System.out.println(name + ": " + value);
         }
index 72268832e2cafec0dc504808c1879128b828493c..609640c6dd27f87909668ed6bea714fc1bece5b6 100644 (file)
@@ -104,8 +104,8 @@ public final class TestEventWorkbookBuilder extends TestCase {
         assertEquals("Sh3",    stubHSSF.getSheetName(2));
 
         // Check we can get the formula without breaking
-        for(int i=0; i<fRecs.length; i++) {
-            HSSFFormulaParser.toFormulaString(stubHSSF, fRecs[i].getParsedExpression());
+        for (FormulaRecord fRec : fRecs) {
+            HSSFFormulaParser.toFormulaString(stubHSSF, fRec.getParsedExpression());
         }
 
         // Peer into just one formula, and check that
index e9fa2a48bcbdbede16832a659942ce60e990af11..ec1e9d0c20a70e5cbf98f9658542374611f83436 100644 (file)
@@ -73,8 +73,8 @@ public final class TestFormatTrackingHSSFListener {
                String[] files = new String[] { 
                                "45365.xls", "45365-2.xls", "MissingBits.xls" 
                };
-               for(int k=0; k<files.length; k++) {
-                       processFile(files[k]);
+               for (String file : files) {
+                       processFile(file);
                        
                        // Check we found our formats
                        assertTrue(listener.getNumberOfCustomFormats() > 5);
index c87021b36d011ca20fcffe9d6e412f198abe1719..040b83cfb055db9ebfe1170f227d3ea83339ab5b 100644 (file)
@@ -91,8 +91,8 @@ public final class TestHSSFEventFactory extends TestCase {
         assertTrue( recs.length > 100 );
 
         // And none of them are continue ones
-        for(int i=0; i<recs.length; i++) {
-            assertFalse( recs[i] instanceof ContinueRecord );
+        for (Record rec : recs) {
+            assertFalse( rec instanceof ContinueRecord );
         }
 
         // Check that the last few records are as we expect
index 5ed44a0f4a035a0f3da96a2783155381b078f598..c57eee387d445baf6ab3994e87a0c90f6dda014e 100644 (file)
@@ -445,8 +445,7 @@ public final class TestMissingRecordAwareHSSFListener extends TestCase {
                int eorCount=0;
                int mbrCount=0;
                int brCount=0;
-               for (int i = 0; i < rr.length; i++) {
-                       Record record = rr[i];
+               for (Record record : rr) {
                        if (record instanceof MulBlankRecord) {
                                mbrCount++;
                        }
@@ -474,8 +473,7 @@ public final class TestMissingRecordAwareHSSFListener extends TestCase {
         Record[] rr = r;
         int missingCount=0;
         int lastCount=0;
-        for (int i = 0; i < rr.length; i++) {
-            Record record = rr[i];
+        for (Record record : rr) {
             if (record instanceof MissingCellDummyRecord) {
                 missingCount++;
             }
index 0e13039340ac156eb6a9613d950aed8ffcba561e..97b3fe0a6be2e912a2ad523bf5d5d6fdff5c4bd1 100644 (file)
@@ -297,8 +297,7 @@ public final class TestSheet {
                boolean is11 = false;
 
                int[] rowBreaks = sheet.getRowBreaks();
-               for (int i = 0; i < rowBreaks.length; i++) {
-                       int main = rowBreaks[i];
+               for (int main : rowBreaks) {
                        if (main != 0 && main != 10 && main != 11) fail("Invalid page break");
                        if (main == 0)   is0 = true;
                        if (main == 10) is10= true;
@@ -355,8 +354,7 @@ public final class TestSheet {
                boolean is15 = false;
 
                int[] colBreaks = sheet.getColumnBreaks();
-               for (int i = 0; i < colBreaks.length; i++) {
-                       int main = colBreaks[i];
+               for (int main : colBreaks) {
                        if (main != 0 && main != 1 && main != 10 && main != 15) fail("Invalid page break");
                        if (main == 0)  is0 = true;
                        if (main == 1)  is1 = true;
index c61c0497631b220c5572c1de0a44d93e23db2473..8be6684fe99432910badf67bd34afa1c79865098 100644 (file)
@@ -213,9 +213,9 @@ public final class TestRecordFactory extends TestCase {
                        EOFRecord.instance,
                };
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-               for (int i = 0; i < recs.length; i++) {
+               for (Record rec : recs) {
                        try {
-                               baos.write(recs[i].serialize());
+                               baos.write(rec.serialize());
                        } catch (IOException e) {
                                throw new RuntimeException(e);
                        }
index b61f9ed67dd281152ee94ca4e4b3d07cdd23e8f4..98f1e855c755772ba0a32f56fcafaaa936a4d688 100644 (file)
@@ -238,8 +238,7 @@ public final class TestSharedFormulaRecord extends TestCase {
     private static int countSharedFormulas(HSSFSheet sheet) {
         Record[] records = RecordInspector.getRecords(sheet, 0);
         int count = 0;
-        for (int i = 0; i < records.length; i++) {
-            Record rec = records[i];
+        for (Record rec : records) {
             if(rec instanceof SharedFormulaRecord) {
                 count++;
             }
index 9c4f8ab7bf5c26b34a4a0b73c2ca689ae31860d8..66f8e89e875ceedb785f714e029571c4e77f2859 100644 (file)
@@ -85,8 +85,8 @@ public final class TestSharedValueManager extends TestCase {
                } while (attempt++ < MAX_ATTEMPTS);
 
                int count=0;
-               for (int i = 0; i < records.length; i++) {
-                       if (records[i] instanceof SharedFormulaRecord) {
+               for (Record record : records) {
+                       if (record instanceof SharedFormulaRecord) {
                                count++;
                        }
                }
@@ -115,8 +115,8 @@ public final class TestSharedValueManager extends TestCase {
                } while (attempt++ < MAX_ATTEMPTS);
 
                int count=0;
-               for (int i = 0; i < records.length; i++) {
-                       if (records[i] instanceof SharedFormulaRecord) {
+               for (Record record : records) {
+                       if (record instanceof SharedFormulaRecord) {
                                count++;
                        }
                }
index c4cffb5fcc750e352a42d7cb927c6b9d2bb7549f..15588e81e8c27d217a16b13e66ad7f9f752fdd8e 100644 (file)
@@ -327,9 +327,8 @@ public class SanityChecker {
     void checkRecordOrder(List<? extends RecordBase> records, CheckRecord[] check)
     {
         int recordIdx = 0;
-        for ( int checkIdx = 0; checkIdx < check.length; checkIdx++ )
-        {
-            recordIdx = check[checkIdx].match(records, recordIdx);
+        for (CheckRecord element : check) {
+            recordIdx = element.match(records, recordIdx);
         }
     }
 
index 8e8a06d3c1499c784e7ca0d034b2eb3ea1f0b3b6..3cbd904988d0e0e7ae45abded4bd4025188aa8f4 100644 (file)
@@ -251,18 +251,18 @@ public class TestHSSFDateUtil {
     public void identifyDateFormats() {
         // First up, try with a few built in date formats
         short[] builtins = new short[] { 0x0e, 0x0f, 0x10, 0x16, 0x2d, 0x2e };
-        for(int i=0; i<builtins.length; i++) {
-            String formatStr = HSSFDataFormat.getBuiltinFormat(builtins[i]);
-            assertTrue( HSSFDateUtil.isInternalDateFormat(builtins[i]) );
-            assertTrue( HSSFDateUtil.isADateFormat(builtins[i],formatStr) );
+        for (short builtin : builtins) {
+            String formatStr = HSSFDataFormat.getBuiltinFormat(builtin);
+            assertTrue( HSSFDateUtil.isInternalDateFormat(builtin) );
+            assertTrue( HSSFDateUtil.isADateFormat(builtin,formatStr) );
         }
 
         // Now try a few built-in non date formats
         builtins = new short[] { 0x01, 0x02, 0x17, 0x1f, 0x30 };
-        for(int i=0; i<builtins.length; i++) {
-            String formatStr = HSSFDataFormat.getBuiltinFormat(builtins[i]);
-            assertFalse( HSSFDateUtil.isInternalDateFormat(builtins[i]) );
-            assertFalse( HSSFDateUtil.isADateFormat(builtins[i],formatStr) );
+        for (short builtin : builtins) {
+            String formatStr = HSSFDataFormat.getBuiltinFormat(builtin);
+            assertFalse( HSSFDateUtil.isInternalDateFormat(builtin) );
+            assertFalse( HSSFDateUtil.isADateFormat(builtin,formatStr) );
         }
 
         // Now for some non-internal ones
@@ -296,10 +296,10 @@ public class TestHSSFDateUtil {
                 "[BLACK]dddd/mm/yy",
                 "[yeLLow]yyyy-mm-dd"
         };
-        for(int i=0; i<formats.length; i++) {
+        for (String format : formats) {
             assertTrue(
-                    formats[i] + " is a date format",
-                    HSSFDateUtil.isADateFormat(formatId, formats[i])
+                    format + " is a date format",
+                    HSSFDateUtil.isADateFormat(formatId, format)
             );
         }
 
@@ -314,10 +314,10 @@ public class TestHSSFDateUtil {
                 //support elapsed time [h],[m],[s]
                 "[hh]", "[mm]", "[ss]", "[SS]", "[red][hh]"
         };
-        for(int i=0; i<formats.length; i++) {
+        for (String format : formats) {
             assertTrue(
-                    formats[i] + " is a datetime format",
-                    HSSFDateUtil.isADateFormat(formatId, formats[i])
+                    format + " is a datetime format",
+                    HSSFDateUtil.isADateFormat(formatId, format)
             );
         }
 
@@ -330,10 +330,10 @@ public class TestHSSFDateUtil {
                 "[ms]", "[Mh]",
                 "", null
         };
-        for(int i=0; i<formats.length; i++) {
+        for (String format : formats) {
             assertFalse(
-                    formats[i] + " is not a date or datetime format",
-                    HSSFDateUtil.isADateFormat(formatId, formats[i])
+                    format + " is not a date or datetime format",
+                    HSSFDateUtil.isADateFormat(formatId, format)
             );
         }
 
@@ -342,7 +342,7 @@ public class TestHSSFDateUtil {
         formats = new String[] {
                 "yyyy:mm:dd",
         };
-        for(int i=0; i<formats.length; i++) {
+        for (String format : formats) {
         //    assertFalse( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
         }
     }
index 1369bee0d21298630e565fd853a4f3dcb0488bb7..4bc3d07412f103e7ffec5cb77dc9a70e8d16b47e 100644 (file)
@@ -235,8 +235,7 @@ public final class TestAreaReference extends TestCase {
         assertEquals(refA, arefs[0].formatAsString());
         assertEquals(refB, arefs[1].formatAsString());
 
-        for(int i=0; i<arefs.length; i++) {
-            AreaReference ar = arefs[i];
+        for (AreaReference ar : arefs) {
             confirmResolveCellRef(wb, ar.getFirstCell());
             confirmResolveCellRef(wb, ar.getLastCell());
         }
index a0a703e0cc48355a45dc92e7f89e9f05efc3b06c..ac9a4f5bf51d2f9a106aaaf65e100b1cac6c73c4 100644 (file)
@@ -59,12 +59,10 @@ public final class TestPOIFSReaderRegistry extends TestCase {
     public void testEmptyRegistry() {
         POIFSReaderRegistry registry = new POIFSReaderRegistry();
 
-        for (int j = 0; j < paths.length; j++)
-        {
-            for (int k = 0; k < names.length; k++)
-            {
+        for (POIFSDocumentPath path : paths) {
+            for (String name : names) {
                 Iterator<POIFSReaderListener> listeners =
-                    registry.getListeners(paths[ j ], names[ k ]);
+                    registry.getListeners(path, name);
 
                 assertTrue(!listeners.hasNext());
             }
@@ -129,16 +127,13 @@ public final class TestPOIFSReaderRegistry extends TestCase {
                 }
             }
         }
-        for (int j = 0; j < listeners.length; j++)
-        {
-            registry.registerListener(listeners[ j ]);
+        for (POIFSReaderListener listener : listeners) {
+            registry.registerListener(listener);
         }
-        for (int k = 0; k < paths.length; k++)
-        {
-            for (int n = 0; n < names.length; n++)
-            {
+        for (POIFSDocumentPath path : paths) {
+            for (String name : names) {
                 Iterator<POIFSReaderListener> listeners =
-                    registry.getListeners(paths[ k ], names[ n ]);
+                    registry.getListeners(path, name);
                 Set<POIFSReaderListener> registeredListeners =
                     new HashSet<POIFSReaderListener>();
 
@@ -148,10 +143,9 @@ public final class TestPOIFSReaderRegistry extends TestCase {
                 }
                 assertEquals(this.listeners.length,
                              registeredListeners.size());
-                for (int j = 0; j < this.listeners.length; j++)
-                {
+                for (POIFSReaderListener listener : this.listeners) {
                     assertTrue(registeredListeners
-                        .contains(this.listeners[ j ]));
+                        .contains(listener));
                 }
             }
         }
index 779218f5bdd25f9a853d081e9e954474d153b027..1afd67c35f8cc17fcd144cb279d56df6fc25267b 100644 (file)
@@ -142,10 +142,10 @@ public final class TestPOIFSFileSystem extends TestCase {
                        "ShortLastBlock.qwp", "ShortLastBlock.wps"
                };
 
-               for(int i=0; i<files.length; i++) {
+               for (String file : files) {
                        // Open the file up
                        OPOIFSFileSystem fs = new OPOIFSFileSystem(
-                           _samples.openResourceAsStream(files[i])
+                           _samples.openResourceAsStream(file)
                        );
 
                        // Write it into a temp output array
index dca549c8884a25fe5aa6dd449b274459e6b44701..487c8eb804262d14bafdc34d35ae03bb25bdcf72 100644 (file)
@@ -34,8 +34,8 @@ public final class RawDataUtil {
        public static byte[] decode(String[] hexDataLines) {
                ByteArrayOutputStream baos = new ByteArrayOutputStream(hexDataLines.length * 32 + 32);
 
-               for (int i = 0; i < hexDataLines.length; i++) {
-                       byte[] lineData = HexRead.readFromString(hexDataLines[i]);
+               for (String hexDataLine : hexDataLines) {
+                       byte[] lineData = HexRead.readFromString(hexDataLine);
                        baos.write(lineData, 0, lineData.length);
                }
                return baos.toByteArray();
@@ -73,8 +73,8 @@ public final class RawDataUtil {
        public static void confirmEqual(byte[] expected, String[] hexDataLines) {
                ByteArrayOutputStream baos = new ByteArrayOutputStream(hexDataLines.length * 32 + 32);
 
-               for (int i = 0; i < hexDataLines.length; i++) {
-                       byte[] lineData = HexRead.readFromString(hexDataLines[i]);
+               for (String hexDataLine : hexDataLines) {
+                       byte[] lineData = HexRead.readFromString(hexDataLine);
                        baos.write(lineData, 0, lineData.length);
                }
                if (!Arrays.equals(expected, baos.toByteArray())) {
index 11c7070e9347d70da53ecc11ad01261a57aed14d..5ee530926427a5998d849f106124087afed2462d 100644 (file)
@@ -96,9 +96,8 @@ public final class TestBATBlock extends TestCase {
         ByteArrayOutputStream stream = new ByteArrayOutputStream(512
                                            * blocks.length);
 
-        for (int j = 0; j < blocks.length; j++)
-        {
-            blocks[ j ].writeBlocks(stream);
+        for (BATBlock block : blocks) {
+            block.writeBlocks(stream);
         }
         byte[] actual = stream.toByteArray();
 
@@ -178,9 +177,8 @@ public final class TestBATBlock extends TestCase {
         ByteArrayOutputStream stream = new ByteArrayOutputStream(512
                                            * blocks.length);
 
-        for (int j = 0; j < blocks.length; j++)
-        {
-            blocks[ j ].writeBlocks(stream);
+        for (BATBlock block : blocks) {
+            block.writeBlocks(stream);
         }
         byte[] actual = stream.toByteArray();
 
index 4539c60b3ca249b8a64b047bcfadae182fe51c3f..023dc6f19381c18184e12d2aa941eb94ada746d5 100644 (file)
@@ -43,10 +43,9 @@ public final class TestBlockAllocationTableWriter extends TestCase {
         };
         int                        expectedIndex = 0;
 
-        for (int j = 0; j < blockSizes.length; j++)
-        {
-            assertEquals(expectedIndex, table.allocateSpace(blockSizes[ j ]));
-            expectedIndex += blockSizes[ j ];
+        for (int blockSize : blockSizes) {
+            assertEquals(expectedIndex, table.allocateSpace(blockSize));
+            expectedIndex += blockSize;
         }
     }
 
index 31c4546a426a4df4cb33170f06cb2629be215b6e..a2ff6ceb1f2066b5d1508baa6c610edd25342968 100644 (file)
@@ -72,9 +72,8 @@ public final class TestSmallDocumentBlock extends TestCase {
                      (_testdata_size + 63) / 64, results.length);
         ByteArrayOutputStream output = new ByteArrayOutputStream();
 
-        for (int j = 0; j < results.length; j++)
-        {
-            results[ j ].writeBlocks(output);
+        for (SmallDocumentBlock result : results) {
+            result.writeBlocks(output);
         }
         byte[] output_array = output.toByteArray();
 
@@ -114,9 +113,8 @@ public final class TestSmallDocumentBlock extends TestCase {
             assertEquals(5, blocks.length);
             ByteArrayOutputStream stream = new ByteArrayOutputStream();
 
-            for (int k = 0; k < blocks.length; k++)
-            {
-                blocks[ k ].writeBlocks(stream);
+            for (SmallDocumentBlock block : blocks) {
+                block.writeBlocks(stream);
             }
             stream.close();
             byte[] output = stream.toByteArray();
index 6d87012b2ca391bee5ab29731f1476d140780c11..1abc92b0641271b03599d97bb73582addbf0a94b 100644 (file)
@@ -701,8 +701,8 @@ public class TestEvaluationCache extends TestCase {
        }
 
        private static void debugPrint(PrintStream ps, String[] log) {
-               for (int i = 0; i < log.length; i++) {
-                       ps.println('"' + log[i] + "\",");
+               for (String element : log) {
+                       ps.println('"' + element + "\",");
                }
        }
 
index aada5e72403a6d0cbfb07513459b6f38996e3ceb..2dab84ca7ea0d42f0906b90b00f1697b04209ff4 100644 (file)
@@ -219,8 +219,8 @@ public final class ExcelFileFormatDocFunctionExtractor {
                        Arrays.sort(keys);
 
                        _ps.println("# " + headingText);
-                       for (int i = 0; i < keys.length; i++) {
-                               FunctionData fd = _allFunctionsByIndex.get(keys[i]);
+                       for (Integer key : keys) {
+                               FunctionData fd = _allFunctionsByIndex.get(key);
                                _ps.println(fd.formatAsDataLine());
                        }
                }
@@ -554,9 +554,9 @@ public final class ExcelFileFormatDocFunctionExtractor {
                        "See the License for the specific language governing permissions and",
                        "limitations under the License.",
                };
-               for (int i = 0; i < lines.length; i++) {
+               for (String line : lines) {
                        ps.print("# ");
-                       ps.println(lines[i]);
+                       ps.println(line);
                }
                ps.println();
        }
index 8cf4d6aafda84ec081e9f98601c6e1b2fb98b75e..559dd8c72c248a08351354960fd4e842771ea408 100644 (file)
@@ -129,9 +129,7 @@ public final class TestAreaPtg extends TestCase {
                int letUsShiftColumn1By1Column=1;
                HSSFWorkbook wb = null;
                Ptg[] ptgs = HSSFFormulaParser.parse(formula, wb);
-               for(int i=0; i<ptgs.length; i++)
-               {
-                       Ptg ptg = ptgs[i];
+               for (Ptg ptg : ptgs) {
                        if (ptg instanceof AreaPtg )
                        {
                                AreaPtg aptg = (AreaPtg)ptg;
index d4f1ebb92fd997002411032a6662db0fb385fd19..01bca57255ad696599c845395f32507e0541e691 100644 (file)
@@ -133,8 +133,7 @@ public class NumberComparingSpreadsheetGenerator {
                HSSFWorkbook wb = new HSSFWorkbook();
                SheetWriter sw = new SheetWriter(wb);
                ComparisonExample[] ces = NumberComparisonExamples.getComparisonExamples();
-               for (int i = 0; i < ces.length; i++) {
-                       ComparisonExample ce = ces[i];
+               for (ComparisonExample ce : ces) {
                        sw.addTestRow(ce.getA(), ce.getB(), ce.getExpectedResult());
                }
 
index 7eda4727927ab6c5617439338361ce036040706d..0961134e6283f00426a5463c445f8d909995cce8 100644 (file)
@@ -148,8 +148,7 @@ public class NumberRenderingSpreadsheetGenerator {
                SheetWriter sw = new SheetWriter(wb);
                
                ExampleConversion[] exampleValues = NumberToTextConversionExamples.getExampleConversions();
-               for (int i = 0; i < exampleValues.length; i++) {
-                       ExampleConversion example = exampleValues[i];
+               for (ExampleConversion example : exampleValues) {
                        sw.addTestRow(example.getRawDoubleBits(), example.getExcelRendering());
                }
                
@@ -178,8 +177,7 @@ public class NumberRenderingSpreadsheetGenerator {
        public static void writeJavaDoc() {
                
                ExampleConversion[] exampleConversions = NumberToTextConversionExamples.getExampleConversions();
-               for (int i = 0; i < exampleConversions.length; i++) {
-                       ExampleConversion ec = exampleConversions[i];
+               for (ExampleConversion ec : exampleConversions) {
                        String line =   " * <tr><td>" 
                                + formatLongAsHex(ec.getRawDoubleBits())
                                + "</td><td>" + Double.toString(ec.getDoubleValue())