]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Address high and medium priority findbugs warnings
authorAndreas L. Delmelle <adelmelle@apache.org>
Sat, 23 May 2015 21:07:13 +0000 (21:07 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Sat, 23 May 2015 21:07:13 +0000 (21:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1681384 13f79535-47bb-0310-9956-ffa450edef68

32 files changed:
findbugs-exclude.xml
src/java/org/apache/fop/afp/AFPStreamer.java
src/java/org/apache/fop/area/Page.java
src/java/org/apache/fop/area/PageViewport.java
src/java/org/apache/fop/area/RegionReference.java
src/java/org/apache/fop/area/inline/InlineArea.java
src/java/org/apache/fop/area/inline/TextArea.java
src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java
src/java/org/apache/fop/fo/flow/MultiProperties.java
src/java/org/apache/fop/fo/flow/MultiPropertySet.java
src/java/org/apache/fop/fo/flow/MultiToggle.java
src/java/org/apache/fop/fo/flow/table/TableAndCaption.java
src/java/org/apache/fop/fo/flow/table/TableCaption.java
src/java/org/apache/fop/fo/properties/CommonAural.java
src/java/org/apache/fop/fo/properties/CommonMarginInline.java
src/java/org/apache/fop/fo/properties/CommonRelativePosition.java
src/java/org/apache/fop/fonts/truetype/OpenFont.java
src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java
src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
src/java/org/apache/fop/layoutmgr/FloatContentLayoutManager.java
src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
src/java/org/apache/fop/pdf/PDFCMap.java
src/java/org/apache/fop/pdf/PDFFactory.java
src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java
src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
src/java/org/apache/fop/render/xml/XMLRenderer.java
src/java/org/apache/fop/svg/NativeTextPainter.java
src/java/org/apache/fop/svg/PDFGraphics2D.java
src/java/org/apache/fop/tools/anttasks/RunTest.java
test/layoutengine/standard-testcases/footnote_id.xml

index e2f560e97c13aeac224110b1207a5f78fa2b1b7f..37a341de0c3b452e36fc108ffca00f8b8908134b 100644 (file)
       </And>
     </Or>
   </Match>
+  <Match>
+    <!-- Only OK as long as the type of the base map remains plain HashMap... -->
+    <Bug pattern="DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS"/>
+    <And>
+      <Class name="org.apache.fop.fonts.truetype.OpenFont"/>
+      <Method name="sortDirTabMap"/>
+    </And>
+  </Match>
   <Match>
     <Bug pattern="EQ_ALWAYS_TRUE"/>
     <Or>
       <Class name="org.apache.fop.util.QName"/>
     </Or>
   </Match>
+  <Match>
+    <Bug pattern="OS_OPEN_STREAM_EXCEPTION_PATH"/>
+    <!-- TODO - fix potential file descriptor leak -->
+    <And>
+      <Class name="org.apache.fop.hyphenation.SerializeHyphPattern"/>
+      <Method name="serializeFile"/>
+    </And>
+  </Match>
   <Match>
     <Bug pattern="SE_INNER_CLASS"/>
     <Or>
       </And>
     </Or>
   </Match>
+  <Match>
+    <Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
+    <Or>
+      <!-- TODO - fix later -->
+      <Class name="org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement"/>
+      <!-- FOs not yet implemented -->
+      <Class name="org.apache.fop.fo.flow.MultiProperties"/>
+      <Class name="org.apache.fop.fo.flow.MultiPropertySet"/>
+      <Class name="org.apache.fop.fo.flow.MultiToggle"/>
+      <Class name="org.apache.fop.fo.flow.table.TableAndCaption"/>
+      <Class name="org.apache.fop.fo.flow.table.TableCaption"/>
+    </Or>
+  </Match>
+  <Match>
+    <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
+    <Or>
+      <!-- TODO - Implementation incomplete? 
+                  If not, remove unused field(s) and unused accessors -->
+      <Class name="org.apache.fop.complexscripts.fonts.GlyphProcessingState"/>
+      <Class name="org.apache.fop.layoutmgr.inline.InlineStackingLayoutManager"/>
+      <Class name="org.apache.fop.pdf.PDFCMap"/>
+      <Class name="org.apache.fop.render.pdf.PDFSVGHandler$PDFInfo"/>
+      <Class name="org.apache.fop.svg.PDFGraphics2D"/>
+      <!-- Properties not yet implemented -->
+      <Class name="org.apache.fop.fo.flow.MultiToggle"/>
+      <Class name="org.apache.fop.fo.properties.CommonMarginInline"/>
+      <Class name="org.apache.fop.fo.properties.CommonRelativePosition"/>
+    </Or>
+  </Match>
+  <Match>
+    <Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/>
+    <!-- Properties not yet implemented -->
+    <Class name="org.apache.fop.fo.properties.CommonAural"/>
+  </Match>
   <!-- END - APPROVED EXCLUSIONS -->
 
   <!-- START - TEMPORARY (UNAPPROVED) EXCLUSIONS -->
     <!-- 29 warnings -->
     <Bug pattern="DM_CONVERT_CASE"/>
   </Match>
+  <Match>
+    <!-- 17 warnings -->
+    <Bug pattern="DM_DEFAULT_ENCODING"/>
+  </Match>
   <Match>
     <!-- 20 warnings -->
     <Bug pattern="DM_FP_NUMBER_CTOR"/>
index 5e6b5a79e04b776a68a80d6d4f8e249da3c29118..d93972973dc41c206165c31a24a3b71648ecbeb9 100644 (file)
@@ -160,10 +160,10 @@ public class AFPStreamer implements Streamable {
      */
     // write out any external resource groups
     public void close() throws IOException {
-        Iterator it = pathResourceGroupMap.values().iterator();
-        while (it.hasNext()) {
-            StreamedResourceGroup resourceGroup = (StreamedResourceGroup)it.next();
-            resourceGroup.close();
+        for (ResourceGroup resourceGroup : pathResourceGroupMap.values()) {
+            // TODO - Why not a Map<URI, StreamedResourceGroup>, if all the elements are expected to be of that type?
+            assert (resourceGroup instanceof StreamedResourceGroup);
+            ((StreamedResourceGroup) resourceGroup).close();
         }
         // close any open print-file resource group
         if (printFileResourceGroup != null) {
index e26429fcc4ba63c87e5db8bc0a7f2bc104a4252f..71de13852fa63abc1a0b9600668a3cccd09919e8 100644 (file)
@@ -252,8 +252,7 @@ public class Page extends AreaTreeObject implements Serializable {
         } else if (regionBody == null) {
             return true;
         } else {
-            BodyRegion body = (BodyRegion)regionBody.getRegionReference();
-            return body.isEmpty();
+            return regionBody.getRegionReference().isEmpty();
         }
     }
 
index 3235d8f3caebb2006b68488e4f92a846af2989f7..dd5c387ee7a9bc6e91a01fb04baae90f64cd0f95 100644 (file)
@@ -364,8 +364,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable {
      * This will retrieve a marker with the class name
      * and position.
      *
-     * @param name The class name of the marker to retrieve
-     * @param pos the position to retrieve
+     * @param rm    the retrieve-marker instance
      * @return Object the marker found or null
      */
     public Marker resolveMarker(AbstractRetrieveMarker rm) {
@@ -409,8 +408,8 @@ public class PageViewport extends AreaTreeObject implements Resolvable {
         page = (Page) in.readObject();
         unresolvedIDRefs = page.getUnresolvedReferences();
         if (unresolvedIDRefs != null && pendingResolved != null) {
-            for (String id : pendingResolved.keySet()) {
-                resolveIDRef(id, pendingResolved.get(id));
+            for (Map.Entry<String, List<PageViewport>> e : pendingResolved.entrySet()) {
+                resolveIDRef(e.getKey(), e.getValue());
             }
             pendingResolved = null;
         }
@@ -457,7 +456,9 @@ public class PageViewport extends AreaTreeObject implements Resolvable {
      * @return BodyRegion object
      */
     public BodyRegion getBodyRegion() {
-        return (BodyRegion) getPage().getRegionViewport(FO_REGION_BODY).getRegionReference();
+        RegionReference regionReference = getPage().getRegionViewport(FO_REGION_BODY).getRegionReference();
+        assert (regionReference instanceof BodyRegion);
+        return (BodyRegion) regionReference;
     }
 
     /**
index e6b46fee46169aa38de4614f2f548cde86c77c9f..a22bb5b06c20170014d3b66c1dbb3d8bdf8f9eec 100644 (file)
@@ -134,6 +134,15 @@ public class RegionReference extends Area {
         addChildArea(block);
     }
 
+    /**
+     * indicates whether the main reference area has any child areas added to it
+     *
+     * @return whether the main reference area has any child areas added to it
+     */
+    public boolean isEmpty() {
+        return true;
+    }
+
     /** {@inheritDoc} */
     public Object clone() throws CloneNotSupportedException {
         RegionReference rr = (RegionReference) super.clone();
index e85d779fe84e670d24c41f9c7e8851996fa9e35d..1733f7b3d3b620110f494d346d198a76c13ef21e 100644 (file)
@@ -272,11 +272,12 @@ public class InlineArea extends Area {
      * @param ipdVariation the difference between new and old ipd
      */
     protected void notifyIPDVariation(int ipdVariation) {
-        if (getParentArea() instanceof InlineArea) {
-            ((InlineArea) getParentArea()).handleIPDVariation(ipdVariation);
-        } else if (getParentArea() instanceof LineArea) {
-            ((LineArea) getParentArea()).handleIPDVariation(ipdVariation);
-        } else if (getParentArea() == null) {
+        Area parentArea = getParentArea();
+        if (parentArea instanceof InlineArea) {
+            ((InlineArea) parentArea).handleIPDVariation(ipdVariation);
+        } else if (parentArea instanceof LineArea) {
+            ((LineArea) parentArea).handleIPDVariation(ipdVariation);
+        } else if (parentArea == null) {
             // parent area not yet set: store the variations
             storedIPDVariation += ipdVariation;
         }
index 91a75d558b5a83ad0b195db59dcb3759754f6fa9..5a1b31c986d2bd2d1ef354e7b8abdf3b306d0436 100644 (file)
@@ -144,12 +144,13 @@ public class TextArea extends AbstractTextArea {
      * @return the text string
      */
     public String getText() {
-        StringBuffer text = new StringBuffer();
+        StringBuilder text = new StringBuilder();
         // assemble the text
         for (InlineArea inline : inlines) {
             if (inline instanceof WordArea) {
                 text.append(((WordArea) inline).getWord());
             } else {
+                assert (inline instanceof SpaceArea);
                 text.append(((SpaceArea) inline).getSpace());
             }
         }
index 82a188abc886b1c9f6d93a197ebc3fb65f571770..322399170aec5f04579fb32f40de7ca6cca76bfd 100644 (file)
@@ -119,6 +119,7 @@ public class GlyphProcessingState {
      * @param language language identifier
      * @param feature feature identifier
      * @param sct script context tester (or null)
+     * @return this instance
      */
     protected GlyphProcessingState reset(GlyphSequence gs, String script, String language, String feature, ScriptContextTester sct) {
         this.gdef = null;
@@ -130,7 +131,7 @@ public class GlyphProcessingState {
         this.indexLast = gs.getGlyphCount();
         this.consumed = 0;
         this.lookupFlags = 0;
-        this.classMatchSet = 0;
+        this.classMatchSet = 0; // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
         this.sct = sct;
         this.gct = (sct != null) ? sct.getTester(feature) : null;
         this.ignoreBase = new GlyphTester() { public boolean test(int gi, int flags) { return isIgnoredBase(gi, flags); } };
index 653c5f74d573f337bc0c8d5204915e7659292921..195dbd8f1deb32e91bd62621452c91b3ea7ca4e8 100644 (file)
@@ -54,6 +54,7 @@ public class MultiProperties extends FObj {
         if (!notImplementedWarningGiven) {
             getFOValidationEventProducer().unimplementedFeature(this, getName(),
                     getName(), getLocator());
+            // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
             notImplementedWarningGiven = true;
         }
     }
index 7a1c5a01e1195078678ed6d57fe5a5d8ad0c0ff6..298ae62c1d9ffd3ec1debdd0ee9a85332cf5b655 100644 (file)
@@ -50,6 +50,7 @@ public class MultiPropertySet extends FObj {
         if (!notImplementedWarningGiven) {
             getFOValidationEventProducer().unimplementedFeature(this, getName(),
                     getName(), getLocator());
+            // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
             notImplementedWarningGiven = true;
         }
     }
index 211c5b8b86e562c83a3b376b4daf0d15767a20b0..d9f46364eff93c8c63b12d5552e5a09d5fdc0c86 100644 (file)
@@ -31,12 +31,12 @@ import org.apache.fop.fo.properties.StringProperty;
 
 /**
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_multi-toggle">
- * <code>fo:multi-toggle<code></a> property.
+ * <code>fo:multi-toggle</code></a> property.
  */
 public class MultiToggle extends FObj {
     // The value of properties relevant for fo:multi-toggle (commented out for performance).
     //     private CommonAccessibility commonAccessibility;
-     public StringProperty prSwitchTo;
+    public StringProperty prSwitchTo; // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     // End of property values
 
     private static boolean notImplementedWarningGiven;
@@ -52,6 +52,7 @@ public class MultiToggle extends FObj {
         if (!notImplementedWarningGiven) {
             getFOValidationEventProducer().unimplementedFeature(this, getName(),
                     getName(), getLocator());
+            // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
             notImplementedWarningGiven = true;
         }
     }
index e452f04d02d505343c69c4756e3b189d47e110f9..b7c7adc910699152e02e46f6a46e85a1e18baae2 100644 (file)
@@ -72,6 +72,7 @@ public class TableAndCaption extends FObj implements CommonAccessibilityHolder {
         if (!notImplementedWarningGiven) {
             getFOValidationEventProducer().unimplementedFeature(this, getName(),
                     "fo:table-and-caption", getLocator());
+            // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
             notImplementedWarningGiven = true;
         }
     }
index 454bcddfdcd2cabd20fd54e61152228f822bf002..5ecce65af01c11b3e3b2ab9c0464f3000784f560 100644 (file)
@@ -67,6 +67,7 @@ public class TableCaption extends FObj implements CommonAccessibilityHolder {
         if (!notImplementedWarningGiven) {
             getFOValidationEventProducer().unimplementedFeature(this, getName(),
                     "fo:table-caption", getLocator());
+            // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
             notImplementedWarningGiven = true;
         }
     }
index a47f183f11d2594ed5dd95ae17d5deac8437b8ba..387562f9134ddab15515d4a22342bbee394f12ed 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.fop.fo.PropertyList;
  * Public "structure" allows direct member access.
  */
 public class CommonAural {
+    // @SuppressFBWarnings("UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD")
     /**
      * The "azimuth" property.
      */
index 04f60ac6606606a941d72d7f5346da70df5fc56c..8d6b9a4460a3f3744e3be89f2bb247779d0303fe 100644 (file)
@@ -30,7 +30,7 @@ import org.apache.fop.fo.expr.PropertyException;
  * Public "structure" allows direct member access.
  */
 public class CommonMarginInline {
-
+    // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     /**
      * The "margin-top" property.
      */
index 872d72314bc51333c8a31f8e957fa7f753ead2b7..964f7cd7f432e2b1e58f3e577f4378948bf607d9 100644 (file)
@@ -30,6 +30,7 @@ import org.apache.fop.fo.expr.PropertyException;
  * Public "structure" allows direct member access.
  */
 public class CommonRelativePosition {
+    // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     /**
      * The "relative-position" property.
      */
index b736c9968fbdf6887c823b3b5c16729f1e3eba5c..9d3a4769d7de54925b3ddea23976b319dff49ded 100644 (file)
@@ -1603,10 +1603,12 @@ public abstract class OpenFont {
             // Create winAnsiEncoded kerning table from kerningTab
             // (could probably be simplified, for now we remap back to CID indexes and
             // then to winAnsi)
-            for (Integer unicodeKey1 : kerningTab.keySet()) {
-                Integer cidKey1 = unicodeToGlyph(unicodeKey1.intValue());
+
+            for (Map.Entry<Integer, Map<Integer, Integer>> e1 : kerningTab.entrySet()) {
+                Integer unicodeKey1 = e1.getKey();
+                Integer cidKey1 = unicodeToGlyph(unicodeKey1);
                 Map<Integer, Integer> akpx = new HashMap<Integer, Integer>();
-                Map<Integer, Integer> ckpx = kerningTab.get(unicodeKey1);
+                Map<Integer, Integer> ckpx = e1.getValue();
 
                 for (Map.Entry<Integer, Integer> e : ckpx.entrySet()) {
                     Integer unicodeKey2 = e.getKey();
@@ -1693,6 +1695,7 @@ public abstract class OpenFont {
                 return (int) (o1.getValue().getOffset() - o2.getValue().getOffset());
             }
         });
+        // @SuppressFBWarnings("DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS")
         sortedSet.addAll(directoryTabs.entrySet());
         return sortedSet;
     }
index c5f5ccc60982d13100481865c6bac2b3f743a174..8d51edf2521822a8f86c622e496d2a129135fc3c 100644 (file)
@@ -53,12 +53,14 @@ public class SerializeHyphPattern {
                 return name.endsWith(extension);
             }
         });
-        for (int j = 0; j < sourceFiles.length; j++) {
-            File infile = new File(sourceDir, sourceFiles[j]);
-            String outfilename = sourceFiles[j].substring(0, sourceFiles[j].length()
-                                                          - extension.length()) + ".hyp";
-            File outfile = new File(targetDir, outfilename);
-            serializeFile(infile, outfile);
+        if (sourceFiles != null) {
+            for (String sourceFile : sourceFiles) {
+                File infile = new File(sourceDir, sourceFile);
+                String outfilename = sourceFile.substring(0, sourceFile.length()
+                        - extension.length()) + ".hyp";
+                File outfile = new File(targetDir, outfilename);
+                serializeFile(infile, outfile);
+            }
         }
     }
 
@@ -73,6 +75,7 @@ public class SerializeHyphPattern {
             HyphenationTree hTree = buildPatternFile(infile);
             // serialize class
             try {
+                // @SuppressFBWarnings("OS_OPEN_STREAM_EXCEPTION_PATH")
                 ObjectOutputStream out = new ObjectOutputStream(
                         new java.io.BufferedOutputStream(
                         new java.io.FileOutputStream(outfile)));
index 21dcf9ea9b2e1599c1fbb226029c22e0862b2d55..802960c65e6acbb3c1eb55765b16851189611132 100644 (file)
@@ -618,10 +618,12 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
                 }
             }
         } else if (innerPosition != null && innerPosition.getLM() != this) {
+            Position lastPosition = lastElement.getPosition();
+            assert (lastPosition instanceof NonLeafPosition);
             // this adjustment concerns another LM
-            NonLeafPosition savedPos = (NonLeafPosition) lastElement.getPosition();
+            NonLeafPosition savedPos = (NonLeafPosition) lastPosition;
             lastElement.setPosition(innerPosition);
-            int returnValue = ((BlockLevelLayoutManager)lastElement.getLayoutManager())
+            int returnValue = ((BlockLevelLayoutManager) lastElement.getLayoutManager())
                     .negotiateBPDAdjustment(adj, lastElement);
             lastElement.setPosition(savedPos);
             return returnValue;
@@ -635,7 +637,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     /** {@inheritDoc} */
     public void discardSpace(KnuthGlue spaceGlue) {
         assert (spaceGlue != null && spaceGlue.getPosition() != null);
-        Position innerPosition = spaceGlue.getPosition().getPosition();
+        Position mainPosition = spaceGlue.getPosition();
+        Position innerPosition = mainPosition.getPosition();
 
         if (innerPosition == null || innerPosition.getLM() == this) {
             // if this block has block-progression-unit > 0, innerPosition can be
@@ -652,8 +655,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
                 //TODO Why are both cases handled in the same way?
             }
         } else {
+            assert (mainPosition instanceof NonLeafPosition);
             // this element was not created by this BlockLM
-            NonLeafPosition savedPos = (NonLeafPosition)spaceGlue.getPosition();
+            NonLeafPosition savedPos = (NonLeafPosition) mainPosition;
             spaceGlue.setPosition(innerPosition);
             ((BlockLevelLayoutManager) spaceGlue.getLayoutManager()).discardSpace(spaceGlue);
             spaceGlue.setPosition(savedPos);
index 5c6f6c685eb266db22f49c6ba4f15f0511802538..06e1484cf084720bbb1eee9d02fc3facc7cc68f4 100644 (file)
@@ -133,7 +133,7 @@ public class FloatContentLayoutManager extends SpacedBorderedPaddedBlockLayoutMa
         while (!(lm instanceof BlockLayoutManager)) {
             lm = lm.getParent();
         }
-        if (lm instanceof BlockLayoutManager) {
+        if (lm != null) {
             startIndent = ((BlockLayoutManager) lm).startIndent;
         }
         return startIndent;
index 227acbfd37e1a82dc0421dd966690fe2f50c83ce..99f6367a35f05bd9b94d9cfb4a079392eb720593 100644 (file)
@@ -239,9 +239,10 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
     public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
         log.debug(" FLM.negotiateBPDAdjustment> " + adj);
 
-        if (lastElement.getPosition() instanceof NonLeafPosition) {
+        Position lastPosition = lastElement.getPosition();
+        if (lastPosition instanceof NonLeafPosition) {
             // this element was not created by this FlowLM
-            NonLeafPosition savedPos = (NonLeafPosition)lastElement.getPosition();
+            NonLeafPosition savedPos = (NonLeafPosition) lastPosition;
             lastElement.setPosition(savedPos.getPosition());
             int returnValue = ((BlockLevelLayoutManager)lastElement.getLayoutManager())
                     .negotiateBPDAdjustment(adj, lastElement);
@@ -258,9 +259,10 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
     public void discardSpace(KnuthGlue spaceGlue) {
         log.debug(" FLM.discardSpace> ");
 
-        if (spaceGlue.getPosition() instanceof NonLeafPosition) {
+        Position gluePosition = spaceGlue.getPosition();
+        if (gluePosition instanceof NonLeafPosition) {
             // this element was not created by this FlowLM
-            NonLeafPosition savedPos = (NonLeafPosition)spaceGlue.getPosition();
+            NonLeafPosition savedPos = (NonLeafPosition) gluePosition;
             spaceGlue.setPosition(savedPos.getPosition());
             ((BlockLevelLayoutManager) spaceGlue.getLayoutManager()).discardSpace(spaceGlue);
             spaceGlue.setPosition(savedPos);
index 1f4a06ee2d434d8d7925cbe3b6f2e30f59e21378..5e3820a4b4199f661b7f1c82501d708dd84e4bf2 100644 (file)
@@ -63,7 +63,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
      */
     protected InlineStackingLayoutManager(FObj node) {
         super(node);
-        extraBPD = MinOptMax.ZERO;
+        extraBPD = MinOptMax.ZERO;  // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     }
 
     /**
index 47561f3c92d08d6212d075a57b267817ed10348e..342a2f33c94eeb74f49d777482b1b2aa3c0629de 100644 (file)
@@ -43,9 +43,6 @@ public class TableRowIterator {
     /** Selects the table-footer elements for iteration. */
     public static final int FOOTER = 2;
 
-    /** The table on which this instance operates. */
-    protected Table table;
-
     /** Part of the table over which to iterate. One of BODY, HEADER or FOOTER. */
     private int tablePart;
 
@@ -59,7 +56,6 @@ public class TableRowIterator {
      * @param tablePart indicates what part of the table to iterate over (HEADER, FOOTER, BODY)
      */
     public TableRowIterator(Table table, int tablePart) {
-        this.table = table;
         this.tablePart = tablePart;
         switch(tablePart) {
             case HEADER:
index 34bc0f9523825af859c63b1131e87fe778f82f7a..c96cf9d3b2e3e50e4f3c2357792915be126cf93e 100644 (file)
@@ -365,7 +365,7 @@ public class PDFCMap extends PDFStream {
     /**
      * font's writing direction
      */
-    protected byte wMode = WMODE_HORIZONTAL;
+    protected byte wMode = WMODE_HORIZONTAL; // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
 
     /**
      * base CMap (String or PDFStream)
@@ -381,8 +381,8 @@ public class PDFCMap extends PDFStream {
     public PDFCMap(String name, PDFCIDSystemInfo sysInfo) {
         super();
         this.name = name;
-        this.sysInfo = sysInfo;
-        this.base = null;
+        this.sysInfo = sysInfo;  // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
+        this.base = null;  // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     }
 
     /**
index b1152df162447fda7411081f0d3f756236f14927..ad117c9d09f3286db4d34c86bcf0806bb9445f74 100644 (file)
@@ -1265,7 +1265,9 @@ public class PDFFactory {
             log.error("Failed to embed font [" + desc + "] " + desc.getEmbedFontName(), ioe);
             return null;
         } finally {
-            IOUtils.closeQuietly(in);
+            if (in != null) {
+                IOUtils.closeQuietly(in);
+            }
         }
     }
 
index 1b13fd78342879a01fd2f5d1ec048bb421cbe6bd..b9f0b501d6837c394b9d9727bad397f2001aa4a4 100644 (file)
@@ -55,7 +55,7 @@ public abstract class RtfElement {
 
     /** Create an RTF element as a child of given container with given attributes */
     RtfElement(RtfContainer parent, Writer w, RtfAttributes attr) throws IOException {
-
+        // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
         id = idCounter++;
         this.parent = parent;
         attrib = (attr != null ? attr : new RtfAttributes());
index 040118eb57c457f8983fdeacd0196f7ea40aa991..5af417ed53906b043325aa2eb604e6f8bc98d905 100644 (file)
@@ -233,11 +233,6 @@ public class RtfExternalGraphic extends RtfElement {
      */
     protected int height = -1;
 
-    /**
-     * The desired percent value of the height
-     */
-    protected int heightPercent = -1;
-
     /**
      * The desired height (in twips)
      */
@@ -253,11 +248,6 @@ public class RtfExternalGraphic extends RtfElement {
      */
     protected int width = -1;
 
-    /**
-     * The desired percent value of the width
-     */
-    protected int widthPercent = -1;
-
     /**
      * The desired width (in twips)
      */
index d6da9d57dcbd6c69dd2c2cab9d734a8b6f46e218..6c392ab4d15371f18b8237f9f53caaaf3ebf92dc 100644 (file)
@@ -202,7 +202,7 @@ public class XMLRenderer extends AbstractXMLRenderer {
                     continue;
                 }
                 Object value = traitEntry.getValue();
-                if (key == Trait.FONT) {
+                if (((Integer) key).intValue() == Trait.FONT) {
                     FontTriplet triplet = (FontTriplet)value;
                     addAttribute("font-name", triplet.getName());
                     addAttribute("font-style", triplet.getStyle());
@@ -245,8 +245,9 @@ public class XMLRenderer extends AbstractXMLRenderer {
                 } else if (clazz.equals(Color.class)) {
                     Color c = (Color)value;
                     addAttribute(name, ColorUtil.colorToString(c));
-                } else if (key == Trait.START_INDENT || key == Trait.END_INDENT) {
-                    if (((Integer)value).intValue() != 0) {
+                } else if (((Integer) key).intValue() == Trait.START_INDENT
+                        || ((Integer) key).intValue() == Trait.END_INDENT) {
+                    if ((Integer) value != 0) {
                         addAttribute(name, value.toString());
                     }
                 } else {
index 126e1efc322b863df2c25a8969f57e34e43ac887..983a184c44f8e115992165d07a0732dd2db10ec9 100644 (file)
@@ -216,11 +216,11 @@ public abstract class NativeTextPainter extends StrokingTextPainter {
     public List computeTextRuns(TextNode node, AttributedCharacterIterator nodeACI,
         AttributedCharacterIterator [] chunkACIs) {
         nodeACI.first();
-        int defaultBidiLevel = (nodeACI.getAttribute(WRITING_MODE) == WRITING_MODE_RTL) ? 1 : 0;
+        int defaultBidiLevel = (((Integer) nodeACI.getAttribute(WRITING_MODE)).intValue() == WRITING_MODE_RTL) ? 1 : 0;
         for (int i = 0, n = chunkACIs.length; i < n; ++i) {
             chunkACIs[i] = new BidiAttributedCharacterIterator(chunkACIs[i], defaultBidiLevel);
         }
-        return super.computeTextRuns(node, nodeACI, chunkACIs, (int[][]) null);
+        return super.computeTextRuns(node, nodeACI, chunkACIs, null);
     }
 
     // We want to sub-divide text chunks into distinct runs at bidi level boundaries.
index 5a029928141f363aed2b7dcb6ab25ec24354ccfe..9af8540e8cf6dd4335e2c60010a7d0f9fae4dcfc 100644 (file)
@@ -295,7 +295,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
      */
     public void setPaintingState(PDFPaintingState state) {
         paintingState = state;
-        baseLevel = paintingState.getStackLevel();
+        baseLevel = paintingState.getStackLevel(); // @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     }
 
     /**
index 1b560802a88ca5d9ce1b3bf272cedb1a246010f3..0d728ae9a3275d1c280cee47203c9afa4db2508b 100644 (file)
@@ -28,6 +28,7 @@ import java.net.URLClassLoader;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -226,14 +227,16 @@ public class RunTest extends Task {
      * @return a list of urls to the runtime jar files.
      */
     private URL[] createUrls(String mainJar) throws MalformedURLException {
-        ArrayList urls = new ArrayList();
+        List<URL> urls = new ArrayList<URL>();
         urls.add(new File(mainJar).toURI().toURL());
         File[] libFiles = new File("lib").listFiles();
-        for (int i = 0; i < libFiles.length; i++) {
-            if (libFiles[i].getPath().endsWith(".jar")) {
-                urls.add(libFiles[i].toURI().toURL());
+        if (libFiles != null) {
+            for (File libFile : libFiles) {
+                if (libFile.getPath().endsWith(".jar")) {
+                    urls.add(libFile.toURI().toURL());
+                }
             }
         }
-        return (URL[]) urls.toArray(new URL[urls.size()]);
+        return urls.toArray(new URL[urls.size()]);
     }
 }
index e9e30e3349237d4eb672fa8a35ecfef33954c72f..84593df3feb7503630850b8cbd4ba79b3d3459b2 100644 (file)
@@ -38,9 +38,7 @@
               <fo:inline font-size="6.95pt" vertical-align="super">1) </fo:inline>
                 <fo:footnote-body id="fnb1">
                   <fo:block text-align="left">
-                    <fo:inline font-size="6.95pt" vertical-align="super">1) </fo:inline>
-                    http://xmlgrapics.apache.org/fop/
-                  </fo:block>
+                    <fo:inline font-size="6.95pt" vertical-align="super">1) </fo:inline>http://xmlgrapics.apache.org/fop/</fo:block>
                 </fo:footnote-body>
             </fo:footnote>
           </fo:block>
@@ -65,6 +63,6 @@
     <!-- Check fo:footnote-body @id -->
     <!-- TODO - figure out where @prod-id should go -->
     <true xpath="((//page)[2]//block)[2]/lineArea[1]/inlineparent[1]/@internal-link" />
-    <eval expected="(P1,fnb1)" xpath="((//page)[2]//block)[2]/lineArea[1]/inlineparent[1]/@internal-link"/>
+    <eval expected="(P1,fnb1)" xpath="((//page)[2]//block)[1]/lineArea[1]/inlineparent[2]/@internal-link"/>
   </checks>
-</testcase>
\ No newline at end of file
+</testcase>