]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Use foreach and cleanup
authorSimon Steiner <ssteiner@apache.org>
Fri, 4 Aug 2017 14:15:05 +0000 (14:15 +0000)
committerSimon Steiner <ssteiner@apache.org>
Fri, 4 Aug 2017 14:15:05 +0000 (14:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1804125 13f79535-47bb-0310-9956-ffa450edef68

15 files changed:
fop-core/src/main/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java
fop-core/src/main/java/org/apache/fop/fo/properties/NumberProperty.java
fop-core/src/main/java/org/apache/fop/fonts/SingleByteFont.java
fop-core/src/main/java/org/apache/fop/pdf/PDFPattern.java
fop-core/src/main/java/org/apache/fop/util/text/GlyphNameFieldPart.java
fop-core/src/main/java/org/apache/fop/util/text/HexFieldPart.java
fop-core/src/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java
fop-core/src/test/java/org/apache/fop/render/afp/AFPRendererConfigParserTestCase.java
fop/examples/embedding/java/embedding/ExampleFO2PDF.java
fop/examples/embedding/java/embedding/MultipleFO2PDF.java
fop/examples/embedding/java/embedding/atxml/ExampleConcat.java
fop/examples/embedding/java/embedding/intermediate/ExampleConcat.java
fop/examples/embedding/java/embedding/model/ProjectTeamXMLReader.java
fop/examples/embedding/java/embedding/tools/AbstractObjectReader.java
fop/lib/xmlgraphics-commons-svn-trunk.jar

index 6c939acae30f38d118c5a0de54dc47bd64ae8291..00c8cf1bfcb326c028ebd993842390c0313ed72d 100644 (file)
@@ -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;
index 7f54fbc8f205b5b998b01718b408096bab2b54af..d99405a76ff27d157252b6feef231f0124e03c0f 100644 (file)
@@ -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));
     }
 
     /**
index 262ea0a75033cfc8fca480cbe4092e062cc66b72..53d3cd4fce03f39ceef258e0c91ce47335b7b753 100644 (file)
@@ -363,7 +363,7 @@ public class SingleByteFont extends CustomFont {
         if (this.unencodedCharacters != null) {
             Set<Character> sortedKeys = new TreeSet<Character>(this.unencodedCharacters.keySet());
             for (Character ch : sortedKeys) {
-                char mapped = mapChar(ch.charValue());
+                char mapped = mapChar(ch);
                 assert mapped != Typeface.NOT_FOUND;
             }
         }
index ebc21b811146739e8c76c4c2ad3317a5f53fe9a5..0ccc4265f969c98c366046f7be42ac70c88db88d 100644 (file)
@@ -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");
index f0e5bcc32db8341a1c85359a920417fe73a5f6f3..48346c13a9c272e7070c8a68e466afb96516ed87 100644 (file)
@@ -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: "
index 6333a8df2e85e8c03fbb034407401b44ffceaf4d..075adb00fc18da1ca24f55a115c047be8820437d 100644 (file)
@@ -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 {
index 74257833a0fbfb17f8d4f83abebefceef2b09a0a..621b4ba3bc44ae07968faed0c022b4dd8abd4fbd 100644 (file)
@@ -139,8 +139,8 @@ public abstract class AbstractAFPObjectTest<S extends AbstractAFPObject> {
 
        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++;
             }
         }
index 8ed54049ffccaf9da3817bfa8561fd5a56532094..a85cfb820035499006f18e108d8bce63046b71f0 100644 (file)
@@ -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());
     }
index e0c7fceea9fc25e17964c06eeeb35f851fabd347..81e60809c24645ac300d2321cf961cebd95a7bc1 100644 (file)
@@ -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() : "<no id>")
+                        ? pageSequenceResults.getID() : "<no id>")
                         + " generated " + pageSequenceResults.getPageCount() + " pages.");
             }
             System.out.println("Generated " + foResults.getPageCount() + " pages in total.");
index 60f26905fd4edc4a4e0170cf5b8f0eccf6b2cf2d..47be08cf1a45ff9e08bee023c68b42a288fcd0b6 100644 (file)
@@ -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() : "<no id>")
+                            ? pageSequenceResults.getID() : "<no id>")
                             + " generated " + pageSequenceResults.getPageCount() + " pages.");
                 }
                 System.out.println("Generated " + foResults.getPageCount() + " pages in total.");
index 977b09f6a40c9ac9335a3a3c5a625a505da2f178..b83bea4378d48c7f7c1290db21e9375b5770a071 100644 (file)
@@ -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);
             }
 
index f3b7386720330379993c454985b7a6d86281a7c1..429ad0d79c295ffc9e2320bb24dc74f80e3e885e 100644 (file)
@@ -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);
             }
 
index b08351a86bf51b776dc2b095717d34c81199f302..61cfc1fb3ec3da94a23ec0a0555e45e520eaad4c 100644 (file)
@@ -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");
index 641a90ca36b54854ec69824d6c70576c9742ed9b..df34d09ee931a17926acadedbd31fcc3cbd676c3 100644 (file)
@@ -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);
     }
 
     /**
index f0707cb8e631bbfe7f1190045c28464c033fed55..07a0f325db3e7abc98c25bccf536a7c3f22b643d 100644 (file)
Binary files a/fop/lib/xmlgraphics-commons-svn-trunk.jar and b/fop/lib/xmlgraphics-commons-svn-trunk.jar differ