]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fix checkstyle and findbugs issues
authorSimon Pepping <spepping@apache.org>
Wed, 15 Jun 2011 11:04:33 +0000 (11:04 +0000)
committerSimon Pepping <spepping@apache.org>
Wed, 15 Jun 2011 11:04:33 +0000 (11:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1135995 13f79535-47bb-0310-9956-ffa450edef68

findbugs-exclude.xml
src/documentation/skinconf.xml
src/java/org/apache/fop/afp/parser/UnparsedStructuredField.java
src/java/org/apache/fop/afp/svg/AFPTextHandler.java
src/java/org/apache/fop/render/afp/extensions/ExtensionPlacement.java
src/java/org/apache/fop/render/pdf/AbstractPDFImageHandler.java
src/java/org/apache/fop/render/ps/PSRendererConfigurator.java
src/java/org/apache/fop/render/rtf/RTFHandler.java
src/java/org/apache/fop/svg/ACIUtils.java

index 318fb06cc1fe9fbef14c85c5e211477e2fc0fa16..67220fc1e695b8691cd1a55d501c997840dfa773 100644 (file)
       <Bug pattern="NM_CONFUSING"/>
    </Match>
    <!-- /The names of public methods will not be modified -->
+   <!-- These casts are checked in the code -->
+   <Match>
+        <Class name="org.apache.fop.render.afp.AFPImageHandlerGraphics2D"/>
+        <Method name="isCompatible"/>
+        <Bug pattern="BC_UNCONFIRMED_CAST"/>
+   </Match>
+   <Match>
+        <Class name="org.apache.fop.render.afp.AFPImageHandlerSVG"/>
+        <Method name="isCompatible"/>
+        <Bug pattern="BC_UNCONFIRMED_CAST"/>
+   </Match>
+   <Match>
+        <Class name="org.apache.fop.render.afp.AbstractPDFImageHandler"/>
+        <Method name="handleImage"/>
+        <Bug pattern="BC_UNCONFIRMED_CAST"/>
+   </Match>
+   <!-- /These casts are checked in the code -->
+   <!-- return null is OK -->
+   <Match>
+        <Class name="org.apache.fop.svg.ACIUtils"/>
+        <Method name="findFontsForBatikACI"/>
+        <Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
+   </Match>
    <!-- Automatically generated list of exclusions -->
    <Match>
       <Class name="org.apache.fop.area.BodyRegion"/>
index 8190982e36accf51651589ef1753a58cae358cf6..7a15fce724ee82fcf23080f34b4676e8885186d7 100644 (file)
@@ -103,9 +103,8 @@ which will be used to configure the chosen Forrest skin.
     For some skins just set the attributes to blank.
   -->
   <trail location="alt">
-    <link1 name="apache.org" href="http://www.apache.org/"/>
-    <link2 name="XML Federation" href="http://xml.apache.org/"/>
-    <link3 name="xmlgraphics.apache.org" href="http://xmlgraphics.apache.org/"/>
+    <link1 name="The Apache Software Foundation" href="http://www.apache.org/"/>
+    <link2 name="Apache XML Graphics Project" href="http://xmlgraphics.apache.org/"/>
   </trail>
 
   <!-- Configure the TOC, i.e. the Table of Contents.
index 4f782c5b1e3a55ace6f77129d4a087551d0a3fea..0e2eeeb0c4c3f0303f9e06aca17072920d473bda 100644 (file)
@@ -219,7 +219,7 @@ public final class UnparsedStructuredField {
     */
    byte[] getExtData() {
        if (this.extData == null) {
-           return null;
+           return new byte[0];
        }
        byte[] rtn = new byte[this.extData.length];
        System.arraycopy(this.extData, 0, rtn, 0, rtn.length);
@@ -232,7 +232,7 @@ public final class UnparsedStructuredField {
     */
    public byte[] getData() {
        if (this.data == null) {
-           return null;
+           return new byte[0];
        }
        byte[] rtn = new byte[this.data.length];
        System.arraycopy(this.data, 0, rtn, 0, rtn.length);
index 4f340c151776d850e4de444d1eea229c5ee54066..eb75e33ffefdb86a8e1dd9b585edf0ccb70d4b4d 100644 (file)
@@ -60,6 +60,7 @@ public class AFPTextHandler extends FOPTextHandlerAdapter {
      * Main constructor.
      *
      * @param fontInfo the AFPGraphics2D instance
+     * @param resourceManager the AFPResourceManager instance
      */
     public AFPTextHandler(FontInfo fontInfo, AFPResourceManager resourceManager) {
         this.fontInfo = fontInfo;
index 7d312033367be7d3971a3e413cd9e8ff4be2e9a6..9c593d52fb2e030f00d975724dc7dcad7d5ce003 100644 (file)
@@ -19,6 +19,8 @@
 
 package org.apache.fop.render.afp.extensions;
 
+import java.util.Locale;
+
 /**
  * An enumeration for placement instruction for AFP extensions.
  */
@@ -34,7 +36,7 @@ public enum ExtensionPlacement {
      * @return the XML value
      */
     public String getXMLValue() {
-        String xmlName = name().toLowerCase();
+        String xmlName = name().toLowerCase(Locale.ENGLISH);
         xmlName = xmlName.replace('_', '-');
         return xmlName;
     }
@@ -45,7 +47,7 @@ public enum ExtensionPlacement {
      * @return the enum value
      */
     public static ExtensionPlacement fromXMLValue(String value) {
-        String name = value.toUpperCase();
+        String name = value.toUpperCase(Locale.ENGLISH);
         name = name.replace('-', '_');
         return ExtensionPlacement.valueOf(name);
     }
index c03d4593ca57951094ce4fe7e54665bd12ce186a..5bc83fee34f26c57f6e3fba6277a7fcec025a38d 100644 (file)
@@ -39,6 +39,7 @@ abstract class AbstractPDFImageHandler implements ImageHandler {
     /** {@inheritDoc} */
     public void handleImage(RenderingContext context, Image image, Rectangle pos)
             throws IOException {
+        assert context instanceof PDFRenderingContext;
         PDFRenderingContext pdfContext = (PDFRenderingContext)context;
         PDFContentGenerator generator = pdfContext.getGenerator();
         PDFImage pdfimage = createPDFImage(image, image.getInfo().getOriginalURI());
index 68f7e9d620c33c556bfbb9f9122ac66605b3af9b..00f3fc154306fb932c48c9366da69330ed8fe961 100644 (file)
@@ -19,6 +19,8 @@
 
 package org.apache.fop.render.ps;
 
+import java.util.Locale;
+
 import org.apache.avalon.framework.configuration.Configuration;
 
 import org.apache.xmlgraphics.ps.PSGenerator;
@@ -69,7 +71,8 @@ public class PSRendererConfigurator extends PrintRendererConfigurator
         child = cfg.getChild("rendering");
         if (child != null) {
             psUtil.setRenderingMode(PSRenderingMode.valueOf(
-                    child.getValue(psUtil.getRenderingMode().toString()).toUpperCase()));
+                    child.getValue(psUtil.getRenderingMode().toString())
+                    .toUpperCase(Locale.ENGLISH)));
         }
         psUtil.setSafeSetPageDevice(
             cfg.getChild("safe-set-page-device").getValueAsBoolean(false));
index 9597c153211b0f6119d8eb8e1fcfc331c488b9e5..ac060caffc13e55845b8f68ead527b49e51f360c 100644 (file)
@@ -100,6 +100,7 @@ import org.apache.fop.layoutmgr.inline.ImageLayout;
 import org.apache.fop.layoutmgr.table.ColumnSetup;
 import org.apache.fop.render.DefaultFontResolver;
 import org.apache.fop.render.RendererEventProducer;
+import org.apache.fop.render.rtf.rtflib.exceptions.RtfException;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfAfterContainer;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfBeforeContainer;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfListContainer;
@@ -1448,7 +1449,7 @@ public class RTFHandler extends FOEventHandler {
             throw new RuntimeException(e.getMessage());
         }
     }
-    
+
     /** {@inheritDoc} */
     public void startPageNumberCitationLast(PageNumberCitationLast l) {
         if (bDefer) {
@@ -1463,7 +1464,10 @@ public class RTFHandler extends FOEventHandler {
 
             textrun.addPageNumberCitation(l.getRefId());
 
-        } catch (Exception e) {
+        } catch (RtfException e) {
+            log.error("startPageNumberCitationLast: " + e.getMessage());
+            throw new RuntimeException(e.getMessage());
+        } catch (IOException e) {
             log.error("startPageNumberCitationLast: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
         }
index 92dd3f16ffcf683b4c7f92736c3e6aa22140b7ac..91361432ae39eda03c0755e3d5a1b4375106335b 100644 (file)
@@ -79,24 +79,19 @@ public final class ACIUtils {
         GVTFont gvtFont = (GVTFont)aci.getAttribute(
                 GVTAttributedCharacterIterator.TextAttribute.GVT_FONT);
         if (gvtFont != null) {
-            try {
-                String gvtFontFamily = gvtFont.getFamilyName(); //Not available in Batik 1.6!
-                if (fontInfo.hasFont(gvtFontFamily, style, weight)) {
-                    FontTriplet triplet = fontInfo.fontLookup(gvtFontFamily, style,
-                                                       weight);
-                    Font f = fontInfo.getFontInstance(triplet, fsize);
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Found a font that matches the GVT font: "
-                                + gvtFontFamily + ", " + weight + ", " + style
-                                + " -> " + f);
-                    }
-                    fonts.add(f);
+            String gvtFontFamily = gvtFont.getFamilyName();
+            if (fontInfo.hasFont(gvtFontFamily, style, weight)) {
+                FontTriplet triplet = fontInfo.fontLookup(gvtFontFamily, style,
+                                                          weight);
+                Font f = fontInfo.getFontInstance(triplet, fsize);
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Found a font that matches the GVT font: "
+                              + gvtFontFamily + ", " + weight + ", " + style
+                              + " -> " + f);
                 }
-                firstFontFamily = gvtFontFamily;
-            } catch (Exception e) {
-                //Most likely NoSuchMethodError here when using Batik 1.6
-                //Just skip this section in this case
+                fonts.add(f);
             }
+            firstFontFamily = gvtFontFamily;
         }
 
         if (gvtFonts != null) {