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