From 68203d133adb608b3b468f507b938ee276d23300 Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Sat, 23 May 2015 21:07:13 +0000 Subject: [PATCH] Address high and medium priority findbugs warnings git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1681384 13f79535-47bb-0310-9956-ffa450edef68 --- findbugs-exclude.xml | 54 +++++++++++++++++++ src/java/org/apache/fop/afp/AFPStreamer.java | 8 +-- src/java/org/apache/fop/area/Page.java | 3 +- .../org/apache/fop/area/PageViewport.java | 11 ++-- .../org/apache/fop/area/RegionReference.java | 9 ++++ .../apache/fop/area/inline/InlineArea.java | 11 ++-- .../org/apache/fop/area/inline/TextArea.java | 3 +- .../fonts/GlyphProcessingState.java | 3 +- .../apache/fop/fo/flow/MultiProperties.java | 1 + .../apache/fop/fo/flow/MultiPropertySet.java | 1 + .../org/apache/fop/fo/flow/MultiToggle.java | 5 +- .../fop/fo/flow/table/TableAndCaption.java | 1 + .../fop/fo/flow/table/TableCaption.java | 1 + .../apache/fop/fo/properties/CommonAural.java | 1 + .../fop/fo/properties/CommonMarginInline.java | 2 +- .../fo/properties/CommonRelativePosition.java | 1 + .../apache/fop/fonts/truetype/OpenFont.java | 9 ++-- .../fop/hyphenation/SerializeHyphPattern.java | 15 +++--- .../layoutmgr/BlockStackingLayoutManager.java | 12 +++-- .../layoutmgr/FloatContentLayoutManager.java | 2 +- .../fop/layoutmgr/FlowLayoutManager.java | 10 ++-- .../inline/InlineStackingLayoutManager.java | 2 +- .../fop/layoutmgr/table/TableRowIterator.java | 4 -- src/java/org/apache/fop/pdf/PDFCMap.java | 6 +-- src/java/org/apache/fop/pdf/PDFFactory.java | 4 +- .../render/rtf/rtflib/rtfdoc/RtfElement.java | 2 +- .../rtf/rtflib/rtfdoc/RtfExternalGraphic.java | 10 ---- .../apache/fop/render/xml/XMLRenderer.java | 7 +-- .../org/apache/fop/svg/NativeTextPainter.java | 4 +- .../org/apache/fop/svg/PDFGraphics2D.java | 2 +- .../apache/fop/tools/anttasks/RunTest.java | 13 +++-- .../standard-testcases/footnote_id.xml | 8 ++- 32 files changed, 150 insertions(+), 75 deletions(-) diff --git a/findbugs-exclude.xml b/findbugs-exclude.xml index e2f560e97..37a341de0 100644 --- a/findbugs-exclude.xml +++ b/findbugs-exclude.xml @@ -85,6 +85,14 @@ + + + + + + + + @@ -121,6 +129,14 @@ + + + + + + + + @@ -141,6 +157,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -160,6 +210,10 @@ + + + + diff --git a/src/java/org/apache/fop/afp/AFPStreamer.java b/src/java/org/apache/fop/afp/AFPStreamer.java index 5e6b5a79e..d93972973 100644 --- a/src/java/org/apache/fop/afp/AFPStreamer.java +++ b/src/java/org/apache/fop/afp/AFPStreamer.java @@ -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, 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) { diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java index e26429fcc..71de13852 100644 --- a/src/java/org/apache/fop/area/Page.java +++ b/src/java/org/apache/fop/area/Page.java @@ -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(); } } diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java index 3235d8f3c..dd5c387ee 100644 --- a/src/java/org/apache/fop/area/PageViewport.java +++ b/src/java/org/apache/fop/area/PageViewport.java @@ -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> 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; } /** diff --git a/src/java/org/apache/fop/area/RegionReference.java b/src/java/org/apache/fop/area/RegionReference.java index e6b46fee4..a22bb5b06 100644 --- a/src/java/org/apache/fop/area/RegionReference.java +++ b/src/java/org/apache/fop/area/RegionReference.java @@ -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(); diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java index e85d779fe..1733f7b3d 100644 --- a/src/java/org/apache/fop/area/inline/InlineArea.java +++ b/src/java/org/apache/fop/area/inline/InlineArea.java @@ -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; } diff --git a/src/java/org/apache/fop/area/inline/TextArea.java b/src/java/org/apache/fop/area/inline/TextArea.java index 91a75d558..5a1b31c98 100644 --- a/src/java/org/apache/fop/area/inline/TextArea.java +++ b/src/java/org/apache/fop/area/inline/TextArea.java @@ -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()); } } diff --git a/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java b/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java index 82a188abc..322399170 100644 --- a/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java +++ b/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java @@ -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); } }; diff --git a/src/java/org/apache/fop/fo/flow/MultiProperties.java b/src/java/org/apache/fop/fo/flow/MultiProperties.java index 653c5f74d..195dbd8f1 100644 --- a/src/java/org/apache/fop/fo/flow/MultiProperties.java +++ b/src/java/org/apache/fop/fo/flow/MultiProperties.java @@ -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; } } diff --git a/src/java/org/apache/fop/fo/flow/MultiPropertySet.java b/src/java/org/apache/fop/fo/flow/MultiPropertySet.java index 7a1c5a01e..298ae62c1 100644 --- a/src/java/org/apache/fop/fo/flow/MultiPropertySet.java +++ b/src/java/org/apache/fop/fo/flow/MultiPropertySet.java @@ -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; } } diff --git a/src/java/org/apache/fop/fo/flow/MultiToggle.java b/src/java/org/apache/fop/fo/flow/MultiToggle.java index 211c5b8b8..d9f46364e 100644 --- a/src/java/org/apache/fop/fo/flow/MultiToggle.java +++ b/src/java/org/apache/fop/fo/flow/MultiToggle.java @@ -31,12 +31,12 @@ import org.apache.fop.fo.properties.StringProperty; /** * Class modelling the - * fo:multi-toggle property. + * fo:multi-toggle 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; } } diff --git a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java index e452f04d0..b7c7adc91 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java +++ b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java @@ -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; } } diff --git a/src/java/org/apache/fop/fo/flow/table/TableCaption.java b/src/java/org/apache/fop/fo/flow/table/TableCaption.java index 454bcddfd..5ecce65af 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableCaption.java +++ b/src/java/org/apache/fop/fo/flow/table/TableCaption.java @@ -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; } } diff --git a/src/java/org/apache/fop/fo/properties/CommonAural.java b/src/java/org/apache/fop/fo/properties/CommonAural.java index a47f183f1..387562f91 100644 --- a/src/java/org/apache/fop/fo/properties/CommonAural.java +++ b/src/java/org/apache/fop/fo/properties/CommonAural.java @@ -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. */ diff --git a/src/java/org/apache/fop/fo/properties/CommonMarginInline.java b/src/java/org/apache/fop/fo/properties/CommonMarginInline.java index 04f60ac66..8d6b9a446 100644 --- a/src/java/org/apache/fop/fo/properties/CommonMarginInline.java +++ b/src/java/org/apache/fop/fo/properties/CommonMarginInline.java @@ -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. */ diff --git a/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java b/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java index 872d72314..964f7cd7f 100644 --- a/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java +++ b/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java @@ -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. */ diff --git a/src/java/org/apache/fop/fonts/truetype/OpenFont.java b/src/java/org/apache/fop/fonts/truetype/OpenFont.java index b736c9968..9d3a4769d 100644 --- a/src/java/org/apache/fop/fonts/truetype/OpenFont.java +++ b/src/java/org/apache/fop/fonts/truetype/OpenFont.java @@ -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> e1 : kerningTab.entrySet()) { + Integer unicodeKey1 = e1.getKey(); + Integer cidKey1 = unicodeToGlyph(unicodeKey1); Map akpx = new HashMap(); - Map ckpx = kerningTab.get(unicodeKey1); + Map ckpx = e1.getValue(); for (Map.Entry 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; } diff --git a/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java b/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java index c5f5ccc60..8d51edf25 100644 --- a/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java +++ b/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java @@ -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))); diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index 21dcf9ea9..802960c65 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -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); diff --git a/src/java/org/apache/fop/layoutmgr/FloatContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FloatContentLayoutManager.java index 5c6f6c685..06e1484cf 100644 --- a/src/java/org/apache/fop/layoutmgr/FloatContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/FloatContentLayoutManager.java @@ -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; diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java index 227acbfd3..99f6367a3 100644 --- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java @@ -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); diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java index 1f4a06ee2..5e3820a4b 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java @@ -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") } /** diff --git a/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java b/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java index 47561f3c9..342a2f33c 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java @@ -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: diff --git a/src/java/org/apache/fop/pdf/PDFCMap.java b/src/java/org/apache/fop/pdf/PDFCMap.java index 34bc0f952..c96cf9d3b 100644 --- a/src/java/org/apache/fop/pdf/PDFCMap.java +++ b/src/java/org/apache/fop/pdf/PDFCMap.java @@ -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") } /** diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java index b1152df16..ad117c9d0 100644 --- a/src/java/org/apache/fop/pdf/PDFFactory.java +++ b/src/java/org/apache/fop/pdf/PDFFactory.java @@ -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); + } } } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java index 1b13fd783..b9f0b501d 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java @@ -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()); diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java index 040118eb5..5af417ed5 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java @@ -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) */ diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index d6da9d57d..6c392ab4d 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -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 { diff --git a/src/java/org/apache/fop/svg/NativeTextPainter.java b/src/java/org/apache/fop/svg/NativeTextPainter.java index 126e1efc3..983a184c4 100644 --- a/src/java/org/apache/fop/svg/NativeTextPainter.java +++ b/src/java/org/apache/fop/svg/NativeTextPainter.java @@ -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. diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index 5a0299281..9af8540e8 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -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") } /** diff --git a/src/java/org/apache/fop/tools/anttasks/RunTest.java b/src/java/org/apache/fop/tools/anttasks/RunTest.java index 1b560802a..0d728ae9a 100644 --- a/src/java/org/apache/fop/tools/anttasks/RunTest.java +++ b/src/java/org/apache/fop/tools/anttasks/RunTest.java @@ -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 urls = new ArrayList(); 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()]); } } diff --git a/test/layoutengine/standard-testcases/footnote_id.xml b/test/layoutengine/standard-testcases/footnote_id.xml index e9e30e334..84593df3f 100644 --- a/test/layoutengine/standard-testcases/footnote_id.xml +++ b/test/layoutengine/standard-testcases/footnote_id.xml @@ -38,9 +38,7 @@ 1) - 1) - http://xmlgrapics.apache.org/fop/ - + 1) http://xmlgrapics.apache.org/fop/ @@ -65,6 +63,6 @@ - + - \ No newline at end of file + -- 2.39.5