]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Address low priority findbugs warnings
authorAndreas L. Delmelle <adelmelle@apache.org>
Sun, 24 May 2015 11:14:22 +0000 (11:14 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Sun, 24 May 2015 11:14:22 +0000 (11:14 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1681435 13f79535-47bb-0310-9956-ffa450edef68

25 files changed:
findbugs-exclude.xml
src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java
src/java/org/apache/fop/area/AreaTreeObject.java
src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java
src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/RowPainter.java
src/java/org/apache/fop/layoutmgr/table/TableStepper.java
src/java/org/apache/fop/render/AbstractRenderer.java
src/java/org/apache/fop/render/afp/AFPImageHandler.java
src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java
src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java
src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java
src/java/org/apache/fop/render/intermediate/IFParser.java
src/java/org/apache/fop/render/intermediate/IFRenderer.java
src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
src/java/org/apache/fop/render/pdf/extensions/PDFArrayElement.java
src/java/org/apache/fop/render/pdf/extensions/PDFDictionaryElement.java
src/java/org/apache/fop/render/pdf/extensions/PDFReferenceElement.java
src/java/org/apache/fop/render/xml/XMLRenderer.java
src/java/org/apache/fop/svg/PDFGraphics2D.java

index 37a341de0c3b452e36fc108ffca00f8b8908134b..73796c1281f91a2df7944a5a706436a23a8b9692 100644 (file)
   -->
 
   <!-- START - APPROVED EXCLUSIONS -->
+  <Match>
+    <Bug pattern="BC_BAD_CAST_TO_CONCRETE_COLLECTION"/>
+    <!-- TODO - Not sure what to do with those two... Seems messy/hacky -->
+    <And>
+      <Class name="org.apache.fop.area.AreaTreeObject"/>
+      <Method name="clone"/>
+    </And>
+  </Match>    
+  <Match>
+    <Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/>
+    <!-- TODO - See if these can be solved in a better way -->
+    <Or>
+      <And>
+        <Class name="org.apache.fop.layoutmgr.PageBreakingAlgorithm"/>
+        <Or>
+          <Method name="createFootnotePages"/>
+          <Method name="finish"/>
+        </Or>
+      </And>
+      <And>
+        <Class name="org.apache.fop.render.rtf.RTFHandler"/>
+        <Or>
+          <Method name="endCell"/>
+          <Method name="endFootnoteBody"/>
+          <Method name="endPart"/>
+          <Method name="endRow"/>
+          <Method name="startCell"/>
+          <Method name="startFootnoteBody"/>
+          <Method name="startListItem"/>
+          <Method name="startListLabel"/>
+          <Method name="startPart"/>
+          <Method name="startRow"/>
+        </Or>
+      </And>
+    </Or>
+  </Match>
   <Match>
     <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
     <Or>
index 54826a2ec50e9e9a34d21ed155b9b025ce4845fd..f5808bda62d46401029259d1fc4c635e8d4ecd51 100644 (file)
@@ -133,7 +133,6 @@ public class GraphicsSetProcessColor extends AbstractGraphicsDrawingOrder {
             dout.writeByte(a);
             dout.writeByte(b);
         } else {
-            IOUtils.closeQuietly(dout);
             IOUtils.closeQuietly(baout);
             throw new IllegalStateException();
         }
index 83bf98b559c83257d38c0265edbfe49c7c643f9a..02d81ef0a3b6140a11945073bcccb7fac386f34d 100644 (file)
@@ -41,13 +41,18 @@ public abstract class AreaTreeObject implements Cloneable {
     protected List<ExtensionAttachment> extensionAttachments;
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     public Object clone() throws CloneNotSupportedException {
         AreaTreeObject ato = (AreaTreeObject) super.clone();
         if (foreignAttributes != null) {
-            ato.foreignAttributes = (Map) ((HashMap) foreignAttributes).clone();
+            // @SuppressFBWarnings("BC_BAD_CAST_TO_CONCRETE_COLLECTION")
+            ato.foreignAttributes = (Map<QName, String>)
+                    ((HashMap<QName, String>)foreignAttributes).clone();
         }
         if (extensionAttachments != null) {
-            ato.extensionAttachments = (List) ((ArrayList) extensionAttachments).clone();
+            // @SuppressFBWarnings("BC_BAD_CAST_TO_CONCRETE_COLLECTION")
+            ato.extensionAttachments = (List<ExtensionAttachment>)
+                    ((ArrayList<ExtensionAttachment>) extensionAttachments).clone();
         }
         return ato;
     }
index 008ec22653a99c612298b53abb25eca88b87fa5a..9327f8f8cd5e699a9a9a52ba7f9282bf05e899e0 100644 (file)
@@ -941,6 +941,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
     @Override
     protected void finish() {
         for (int i = startLine; i < endLine; i++) {
+            // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
             for (KnuthPageNode node = (KnuthPageNode) getNode(i);
                  node != null;
                  node = (KnuthPageNode) node.next) {
@@ -978,6 +979,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
                 // footnoteElementIndex has already been set in getFootnoteSplit()
             } else {
                 // cannot add any content: create a new node and start again
+                // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
                 KnuthPageNode node = (KnuthPageNode)
                                      createNode(lastNode.position, prevNode.line + 1, 1,
                                                 insertedFootnotesLength - prevNode.insertedFootnotes,
@@ -992,6 +994,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
             }
         }
         // create the last node
+        // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
         KnuthPageNode node = (KnuthPageNode)
                              createNode(lastNode.position, prevNode.line + 1, 1,
                                         totalFootnotesLength - prevNode.insertedFootnotes, 0, 0,
index 20c4616bd14fa613b9617686674b8de340be402c..7d84a91ffcec39906b8726dd5d2bfccf79229d99 100644 (file)
@@ -26,6 +26,7 @@ import java.util.List;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.fop.area.Area;
 import org.apache.fop.area.AreaTreeHandler;
 import org.apache.fop.area.AreaTreeModel;
 import org.apache.fop.area.LineArea;
@@ -112,7 +113,9 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager
             try {
                 ContentLayoutManager clm = getLayoutManagerMaker()
                     .makeContentLayoutManager(this, getPageSequence().getTitleFO());
-                title = (LineArea) clm.getParentArea(null);
+                Area parentArea = clm.getParentArea(null);
+                assert (parentArea instanceof LineArea);
+                title = (LineArea) parentArea;
             } catch (IllegalStateException e) {
                 // empty title; do nothing
             }
index 6f31f038a1475ab08089e39e07c9443b4299832f..075199e5ea2a72ef587bd92c7f6ce10d3a81772f 100644 (file)
@@ -108,7 +108,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
      * Each value holds the start and end indexes into a List of
      * inline break positions.
      */
-    private static class LineBreakPosition extends LeafPosition {
+    static class LineBreakPosition extends LeafPosition {
         private final int parIndex; // index of the Paragraph this Position refers to
         private final int startIndex; //index of the first element this Position refers to
         private final int availableShrink;
@@ -986,7 +986,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
                                     keep.getContext(),
                                     context));
                     }
-                    endIndex = ((LineBreakPosition) llPoss.getChosenPosition(i)).getLeafPos();
+                    endIndex = llPoss.getChosenPosition(i).getLeafPos();
                     // create a list of the FootnoteBodyLM handling footnotes
                     // whose citations are in this line
                     List<FootnoteBodyLayoutManager> footnoteList = FootenoteUtil.getFootnotes(
@@ -994,7 +994,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
                     List<FloatContentLayoutManager> floats = FloatContentLayoutManager.checkForFloats(seq,
                             startIndex, endIndex);
                     startIndex = endIndex + 1;
-                    LineBreakPosition lbp = (LineBreakPosition) llPoss.getChosenPosition(i);
+                    LineBreakPosition lbp = llPoss.getChosenPosition(i);
                     if (baselineOffset < 0) {
                         baselineOffset = lbp.spaceBefore + lbp.baseline;
                     }
@@ -1186,7 +1186,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager
 
     /** {@inheritDoc} */
     public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
-        LeafPosition pos = (LeafPosition)lastElement.getPosition();
+        Position lastPos = lastElement.getPosition();
+        assert (lastPos instanceof LeafPosition);
+        LeafPosition pos = (LeafPosition) lastPos;
         //if (lastElement.isPenalty()) {
         //    totalAdj += lastElement.getWidth();
         //}
@@ -1230,7 +1232,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
                     // null penalty allowing a page break between lines
                     returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
                 }
-                LineBreakPosition lbp = (LineBreakPosition) llPoss.getChosenPosition(i);
+                LineBreakPosition lbp = llPoss.getChosenPosition(i);
                 //log.debug("LLM.getChangedKnuthElements> lineWidth= "
                 // + lbp.lineWidth + " difference= " + lbp.difference);
                 //log.debug("                             shrink= "
index 49c97b7b6f096f95aeab1ce4ac2c83967564266e..54ca3e54fe20ed5b2cbf77c67726de126ea96b37 100644 (file)
@@ -24,8 +24,6 @@ import java.util.List;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import org.apache.fop.layoutmgr.Position;
-
 /**
  * Line layout possibilities.
  */
@@ -37,12 +35,12 @@ public class LineLayoutPossibilities {
     private final class Possibility {
         private int lineCount;
         private double demerits;
-        private List breakPositions;
+        private List<LineLayoutManager.LineBreakPosition> breakPositions;
 
         private Possibility(int lc, double dem) {
             lineCount = lc;
             demerits = dem;
-            breakPositions = new java.util.ArrayList(lc);
+            breakPositions = new java.util.ArrayList<LineLayoutManager.LineBreakPosition>(lc);
         }
 
         private int getLineCount() {
@@ -53,15 +51,15 @@ public class LineLayoutPossibilities {
             return demerits;
         }
 
-        private void addBreakPosition(Position pos) {
+        private void addBreakPosition(LineLayoutManager.LineBreakPosition pos) {
             // Positions are always added with index 0 because
             // they are created backward, from the last one to
             // the first one
             breakPositions.add(0, pos);
         }
 
-        private Position getBreakPosition(int i) {
-            return (Position)breakPositions.get(i);
+        private LineLayoutManager.LineBreakPosition getBreakPosition(int i) {
+            return breakPositions.get(i);
         }
     }
 
@@ -181,7 +179,7 @@ public class LineLayoutPossibilities {
      * @param pos a position
      * @param i an index into posibilities list
      */
-    public void addBreakPosition(Position pos, int i) {
+    public void addBreakPosition(LineLayoutManager.LineBreakPosition pos, int i) {
         ((Possibility)possibilitiesList.get(i)).addBreakPosition(pos);
     }
 
@@ -245,7 +243,7 @@ public class LineLayoutPossibilities {
      * @param i the break position index
      * @return the chosen position
      */
-    public Position getChosenPosition(int i) {
+    public LineLayoutManager.LineBreakPosition getChosenPosition(int i) {
         return ((Possibility)possibilitiesList.get(chosenIndex)).getBreakPosition(i);
     }
 
index 2866b80da4cef3e5d657d86cff21aa33fe868651..638460866aa9a0b6b0623e3d6d30f89eb67adc66 100644 (file)
@@ -209,7 +209,9 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
          */
         GlyphMapping lastMapping = null;
         while (posIter.hasNext()) {
-            final LeafPosition tbpNext = (LeafPosition) posIter.next();
+            Position nextPos = posIter.next();
+            assert (nextPos instanceof LeafPosition);
+            final LeafPosition tbpNext = (LeafPosition) nextPos;
             if (tbpNext == null) {
                 continue; //Ignore elements without Positions
             }
@@ -961,7 +963,9 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
         ListIterator oldListIterator = oldList.listIterator();
         KnuthElement knuthElement = (KnuthElement) oldListIterator.next();
         Position pos = knuthElement.getPosition();
-        LeafPosition leafPos = (LeafPosition) pos.getPosition(depth);
+        Position innerPosition = pos.getPosition(depth);
+        assert (innerPosition instanceof LeafPosition);
+        LeafPosition leafPos = (LeafPosition) innerPosition;
         int index = leafPos.getLeafPos();
         //element could refer to '-1' position, for non-collapsed spaces (?)
         if (index > -1) {
@@ -1082,14 +1086,18 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
         ListIterator oldListIter;
         for (oldListIter = oldList.listIterator(); oldListIter.hasNext();) {
             Position pos = ((KnuthElement) oldListIter.next()).getPosition();
-            startPos = (LeafPosition) pos.getPosition(depth);
+            Position innerPosition = pos.getPosition(depth);
+            assert (innerPosition == null || innerPosition instanceof LeafPosition);
+            startPos = (LeafPosition) innerPosition;
             if (startPos != null && startPos.getLeafPos() != -1) {
                 break;
             }
         }
         for (oldListIter = oldList.listIterator(oldList.size()); oldListIter.hasPrevious();) {
             Position pos = ((KnuthElement) oldListIter.previous()).getPosition();
-            endPos = (LeafPosition) pos.getPosition(depth);
+            Position innerPosition = pos.getPosition(depth);
+            assert (innerPosition instanceof LeafPosition);
+            endPos = (LeafPosition) innerPosition;
             if (endPos != null && endPos.getLeafPos() != -1) {
                 break;
             }
index 4c45e62f8acdf87a75b3a02a0f2dfdfeef878bc8..40edca6f750c2423fe399fc229aeb77437778462 100644 (file)
@@ -269,6 +269,7 @@ class RowPainter {
                 } else {
                     borderAfterWhich = ConditionalBorder.REST;
                 }
+                assert (currentGU instanceof EmptyGridUnit);
                 addAreaForEmptyGridUnit((EmptyGridUnit)currentGU,
                         currentRow.getIndex(), i,
                         actualRowHeight,
index 0906e9faa4d197f6e9e6eabfc91e0496eedfd0db..7c98bd481d529822c5d07b82871246499a5842e4 100644 (file)
@@ -158,6 +158,7 @@ public class TableStepper {
         for (int i = 0; i < columnCount; i++) {
             GridUnit gu = row.getGridUnit(i);
             if (!gu.isEmpty() && gu.isPrimary()) {
+                assert (gu instanceof PrimaryGridUnit);
                 activeCellList.add(new ActiveCell((PrimaryGridUnit) gu, row, rowIndex,
                         previousRowsLength, getTableLM()));
             }
index 72a517efd3d52c4186b2afb982782e37f1c3623d..ae54e6539f45a866e438efe27336b6621aba6b7c 100644 (file)
@@ -301,6 +301,7 @@ public abstract class AbstractRenderer
         startVParea(regionReference.getCTM(), port.getClipRectangle());
         // do after starting viewport area
         if (regionReference.getRegionClass() == FO_REGION_BODY) {
+            assert (regionReference instanceof BodyRegion);
             renderBodyRegion((BodyRegion) regionReference);
         } else {
             renderRegion(regionReference);
index 6404924a1df57b3e25034adeecc2116f2974acf5..d3801c119ef10bacaf38b0efb3846cf6866fce4e 100644 (file)
@@ -31,6 +31,7 @@ import org.apache.fop.afp.AFPPaintingState;
 import org.apache.fop.afp.AFPResourceInfo;
 import org.apache.fop.afp.AFPUnitConverter;
 import org.apache.fop.render.ImageHandlerBase;
+import org.apache.fop.render.RendererContext;
 
 /**
  * A base abstract AFP image handler
@@ -71,8 +72,9 @@ public abstract class AFPImageHandler implements ImageHandlerBase {
                 (int)Math.round(position.getWidth()),
                 (int)Math.round(position.getHeight()));
 
-        AFPRendererContext rendererContext
-            = (AFPRendererContext)rendererImageInfo.getRendererContext();
+        RendererContext context = rendererImageInfo.getRendererContext();
+        assert (context instanceof AFPRendererContext);
+        AFPRendererContext rendererContext = (AFPRendererContext) context;
         AFPInfo afpInfo = rendererContext.getInfo();
         AFPPaintingState paintingState = afpInfo.getPaintingState();
 
index 2a0db08bb66b60fd2881b08c2a69a0113d7140ac..ba0b5433fb22142b5f1ae3a6e87f096727acbf40 100644 (file)
@@ -82,7 +82,9 @@ public class AFPImageHandlerGraphics2D extends AFPImageHandler implements ImageH
             throws IOException {
         AFPRenderingContext afpContext = (AFPRenderingContext)context;
 
-        AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)createDataObjectInfo();
+        AFPDataObjectInfo info = createDataObjectInfo();
+        assert (info instanceof AFPGraphicsObjectInfo);
+        AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo) info;
 
         // set resource information
 
index 7508c8ca04be9bc895fd428b515e150ad1eec8c2..e5f6f64cb2dc3b2152b986d5692afb8cc01f0fa8 100644 (file)
@@ -90,7 +90,9 @@ public class AFPImageHandlerRawJPEG extends AFPImageHandler implements ImageHand
             throws IOException {
         AFPRenderingContext afpContext = (AFPRenderingContext)context;
 
-        AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)createDataObjectInfo();
+        AFPDataObjectInfo info = createDataObjectInfo();
+        assert (info instanceof AFPImageObjectInfo);
+        AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo) info;
         AFPPaintingState paintingState = afpContext.getPaintingState();
 
         // set resource information
index aea7fe8c02dfc42a99161ebbc4b216fdb5107257..57a5143f6113e1825b0799f40c725f742a18fc8f 100644 (file)
@@ -107,7 +107,9 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima
             throws IOException {
         AFPRenderingContext afpContext = (AFPRenderingContext)context;
 
-        AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)createDataObjectInfo();
+        AFPDataObjectInfo info = createDataObjectInfo();
+        assert (info instanceof AFPImageObjectInfo);
+        AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo) info;
         AFPPaintingState paintingState = afpContext.getPaintingState();
 
         // set resource information
index 68d806a1cdf237394f52167741369b22b39ae76a..f38da91e972df1c54af5dcbccfb2544cb16e6814 100644 (file)
@@ -78,7 +78,9 @@ public class AFPImageHandlerSVG implements ImageHandler {
         ImageXMLDOM imageSVG = (ImageXMLDOM)image;
         FOUserAgent userAgent = afpContext.getUserAgent();
 
-        AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)createDataObjectInfo();
+        AFPDataObjectInfo info = createDataObjectInfo();
+        assert (info instanceof AFPGraphicsObjectInfo);
+        AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo) info;
         AFPResourceInfo resourceInfo = graphicsObjectInfo.getResourceInfo();
         setDefaultToInlineResourceLevel(graphicsObjectInfo);
 
index 30b3af9dd0daf268215ff3a8846886dea6801de0..a1c740da8efca6134109911099e954a5ff85f202 100644 (file)
@@ -43,7 +43,7 @@ import org.apache.fop.render.awt.AWTRenderer;
 public class ImageProxyPanel extends JPanel {
 
     /** The reference to the BufferedImage storing the page data */
-    private Reference imageRef;
+    private transient Reference imageRef;
 
     /** The maximum and preferred size of the panel */
     private Dimension size;
index 519726291dac488e7eca4d775993f8540a87997a..3d0bfd32f0825f69007a982847cea203e37878c0 100644 (file)
@@ -107,14 +107,16 @@ public class IFParser implements IFConstants {
 
             transformer.transform(src, res);
         } catch (TransformerException te) {
+            Throwable cause = te.getCause();
             //Unpack original IFException if applicable
-            if (te.getCause() instanceof SAXException) {
-                SAXException se = (SAXException)te.getCause();
-                if (se.getCause() instanceof IFException) {
-                    throw (IFException)se.getCause();
+            if (cause instanceof SAXException) {
+                SAXException se = (SAXException) cause;
+                cause = se.getCause();
+                if (cause instanceof IFException) {
+                    throw (IFException) cause;
                 }
-            } else if (te.getCause() instanceof IFException) {
-                throw (IFException)te.getCause();
+            } else if (cause instanceof IFException) {
+                throw (IFException) cause;
             }
             throw te;
         }
@@ -375,9 +377,10 @@ public class IFParser implements IFConstants {
         }
 
         private void handleIFException(IFException ife) throws SAXException {
-            if (ife.getCause() instanceof SAXException) {
+            Throwable cause = ife.getCause();
+            if (cause instanceof SAXException) {
                 //unwrap
-                throw (SAXException)ife.getCause();
+                throw (SAXException) cause;
             } else {
                 //wrap
                 throw new SAXException(ife);
index 176f74705c19727ef95996d146af919c2a80ae69..e0843ef7441a723ff24cfec384fbc1b4890a5dfe 100644 (file)
@@ -197,8 +197,9 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
     }
 
     private void handleIFExceptionWithIOException(IFException ife) throws IOException {
-        if (ife.getCause() instanceof IOException) {
-            throw (IOException)ife.getCause();
+        Throwable cause = ife.getCause();
+        if (cause instanceof IOException) {
+            throw (IOException) cause;
         } else {
             handleIFException(ife);
         }
@@ -1072,15 +1073,17 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
         String s = word.getWord();
 
         int[][] dp = word.getGlyphPositionAdjustments();
+        Area parentArea = word.getParentArea();
+        assert (parentArea instanceof AbstractTextArea);
         if (dp == null) {
             renderTextWithAdjustments(s, word.getLetterAdjustArray(), word.isReversed(),
-                    font, (AbstractTextArea)word.getParentArea());
+                    font, (AbstractTextArea) parentArea);
         } else if (IFUtil.isDPOnlyDX(dp)) {
             renderTextWithAdjustments(s, IFUtil.convertDPToDX(dp), word.isReversed(),
-                    font, (AbstractTextArea)word.getParentArea());
+                    font, (AbstractTextArea) parentArea);
         } else {
             renderTextWithAdjustments(s, dp, word.isReversed(),
-                    font, (AbstractTextArea)word.getParentArea());
+                    font, (AbstractTextArea) parentArea);
         }
 
         super.renderWord(word);
@@ -1091,7 +1094,9 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
         Font font = getFontFromArea(space.getParentArea());
         String s = space.getSpace();
 
-        AbstractTextArea textArea = (AbstractTextArea)space.getParentArea();
+        Area parentArea = space.getParentArea();
+        assert (parentArea instanceof AbstractTextArea);
+        AbstractTextArea textArea = (AbstractTextArea) parentArea;
         renderTextWithAdjustments(s, (int[]) null, false, font, textArea);
 
         /* COMBINED is always false
index e8da29b7dbc049d0ee754f9e39f5bf0230fe0937..df6f26c652eca58667fbf7b499a8bd0b79c44329 100644 (file)
@@ -388,6 +388,7 @@ class PDFRenderingUtil {
             } else if (type == PDFObjectType.Number) {
                 array.add(new PDFNumber(entry.getValueAsNumber()));
             } else if (type == PDFObjectType.Reference) {
+                assert (entry instanceof PDFReferenceExtension);
                 array.add(resolveReference((PDFReferenceExtension) entry));
             } else if (type == PDFObjectType.String) {
                 array.add(entry.getValue());
@@ -423,6 +424,7 @@ class PDFRenderingUtil {
             } else if (type == PDFObjectType.Number) {
                 dictionary.put(key, new PDFNumber(entry.getValueAsNumber()));
             } else if (type == PDFObjectType.Reference) {
+                assert (entry instanceof PDFReferenceExtension);
                 dictionary.put(key, resolveReference((PDFReferenceExtension) entry));
             } else if (type == PDFObjectType.String) {
                 dictionary.put(key, entry.getValue());
index 1f3ba22b248728486bc7437578f4c4b5081207fc..34b11272f40dc8c5da7c665e4e043eed69f79dd4 100644 (file)
@@ -44,8 +44,9 @@ public class PDFArrayElement extends PDFCollectionEntryElement {
     }
 
     public PDFArrayExtension getArrayExtension() {
-        assert getExtension() instanceof PDFArrayExtension;
-        return (PDFArrayExtension) getExtension();
+        PDFCollectionEntryExtension extension = getExtension();
+        assert (extension instanceof PDFArrayExtension);
+        return (PDFArrayExtension) extension;
     }
 
     @Override
index 3da2242906e09775d88699cbbf3a59ee2daf6bba..d7b155e23d3ac7f765272de95751777041663f75 100644 (file)
@@ -64,8 +64,9 @@ public class PDFDictionaryElement extends PDFCollectionEntryElement {
     }
 
     public PDFDictionaryExtension getDictionaryExtension() {
-        assert getExtension() instanceof PDFDictionaryExtension;
-        return (PDFDictionaryExtension) getExtension();
+        PDFCollectionEntryExtension extension = getExtension();
+        assert extension instanceof PDFDictionaryExtension;
+        return (PDFDictionaryExtension) extension;
     }
 
     @Override
index 37aeeb89072cafae634eb4ad8ba04f9a1a45d336..c774a09a8c4f0ba5746933ec34ee74e8f720d9b5 100644 (file)
@@ -52,7 +52,9 @@ public class PDFReferenceElement extends PDFCollectionEntryElement {
         } else if (refid.length() == 0) {
             invalidPropertyValueError(ATT_REFID, refid, null);
         } else {
-            ((PDFReferenceExtension) getExtension()).setReferenceId(refid);
+            PDFCollectionEntryExtension extension = getExtension();
+            assert (extension instanceof PDFReferenceExtension);
+            ((PDFReferenceExtension) extension).setReferenceId(refid);
         }
     }
 }
index 6c392ab4d15371f18b8237f9f53caaaf3ebf92dc..c50508edb7dddef8e4cafe161714f42e2b2b4482 100644 (file)
@@ -514,7 +514,8 @@ public class XMLRenderer extends AbstractXMLRenderer {
                 renderRegion(region);
                 endElement("regionStart");
             } else if (region.getRegionClass() == FO_REGION_BODY) {
-                BodyRegion body = (BodyRegion)region;
+                assert (region instanceof BodyRegion);
+                BodyRegion body = (BodyRegion) region;
                 if (body.getColumnCount() != 1) {
                     addAttribute("columnGap", body.getColumnGap());
                     addAttribute("columnCount", body.getColumnCount());
index 9af8540e8cf6dd4335e2c60010a7d0f9fae4dcfc..f415c54730d355f9d3926e6f0e94b6da2b538489 100644 (file)
@@ -1029,7 +1029,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
             resourceContext.addXObject(imageInfo);
         } else {
             Raster r = pctx.getRaster(devX, devY, devW, devH);
-            WritableRaster wr = (WritableRaster)r;
+            assert (r instanceof WritableRaster);
+            WritableRaster wr = (WritableRaster) r;
             wr = wr.createWritableTranslatedChild(0, 0);
 
             ColorModel pcm = pctx.getColorModel();