From: Simon Steiner Date: Fri, 4 Aug 2017 14:15:05 +0000 (+0000) Subject: Use foreach and cleanup X-Git-Tag: fop-2_3~44 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d6665a21c12d61573f0055e30bda56ffd90f6a6e;p=xmlgraphics-fop.git Use foreach and cleanup git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1804125 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java index 6c939acae..00c8cf1bf 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java @@ -3644,7 +3644,7 @@ public final class OTFAdvancedTypographicTableReader { GlyphMappingTable mapping = (GlyphMappingTable) stp[6]; List entries = (List) stp[7]; if (tt == GlyphTable.GLYPH_TABLE_TYPE_DEFINITION) { - int type = GDEFLookupType.getSubtableType(lt.intValue()); + int type = GDEFLookupType.getSubtableType(lt); String lid = "lu" + ln; int sequence = sn; int flags = lf; @@ -3680,7 +3680,7 @@ public final class OTFAdvancedTypographicTableReader { GlyphCoverageTable coverage = (GlyphCoverageTable) stp[6]; List entries = (List) stp[7]; if (tt == GlyphTable.GLYPH_TABLE_TYPE_SUBSTITUTION) { - int type = GSUBLookupType.getSubtableType(lt.intValue()); + int type = GSUBLookupType.getSubtableType(lt); String lid = "lu" + ln; int sequence = sn; int flags = lf; @@ -3716,7 +3716,7 @@ public final class OTFAdvancedTypographicTableReader { GlyphCoverageTable coverage = (GlyphCoverageTable) stp[6]; List entries = (List) stp[7]; if (tt == GlyphTable.GLYPH_TABLE_TYPE_POSITIONING) { - int type = GSUBLookupType.getSubtableType(lt.intValue()); + int type = GSUBLookupType.getSubtableType(lt); String lid = "lu" + ln; int sequence = sn; int flags = lf; diff --git a/fop-core/src/main/java/org/apache/fop/fo/properties/NumberProperty.java b/fop-core/src/main/java/org/apache/fop/fo/properties/NumberProperty.java index 7f54fbc8f..d99405a76 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/properties/NumberProperty.java +++ b/fop-core/src/main/java/org/apache/fop/fo/properties/NumberProperty.java @@ -145,7 +145,7 @@ public final class NumberProperty extends Property implements Numeric { * @return the canonical NumberProperty */ public static NumberProperty getInstance(Double num) { - return CACHE.fetch(new NumberProperty(num.doubleValue())); + return CACHE.fetch(new NumberProperty(num)); } /** @@ -155,7 +155,7 @@ public final class NumberProperty extends Property implements Numeric { * @return the canonical NumberProperty */ public static NumberProperty getInstance(Integer num) { - return CACHE.fetch(new NumberProperty(num.intValue())); + return CACHE.fetch(new NumberProperty(num)); } /** diff --git a/fop-core/src/main/java/org/apache/fop/fonts/SingleByteFont.java b/fop-core/src/main/java/org/apache/fop/fonts/SingleByteFont.java index 262ea0a75..53d3cd4fc 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/SingleByteFont.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/SingleByteFont.java @@ -363,7 +363,7 @@ public class SingleByteFont extends CustomFont { if (this.unencodedCharacters != null) { Set sortedKeys = new TreeSet(this.unencodedCharacters.keySet()); for (Character ch : sortedKeys) { - char mapped = mapChar(ch.charValue()); + char mapped = mapChar(ch); assert mapped != Typeface.NOT_FOUND; } } diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFPattern.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFPattern.java index ebc21b811..0ccc4265f 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFPattern.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFPattern.java @@ -249,7 +249,7 @@ public class PDFPattern extends PDFPathPaint { p.append("/Matrix [ "); for (tempInt = 0; tempInt < vectorSize; tempInt++) { p.append(PDFNumber.doubleOut( - ((Double)this.matrix.get(tempInt)).doubleValue(), 8)); + (Double) this.matrix.get(tempInt), 8)); p.append(" "); } p.append("] \n"); @@ -304,7 +304,7 @@ public class PDFPattern extends PDFPathPaint { p.append("/Matrix [ "); for (tempInt = 0; tempInt < vectorSize; tempInt++) { p.append(PDFNumber.doubleOut( - ((Double)this.matrix.get(tempInt)).doubleValue(), 8)); + (Double) this.matrix.get(tempInt), 8)); p.append(" "); } p.append("] \n"); diff --git a/fop-core/src/main/java/org/apache/fop/util/text/GlyphNameFieldPart.java b/fop-core/src/main/java/org/apache/fop/util/text/GlyphNameFieldPart.java index f0e5bcc32..48346c13a 100644 --- a/fop-core/src/main/java/org/apache/fop/util/text/GlyphNameFieldPart.java +++ b/fop-core/src/main/java/org/apache/fop/util/text/GlyphNameFieldPart.java @@ -49,7 +49,7 @@ public class GlyphNameFieldPart implements Part { private String getGlyphName(Object obj) { if (obj instanceof Character) { - return Glyphs.charToGlyphName(((Character)obj).charValue()); + return Glyphs.charToGlyphName((Character) obj); } else { throw new IllegalArgumentException( "Value for glyph name part must be a Character but was: " diff --git a/fop-core/src/main/java/org/apache/fop/util/text/HexFieldPart.java b/fop-core/src/main/java/org/apache/fop/util/text/HexFieldPart.java index 6333a8df2..075adb00f 100644 --- a/fop-core/src/main/java/org/apache/fop/util/text/HexFieldPart.java +++ b/fop-core/src/main/java/org/apache/fop/util/text/HexFieldPart.java @@ -53,7 +53,7 @@ public class HexFieldPart implements Part { } Object obj = params.get(fieldName); if (obj instanceof Character) { - sb.append(Integer.toHexString(((Character)obj).charValue())); + sb.append(Integer.toHexString((Character) obj)); } else if (obj instanceof Number) { sb.append(Integer.toHexString(((Number)obj).intValue())); } else { diff --git a/fop-core/src/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java b/fop-core/src/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java index 74257833a..621b4ba3b 100644 --- a/fop-core/src/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java +++ b/fop-core/src/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java @@ -139,8 +139,8 @@ public abstract class AbstractAFPObjectTest { int index = 0; for (byte[] anExpected : expected) { - for (int j = 0; j < anExpected.length; j++) { - assertTrue("" + index, actual[index] == anExpected[j]); + for (byte anAnExpected : anExpected) { + assertTrue("" + index, actual[index] == anAnExpected); index++; } } diff --git a/fop-core/src/test/java/org/apache/fop/render/afp/AFPRendererConfigParserTestCase.java b/fop-core/src/test/java/org/apache/fop/render/afp/AFPRendererConfigParserTestCase.java index 8ed54049f..a85cfb820 100644 --- a/fop-core/src/test/java/org/apache/fop/render/afp/AFPRendererConfigParserTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/afp/AFPRendererConfigParserTestCase.java @@ -65,7 +65,7 @@ public class AFPRendererConfigParserTestCase public void testLineWidthCorrection() throws Exception { parseConfig(createRenderer()); assertEquals(AFPConstants.LINE_WIDTH_CORRECTION, - conf.getLineWidthCorrection().floatValue(), 0.0001f); + conf.getLineWidthCorrection(), 0.0001f); parseConfig(createRenderer().setLineWidthCorrection(1f)); assertEquals(Float.valueOf(1f), conf.getLineWidthCorrection()); } diff --git a/fop/examples/embedding/java/embedding/ExampleFO2PDF.java b/fop/examples/embedding/java/embedding/ExampleFO2PDF.java index e0c7fceea..81e60809c 100644 --- a/fop/examples/embedding/java/embedding/ExampleFO2PDF.java +++ b/fop/examples/embedding/java/embedding/ExampleFO2PDF.java @@ -88,11 +88,11 @@ public class ExampleFO2PDF { // Result processing FormattingResults foResults = fop.getResults(); java.util.List pageSequences = foResults.getPageSequences(); - for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { - PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); + for (Object pageSequence : pageSequences) { + PageSequenceResults pageSequenceResults = (PageSequenceResults) pageSequence; System.out.println("PageSequence " + (String.valueOf(pageSequenceResults.getID()).length() > 0 - ? pageSequenceResults.getID() : "") + ? pageSequenceResults.getID() : "") + " generated " + pageSequenceResults.getPageCount() + " pages."); } System.out.println("Generated " + foResults.getPageCount() + " pages in total."); diff --git a/fop/examples/embedding/java/embedding/MultipleFO2PDF.java b/fop/examples/embedding/java/embedding/MultipleFO2PDF.java index 60f26905f..47be08cf1 100644 --- a/fop/examples/embedding/java/embedding/MultipleFO2PDF.java +++ b/fop/examples/embedding/java/embedding/MultipleFO2PDF.java @@ -142,11 +142,11 @@ public class MultipleFO2PDF { // Result processing java.util.List pageSequences = foResults.getPageSequences(); - for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { - PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); + for (Object pageSequence : pageSequences) { + PageSequenceResults pageSequenceResults = (PageSequenceResults) pageSequence; System.out.println("PageSequence " + (String.valueOf(pageSequenceResults.getID()).length() > 0 - ? pageSequenceResults.getID() : "") + ? pageSequenceResults.getID() : "") + " generated " + pageSequenceResults.getPageCount() + " pages."); } System.out.println("Generated " + foResults.getPageCount() + " pages in total."); diff --git a/fop/examples/embedding/java/embedding/atxml/ExampleConcat.java b/fop/examples/embedding/java/embedding/atxml/ExampleConcat.java index 977b09f6a..b83bea437 100644 --- a/fop/examples/embedding/java/embedding/atxml/ExampleConcat.java +++ b/fop/examples/embedding/java/embedding/atxml/ExampleConcat.java @@ -152,8 +152,8 @@ public class ExampleConcat { //Iterate over all area tree files AreaTreeParser parser = new AreaTreeParser(); - for (int i = 0; i < files.length; i++) { - Source src = new StreamSource(files[i]); + for (File file : files) { + Source src = new StreamSource(file); parser.parse(src, treeModel, userAgent); } diff --git a/fop/examples/embedding/java/embedding/intermediate/ExampleConcat.java b/fop/examples/embedding/java/embedding/intermediate/ExampleConcat.java index f3b738672..429ad0d79 100644 --- a/fop/examples/embedding/java/embedding/intermediate/ExampleConcat.java +++ b/fop/examples/embedding/java/embedding/intermediate/ExampleConcat.java @@ -160,8 +160,8 @@ public class ExampleConcat { IFConcatenator concatenator = new IFConcatenator(targetHandler, null); //Iterate over all intermediate files - for (int i = 0; i < files.length; i++) { - Source src = new StreamSource(files[i]); + for (File file : files) { + Source src = new StreamSource(file); concatenator.appendDocument(src); } diff --git a/fop/examples/embedding/java/embedding/model/ProjectTeamXMLReader.java b/fop/examples/embedding/java/embedding/model/ProjectTeamXMLReader.java index b08351a86..61cfc1fb3 100644 --- a/fop/examples/embedding/java/embedding/model/ProjectTeamXMLReader.java +++ b/fop/examples/embedding/java/embedding/model/ProjectTeamXMLReader.java @@ -20,7 +20,6 @@ package embedding.model; //Java -import java.util.Iterator; import java.io.IOException; //SAX @@ -87,9 +86,8 @@ public class ProjectTeamXMLReader extends AbstractObjectReader { handler.startElement("projectteam"); handler.element("projectname", projectTeam.getProjectName()); - Iterator i = projectTeam.getMembers().iterator(); - while (i.hasNext()) { - ProjectMember member = (ProjectMember)i.next(); + for (Object o : projectTeam.getMembers()) { + ProjectMember member = (ProjectMember) o; generateFor(member); } handler.endElement("projectteam"); diff --git a/fop/examples/embedding/java/embedding/tools/AbstractObjectReader.java b/fop/examples/embedding/java/embedding/tools/AbstractObjectReader.java index 641a90ca3..df34d09ee 100644 --- a/fop/examples/embedding/java/embedding/tools/AbstractObjectReader.java +++ b/fop/examples/embedding/java/embedding/tools/AbstractObjectReader.java @@ -135,7 +135,7 @@ public abstract class AbstractObjectReader implements XMLReader { * @see org.xml.sax.XMLReader#getFeature(String) */ public boolean getFeature(java.lang.String name) { - return ((Boolean) features.get(name)).booleanValue(); + return (Boolean) features.get(name); } /** @@ -158,7 +158,7 @@ public abstract class AbstractObjectReader implements XMLReader { * @see org.xml.sax.XMLReader#setFeature(String, boolean) */ public void setFeature(java.lang.String name, boolean value) { - this.features.put(name, new Boolean(value)); + this.features.put(name, value); } /** diff --git a/fop/lib/xmlgraphics-commons-svn-trunk.jar b/fop/lib/xmlgraphics-commons-svn-trunk.jar index f0707cb8e..07a0f325d 100644 Binary files a/fop/lib/xmlgraphics-commons-svn-trunk.jar and b/fop/lib/xmlgraphics-commons-svn-trunk.jar differ