From: Glenn Adams Date: Sun, 10 Aug 2014 06:55:01 +0000 (+0000) Subject: Fix or suppress 5- to 9-instance findbug warnings. X-Git-Tag: fop-2_0~80 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5f66eef3fe635d61f3e6408d101a87b57409aa5c;p=xmlgraphics-fop.git Fix or suppress 5- to 9-instance findbug warnings. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1617052 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/findbugs-exclude.xml b/findbugs-exclude.xml index 2deaa263f..246e7b031 100644 --- a/findbugs-exclude.xml +++ b/findbugs-exclude.xml @@ -1,22 +1,149 @@ + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -29,10 +156,6 @@ - - - - @@ -49,36 +172,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -91,18 +188,6 @@ - - - - - - - - - - - - @@ -115,10 +200,6 @@ - - - - @@ -127,23 +208,6 @@ - - - - - - - - - - - - - - - - - @@ -152,22 +216,6 @@ - - - - - - - - - - - - - - - - @@ -176,12 +224,6 @@ - - - - - - - - + + diff --git a/src/java/org/apache/fop/afp/AFPGraphics2D.java b/src/java/org/apache/fop/afp/AFPGraphics2D.java index 3fc70f3a4..f6db94458 100644 --- a/src/java/org/apache/fop/afp/AFPGraphics2D.java +++ b/src/java/org/apache/fop/afp/AFPGraphics2D.java @@ -32,7 +32,6 @@ import java.awt.Paint; import java.awt.Rectangle; import java.awt.Shape; import java.awt.Stroke; -import java.awt.TexturePaint; import java.awt.geom.AffineTransform; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; @@ -333,14 +332,14 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand return true; } LOG.debug("NYI: applyPaint() " + paint + " fill=" + fill); - if (paint instanceof TexturePaint) { +// if (paint instanceof TexturePaint) { // TexturePaint texturePaint = (TexturePaint)paint; // BufferedImage bufferedImage = texturePaint.getImage(); // AffineTransform at = paintingState.getTransform(); // int x = (int)Math.round(at.getTranslateX()); // int y = (int)Math.round(at.getTranslateY()); // drawImage(bufferedImage, x, y, null); - } +// } return false; } diff --git a/src/java/org/apache/fop/afp/AFPPaintingState.java b/src/java/org/apache/fop/afp/AFPPaintingState.java index 5a606dfdf..349ecc2dc 100644 --- a/src/java/org/apache/fop/afp/AFPPaintingState.java +++ b/src/java/org/apache/fop/afp/AFPPaintingState.java @@ -20,6 +20,8 @@ package org.apache.fop.afp; import java.awt.Point; +import java.io.IOException; +import java.io.ObjectInputStream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -34,8 +36,7 @@ import org.apache.fop.util.AbstractPaintingState; * This keeps information about the current painting state when writing to an * AFP datastream. */ -public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState implements - Cloneable { +public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState { private static final long serialVersionUID = 8206711712452344473L; @@ -57,7 +58,7 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState private float bitmapEncodingQuality; /** color image handler */ - private transient ColorConverter colorConverter = GrayScaleColorConverter.getInstance(); + private transient ColorConverter colorConverter; /** * true if certain image formats may be embedded unchanged in their native @@ -98,13 +99,23 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState private boolean fs45; /** the current page */ - private transient AFPPagePaintingState pagePaintingState = new AFPPagePaintingState(); + private transient AFPPagePaintingState pagePaintingState; // /** reference orientation */ // private int orientation = 0; /** a unit converter */ - private final transient AFPUnitConverter unitConv = new AFPUnitConverter(this); + private final transient AFPUnitConverter unitConv; + + public AFPPaintingState() { + colorConverter = GrayScaleColorConverter.getInstance(); + pagePaintingState = new AFPPagePaintingState(); + unitConv = new AFPUnitConverter(this); + } + + private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { + ois.defaultReadObject(); + } /** * Sets the rotation to be used for portrait pages, valid values are 0 @@ -722,6 +733,7 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState /** * Block level state data */ + // @SuppressFBWarnings("SE_INNER_CLASS") private class AFPData extends org.apache.fop.util.AbstractPaintingState.AbstractData { private static final long serialVersionUID = -1789481244175275686L; diff --git a/src/java/org/apache/fop/afp/apps/FontPatternExtractor.java b/src/java/org/apache/fop/afp/apps/FontPatternExtractor.java index 66150dda3..478c7dcd7 100644 --- a/src/java/org/apache/fop/afp/apps/FontPatternExtractor.java +++ b/src/java/org/apache/fop/afp/apps/FontPatternExtractor.java @@ -67,7 +67,9 @@ public class FontPatternExtractor { DataInputStream din = new DataInputStream(bin); long len = din.readInt() & 0xFFFFFFFFL; println("Length: " + len); - din.skip(4); //checksum + if (din.skip(4) != 4) { //checksum + throw new IOException("premature EOF when skipping checksum"); + } int tidLen = din.readUnsignedShort() - 2; byte[] tid = new byte[tidLen]; din.readFully(tid); diff --git a/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java b/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java index 9db13995a..5a5bab771 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java @@ -30,7 +30,7 @@ import org.apache.fop.afp.util.BinaryUtils; public final class GraphicsChainedSegment extends AbstractGraphicsDrawingOrderContainer { /** The maximum segment data length */ - protected static final int MAX_DATA_LEN = 8192; + public static final int MAX_DATA_LEN = 8192; private byte[] predecessorNameBytes; private boolean appended; diff --git a/src/java/org/apache/fop/afp/ioca/IDEStructureParameter.java b/src/java/org/apache/fop/afp/ioca/IDEStructureParameter.java index ba616def4..8256f986f 100644 --- a/src/java/org/apache/fop/afp/ioca/IDEStructureParameter.java +++ b/src/java/org/apache/fop/afp/ioca/IDEStructureParameter.java @@ -43,7 +43,7 @@ public class IDEStructureParameter implements Streamable { private boolean subtractive; /** setting for GRAYCODE flag */ - private boolean grayCoding; + // private boolean grayCoding; // never written /** the image color model */ private byte colorModel = COLOR_MODEL_RGB; @@ -133,9 +133,11 @@ public class IDEStructureParameter implements Streamable { if (subtractive) { flags |= 1 << 7; } + /* graCoding is never written if (grayCoding) { flags |= 1 << 6; } + */ DataOutputStream dout = new DataOutputStream(os); dout.writeByte(0x9B); //ID diff --git a/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java b/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java index f52ede652..667faca80 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java +++ b/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java @@ -26,14 +26,12 @@ import java.util.Iterator; import org.apache.fop.afp.Completable; import org.apache.fop.afp.Factory; -import org.apache.fop.afp.Streamable; /** * An abstract container of resource objects */ -public abstract class AbstractResourceGroupContainer extends AbstractPageObject -implements Streamable { +public abstract class AbstractResourceGroupContainer extends AbstractPageObject { /** The container started state */ protected boolean started; diff --git a/src/java/org/apache/fop/afp/modca/ObjectAreaPosition.java b/src/java/org/apache/fop/afp/modca/ObjectAreaPosition.java index 8d8d7d951..016d74107 100644 --- a/src/java/org/apache/fop/afp/modca/ObjectAreaPosition.java +++ b/src/java/org/apache/fop/afp/modca/ObjectAreaPosition.java @@ -42,8 +42,8 @@ public class ObjectAreaPosition extends AbstractAFPObject { private final int x; private final int y; private final int rotation; - private int xOffset; - private int yOffset; + // private int xOffset; // never written + // private int yOffset; // never written private byte refCSys = 0x01; //Page or overlay coordinate system /** @@ -108,12 +108,12 @@ public class ObjectAreaPosition extends AbstractAFPObject { byte yorient = (byte)(rotation / 2 + 45); data[19] = yorient; // YoaOrent - byte[] xoffset = BinaryUtils.convert(xOffset, 3); + byte[] xoffset = BinaryUtils.convert(/*xOffset*/ 0, 3); data[22] = xoffset[0]; // XocaOSet data[23] = xoffset[1]; data[24] = xoffset[2]; - byte[] yoffset = BinaryUtils.convert(yOffset, 3); + byte[] yoffset = BinaryUtils.convert(/*yOffset*/ 0, 3); data[25] = yoffset[0]; // YocaOSet data[26] = yoffset[1]; data[27] = yoffset[2]; @@ -136,7 +136,7 @@ public class ObjectAreaPosition extends AbstractAFPObject { + ", y=" + y + ", rotation=" + rotation + ", rotation=" + rotation - + ", xOffset=" + xOffset - + ", yOffset=" + yOffset; + + ", xOffset=" + /*xOffset*/ 0 + + ", yOffset=" + /*yOffset*/ 0; } } diff --git a/src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java b/src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java index db9b5e1c9..db254273e 100644 --- a/src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java +++ b/src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java @@ -21,7 +21,6 @@ package org.apache.fop.afp.modca; import java.io.IOException; import java.io.OutputStream; -import java.util.List; import org.apache.fop.afp.Completable; @@ -35,7 +34,8 @@ public class ResourceEnvironmentGroup extends AbstractEnvironmentGroup implement private static final String DEFAULT_NAME = "REG00001"; /** the pre-process presentation objects contained in this resource environment group */ - private List/**/ preProcessPresentationObjects; + // never written + // private List/**/ preProcessPresentationObjects; /** the resource environment group state */ private boolean complete; @@ -47,13 +47,15 @@ public class ResourceEnvironmentGroup extends AbstractEnvironmentGroup implement this(DEFAULT_NAME); } - private List/**/ getPreprocessPresentationObjects() { + /* not used + private List getPreprocessPresentationObjects() { if (preProcessPresentationObjects == null) { this.preProcessPresentationObjects - = new java.util.ArrayList/**/(); + = new java.util.ArrayList(); } return this.preProcessPresentationObjects; } + */ /** * Constructor for the ResourceEnvironmentGroup, this takes a @@ -92,7 +94,7 @@ public class ResourceEnvironmentGroup extends AbstractEnvironmentGroup implement protected void writeContent(OutputStream os) throws IOException { writeObjects(mapDataResources, os); writeObjects(mapPageOverlays, os); - writeObjects(preProcessPresentationObjects, os); + // writeObjects(preProcessPresentationObjects, os); always empty list } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/area/Block.java b/src/java/org/apache/fop/area/Block.java index 337d1fb37..e04a5dc43 100644 --- a/src/java/org/apache/fop/area/Block.java +++ b/src/java/org/apache/fop/area/Block.java @@ -19,9 +19,10 @@ package org.apache.fop.area; +import java.io.IOException; +import java.io.ObjectInputStream; import java.util.Locale; - // block areas hold either more block areas or line // areas can also be used as a block spacer // a block area may have children positioned by stacking @@ -63,12 +64,20 @@ public class Block extends BlockParent { private int positioning = STACK; /** if true, allow BPD update */ - protected transient boolean allowBPDUpdate = true; + protected transient boolean allowBPDUpdate; private Locale locale; private String location; + public Block() { + allowBPDUpdate = true; + } + + private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { + ois.defaultReadObject(); + } + /** * Add the block to this block area. * diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java index 8debd1e3d..3213eb588 100644 --- a/src/java/org/apache/fop/area/LineArea.java +++ b/src/java/org/apache/fop/area/LineArea.java @@ -44,6 +44,7 @@ public class LineArea extends Area { * that can be used in order to re-compute adjustement and / or indents when a * page-number or a page-number-citation is resolved */ + // @SuppressFBWarnings("SE_INNER_CLASS") private final class LineAdjustingInfo implements Serializable { private static final long serialVersionUID = -6103629976229458273L; diff --git a/src/java/org/apache/fop/area/LinkResolver.java b/src/java/org/apache/fop/area/LinkResolver.java index 0d5672e2b..a300bffa9 100644 --- a/src/java/org/apache/fop/area/LinkResolver.java +++ b/src/java/org/apache/fop/area/LinkResolver.java @@ -19,6 +19,8 @@ package org.apache.fop.area; +import java.io.IOException; +import java.io.ObjectInputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -35,6 +37,10 @@ public class LinkResolver implements Resolvable, Serializable { private Area area; private transient List dependents; + public LinkResolver() { + this(null, null); + } + /** * Create a new link resolver. * @@ -46,6 +52,10 @@ public class LinkResolver implements Resolvable, Serializable { area = a; } + private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { + ois.defaultReadObject(); + } + /** * @return true if this link is resolved */ diff --git a/src/java/org/apache/fop/area/inline/AbstractTextArea.java b/src/java/org/apache/fop/area/inline/AbstractTextArea.java index 0a4b2b504..c2c4fe67b 100644 --- a/src/java/org/apache/fop/area/inline/AbstractTextArea.java +++ b/src/java/org/apache/fop/area/inline/AbstractTextArea.java @@ -31,6 +31,7 @@ public abstract class AbstractTextArea extends InlineParent { * that can be used in order to re-compute adjustments when a * page-number or a page-number-citation is resolved */ + // @SuppressFBWarnings("SE_INNER_CLASS") protected class TextAdjustingInfo extends InlineAdjustingInfo { private static final long serialVersionUID = -2412095162983479947L; diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java index 8994663a2..945d1ff4e 100644 --- a/src/java/org/apache/fop/area/inline/InlineArea.java +++ b/src/java/org/apache/fop/area/inline/InlineArea.java @@ -41,6 +41,7 @@ public class InlineArea extends Area { * that can be used in order to re-compute adjustments when a * page-number or a page-number-citation is resolved */ + // @SuppressFBWarnings("SE_INNER_CLASS") protected class InlineAdjustingInfo implements Serializable { private static final long serialVersionUID = -5601387735459712149L; diff --git a/src/java/org/apache/fop/area/inline/InlineParent.java b/src/java/org/apache/fop/area/inline/InlineParent.java index c65c803c3..2e03f4d80 100644 --- a/src/java/org/apache/fop/area/inline/InlineParent.java +++ b/src/java/org/apache/fop/area/inline/InlineParent.java @@ -19,6 +19,8 @@ package org.apache.fop.area.inline; +import java.io.IOException; +import java.io.ObjectInputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -51,6 +53,10 @@ public class InlineParent extends InlineArea { */ private int maxAfterEdge; + private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { + ois.defaultReadObject(); + } + @Override public void addChildArea(Area c) { assert c instanceof InlineArea; diff --git a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java index 64d79b536..2d5845718 100644 --- a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java +++ b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java @@ -19,6 +19,8 @@ package org.apache.fop.area.inline; +import java.io.IOException; +import java.io.ObjectInputStream; import java.util.List; import org.apache.fop.area.PageViewport; @@ -49,6 +51,10 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable { //Transient fields private transient Font font; + public UnresolvedPageNumber() { + this(null, null, FIRST); + } + /** * Create a new unresolved page number. * @@ -74,6 +80,10 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable { pageType = type; } + private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { + ois.defaultReadObject(); + } + /** * Get the id references for this area. * diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java index 325dc6703..6e9eeabdc 100644 --- a/src/java/org/apache/fop/cli/CommandLineOptions.java +++ b/src/java/org/apache/fop/cli/CommandLineOptions.java @@ -397,6 +397,7 @@ public class CommandLineOptions { i = i + parseUnknownOption(args, i); } else { printUsage(System.err); + // @SuppressFBWarnings("DM_EXIT") System.exit(1); } } @@ -702,6 +703,7 @@ public class CommandLineOptions { for (int j = 0; j < mimes.length; j++) { System.out.println(" " + mimes[j]); } + // @SuppressFBWarnings("DM_EXIT") System.exit(0); } } diff --git a/src/java/org/apache/fop/cli/Main.java b/src/java/org/apache/fop/cli/Main.java index 648313efd..b4c294e6e 100644 --- a/src/java/org/apache/fop/cli/Main.java +++ b/src/java/org/apache/fop/cli/Main.java @@ -144,6 +144,7 @@ public final class Main { } catch (Exception e) { System.err.println("Unable to start FOP:"); e.printStackTrace(); + // @SuppressFBWarnings("DM_EXIT") System.exit(-1); } } @@ -166,6 +167,7 @@ public final class Main { try { options = new CommandLineOptions(); if (!options.parse(args)) { + // @SuppressFBWarnings("DM_EXIT") System.exit(0); } diff --git a/src/java/org/apache/fop/datatypes/URISpecification.java b/src/java/org/apache/fop/datatypes/URISpecification.java index b1a1d84d4..9beb817d0 100644 --- a/src/java/org/apache/fop/datatypes/URISpecification.java +++ b/src/java/org/apache/fop/datatypes/URISpecification.java @@ -61,9 +61,11 @@ public final class URISpecification { private static final String PUNCT = ",;:$&+="; private static final String RESERVED = PUNCT + "?/[]@"; + /* not used private static boolean isValidURIChar(char ch) { return true; } + */ private static boolean isDigit(char ch) { return (ch >= '0' && ch <= '9'); diff --git a/src/java/org/apache/fop/datatypes/ValidationPercentBaseContext.java b/src/java/org/apache/fop/datatypes/ValidationPercentBaseContext.java index fe9caf5fe..e13d7d980 100644 --- a/src/java/org/apache/fop/datatypes/ValidationPercentBaseContext.java +++ b/src/java/org/apache/fop/datatypes/ValidationPercentBaseContext.java @@ -47,13 +47,10 @@ public final class ValidationPercentBaseContext implements PercentBaseContext { return 100000; } - private static PercentBaseContext pseudoContextForValidation; + private static PercentBaseContext pseudoContextForValidation = new ValidationPercentBaseContext(); /** @return a base context for validation purposes. See class description. */ public static PercentBaseContext getPseudoContext() { - if (pseudoContextForValidation == null) { - pseudoContextForValidation = new ValidationPercentBaseContext(); - } return pseudoContextForValidation; } diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index 937fc62e3..b4c91da5a 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -287,62 +287,61 @@ public final class FOPropertyMapping implements Constants { return enums[enumValue]; } + static { + /* this method was never called before */ + generics = new PropertyMaker[PROPERTY_COUNT + 1]; + FOPropertyMapping gp = new FOPropertyMapping(); + + /* Create the shorthand first. They are + * referenced by the real properties. + */ + gp.createShorthandProperties(); + gp.createGenerics(); + gp.createAccessibilityProperties(); + gp.createAbsolutePositionProperties(); + gp.createAuralProperties(); + gp.createBorderPaddingBackgroundProperties(); + gp.createFontProperties(); + gp.createHyphenationProperties(); + gp.createMarginBlockProperties(); + gp.createMarginInlineProperties(); + gp.createRelativePosProperties(); + gp.createAreaAlignmentProperties(); + gp.createAreaDimensionProperties(); + gp.createBlockAndLineProperties(); + gp.createCharacterProperties(); + gp.createColorProperties(); + gp.createFloatProperties(); + gp.createKeepsAndBreaksProperties(); + gp.createLayoutProperties(); + gp.createLeaderAndRuleProperties(); + gp.createDynamicProperties(); + gp.createMarkersProperties(); + gp.createNumberToStringProperties(); + gp.createPaginationAndLayoutProperties(); + gp.createTableProperties(); + gp.createWritingModeProperties(); + gp.createMiscProperties(); + + // Hardcode the subproperties. + addSubpropMakerName("length", CP_LENGTH); + addSubpropMakerName("conditionality", CP_CONDITIONALITY); + addSubpropMakerName("block-progression-direction", CP_BLOCK_PROGRESSION_DIRECTION); + addSubpropMakerName("inline-progression-direction", CP_INLINE_PROGRESSION_DIRECTION); + addSubpropMakerName("within-line", CP_WITHIN_LINE); + addSubpropMakerName("within-column", CP_WITHIN_COLUMN); + addSubpropMakerName("within-page", CP_WITHIN_PAGE); + addSubpropMakerName("minimum", CP_MINIMUM); + addSubpropMakerName("maximum", CP_MAXIMUM); + addSubpropMakerName("optimum", CP_OPTIMUM); + addSubpropMakerName("precedence", CP_PRECEDENCE); + } + /** * Return the array of Makers. * @return the maker array. */ public static PropertyMaker[] getGenericMappings() { - - if (generics == null) { - /* this method was never called before */ - generics = new PropertyMaker[PROPERTY_COUNT + 1]; - FOPropertyMapping gp = new FOPropertyMapping(); - - /* Create the shorthand first. They are - * referenced by the real properties. - */ - gp.createShorthandProperties(); - gp.createGenerics(); - gp.createAccessibilityProperties(); - gp.createAbsolutePositionProperties(); - gp.createAuralProperties(); - gp.createBorderPaddingBackgroundProperties(); - gp.createFontProperties(); - gp.createHyphenationProperties(); - gp.createMarginBlockProperties(); - gp.createMarginInlineProperties(); - gp.createRelativePosProperties(); - gp.createAreaAlignmentProperties(); - gp.createAreaDimensionProperties(); - gp.createBlockAndLineProperties(); - gp.createCharacterProperties(); - gp.createColorProperties(); - gp.createFloatProperties(); - gp.createKeepsAndBreaksProperties(); - gp.createLayoutProperties(); - gp.createLeaderAndRuleProperties(); - gp.createDynamicProperties(); - gp.createMarkersProperties(); - gp.createNumberToStringProperties(); - gp.createPaginationAndLayoutProperties(); - gp.createTableProperties(); - gp.createWritingModeProperties(); - gp.createMiscProperties(); - - // Hardcode the subproperties. - addSubpropMakerName("length", CP_LENGTH); - addSubpropMakerName("conditionality", CP_CONDITIONALITY); - addSubpropMakerName("block-progression-direction", CP_BLOCK_PROGRESSION_DIRECTION); - addSubpropMakerName("inline-progression-direction", CP_INLINE_PROGRESSION_DIRECTION); - addSubpropMakerName("within-line", CP_WITHIN_LINE); - addSubpropMakerName("within-column", CP_WITHIN_COLUMN); - addSubpropMakerName("within-page", CP_WITHIN_PAGE); - addSubpropMakerName("minimum", CP_MINIMUM); - addSubpropMakerName("maximum", CP_MAXIMUM); - addSubpropMakerName("optimum", CP_OPTIMUM); - addSubpropMakerName("precedence", CP_PRECEDENCE); - } - // @SuppressFBWarnings("MS_EXPOSE_REP") return generics; } diff --git a/src/java/org/apache/fop/fo/NullCharIterator.java b/src/java/org/apache/fop/fo/NullCharIterator.java index db872caec..0c796fe73 100644 --- a/src/java/org/apache/fop/fo/NullCharIterator.java +++ b/src/java/org/apache/fop/fo/NullCharIterator.java @@ -26,16 +26,13 @@ import java.util.NoSuchElementException; */ public class NullCharIterator extends CharIterator { - private static CharIterator instance; + private static CharIterator instance = new NullCharIterator(); /** * Obtain the singleton instance of the null character iterator. * @return the char iterator */ public static CharIterator getInstance() { - if (instance == null) { - instance = new NullCharIterator(); - } return instance; } diff --git a/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java b/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java index a4438d1bd..f9b4cd87d 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java +++ b/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java @@ -333,6 +333,7 @@ class PropertyTokenizer { * as defined by XSL (space, newline, CR, tab). * @param c The character to check */ + /* not used private static boolean isSpace(char c) { switch (c) { case ' ': @@ -344,6 +345,7 @@ class PropertyTokenizer { return false; } } + */ /** * Return a boolean value indicating whether the argument is a valid name diff --git a/src/java/org/apache/fop/fo/flow/Marker.java b/src/java/org/apache/fop/fo/flow/Marker.java index 8abf3d992..4a2ea64fc 100644 --- a/src/java/org/apache/fop/fo/flow/Marker.java +++ b/src/java/org/apache/fop/fo/flow/Marker.java @@ -361,13 +361,13 @@ public class Marker extends FObjMixed { = new PropertyCache(); /** namespace */ - protected String namespace; + private String namespace; /** qualfied name */ - protected String qname; + private String qname; /** local name */ - protected String name; + private String name; /** value */ - protected String value; + private String value; /** * Main constructor diff --git a/src/java/org/apache/fop/fo/properties/ColorProperty.java b/src/java/org/apache/fop/fo/properties/ColorProperty.java index f577cbeec..131c5a692 100644 --- a/src/java/org/apache/fop/fo/properties/ColorProperty.java +++ b/src/java/org/apache/fop/fo/properties/ColorProperty.java @@ -38,7 +38,7 @@ public final class ColorProperty extends Property { /** * The color represented by this property. */ - protected final Color color; + private final Color color; /** diff --git a/src/java/org/apache/fop/fo/properties/PropertyMaker.java b/src/java/org/apache/fop/fo/properties/PropertyMaker.java index 845b79a1d..a315944b1 100644 --- a/src/java/org/apache/fop/fo/properties/PropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/PropertyMaker.java @@ -510,12 +510,6 @@ public class PropertyMaker implements Cloneable { } } } - if (pret != null) { - /* - * log.debug("Return shorthand value " + pret.getString() + - * " for " + getPropName()); - */ - } return pret; } diff --git a/src/java/org/apache/fop/fonts/FontCache.java b/src/java/org/apache/fop/fonts/FontCache.java index 9134cf702..1f5b96b80 100644 --- a/src/java/org/apache/fop/fonts/FontCache.java +++ b/src/java/org/apache/fop/fonts/FontCache.java @@ -84,11 +84,8 @@ public final class FontCache implements Serializable { */ private Map failedFontMap; - /** - * Default constructor - */ - public FontCache() { - //nop + private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { + ois.defaultReadObject(); } private static File getUserHome() { diff --git a/src/java/org/apache/fop/fonts/FontReader.java b/src/java/org/apache/fop/fonts/FontReader.java index bd64a7595..9f5d54396 100644 --- a/src/java/org/apache/fop/fonts/FontReader.java +++ b/src/java/org/apache/fop/fonts/FontReader.java @@ -294,7 +294,7 @@ public class FontReader extends DefaultHandler { multiFont.setWidthArray(wds); } else if ("bfranges".equals(localName)) { - multiFont.setCMap(bfranges.toArray(new CMapSegment[0])); + multiFont.setCMap(bfranges.toArray(new CMapSegment[bfranges.size()])); } text.setLength(0); //Reset text buffer (see characters()) } diff --git a/src/java/org/apache/fop/fonts/FontTriplet.java b/src/java/org/apache/fop/fonts/FontTriplet.java index 9392cc8b9..a9728428a 100644 --- a/src/java/org/apache/fop/fonts/FontTriplet.java +++ b/src/java/org/apache/fop/fonts/FontTriplet.java @@ -19,6 +19,8 @@ package org.apache.fop.fonts; +import java.io.IOException; +import java.io.ObjectInputStream; import java.io.Serializable; @@ -41,6 +43,10 @@ public class FontTriplet implements Comparable, Serializable { //This is only a cache private transient String key; + public FontTriplet() { + this(null, null, 0); + } + /** * Creates a new font triplet. * @param name font name @@ -65,6 +71,10 @@ public class FontTriplet implements Comparable, Serializable { this.priority = priority; } + private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { + ois.defaultReadObject(); + } + /** @return the font name */ public String getName() { return name; diff --git a/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java b/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java index 3da33ec3f..4aa9b77a2 100644 --- a/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java +++ b/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java @@ -38,18 +38,12 @@ import org.apache.commons.logging.LogFactory; public abstract class AbstractFontReader { /** Logger instance */ - protected static Log log; + protected static final Log log = LogFactory.getLog(AbstractFontReader.class); /** * Main constructor. */ protected AbstractFontReader() { - // Create logger if necessary here to allow embedding of TTFReader in - // other applications. There is a possible but harmless synchronization - // issue. - if (log == null) { - log = LogFactory.getLog(AbstractFontReader.class); - } } /** @@ -78,7 +72,7 @@ public abstract class AbstractFontReader { arguments.add(args[i]); } } - return (String[])arguments.toArray(new String[0]); + return (String[])arguments.toArray(new String[arguments.size()]); } /** diff --git a/src/java/org/apache/fop/fonts/apps/TTFReader.java b/src/java/org/apache/fop/fonts/apps/TTFReader.java index 12fc638b4..6f80fd098 100644 --- a/src/java/org/apache/fop/fonts/apps/TTFReader.java +++ b/src/java/org/apache/fop/fonts/apps/TTFReader.java @@ -462,11 +462,12 @@ public class TTFReader extends AbstractFontReader { h2 = ttf.getAnsiKerning().get(kpx1); } - for (Integer kpx2 : h2.keySet()) { + for (Map.Entry e : h2.entrySet()) { + Integer kpx2 = e.getKey(); if (isCid || kpx2.intValue() < 256) { el2 = doc.createElement("pair"); el2.setAttribute("kpx2", kpx2.toString()); - Integer val = h2.get(kpx2); + Integer val = e.getValue(); el2.setAttribute("kern", val.toString()); el.appendChild(el2); } diff --git a/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java b/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java index d9c6f3b3a..0e468eb7b 100644 --- a/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java +++ b/src/java/org/apache/fop/fonts/truetype/OFDirTabEntry.java @@ -54,8 +54,7 @@ public class OFDirTabEntry { tag[2] = in.readTTFByte(); tag[3] = in.readTTFByte(); - in.skip(4); // Skip checksum - + checksum = in.readTTFLong(); offset = in.readTTFULong(); length = in.readTTFULong(); diff --git a/src/java/org/apache/fop/fonts/truetype/OTFFile.java b/src/java/org/apache/fop/fonts/truetype/OTFFile.java index 57d875f9c..1ac7a565e 100644 --- a/src/java/org/apache/fop/fonts/truetype/OTFFile.java +++ b/src/java/org/apache/fop/fonts/truetype/OTFFile.java @@ -53,7 +53,7 @@ public class OTFFile extends OpenFont { protected void updateBBoxAndOffset() throws IOException { List gidMappings = getGIDMappings(fileFont); Map sidNames = constructNameMap(gidMappings); - UnicodeMapping[] mappings = unicodeMappings.toArray(new UnicodeMapping[0]); + UnicodeMapping[] mappings = unicodeMappings.toArray(new UnicodeMapping[unicodeMappings.size()]); for (int i = 0; i < mappings.length; i++) { int glyphIdx = mappings[i].getGlyphIndex(); Mapping m = gidMappings.get(glyphIdx); diff --git a/src/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java b/src/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java index caace37bc..34e1ebb6c 100644 --- a/src/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java +++ b/src/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java @@ -29,6 +29,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import org.apache.fontbox.cff.CFFStandardString; import org.apache.fontbox.cff.encoding.CFFEncoding; @@ -386,7 +387,8 @@ public class OTFSubSetFile extends OTFFile { List uniqueGroups = new ArrayList(); for (int gid : subsetGlyphs.keySet()) { - Integer[] ranges = fdSelect.getRanges().keySet().toArray(new Integer[0]); + Set rangeKeys = fdSelect.getRanges().keySet(); + Integer[] ranges = rangeKeys.toArray(new Integer[rangeKeys.size()]); for (int i = 0; i < ranges.length; i++) { int nextRange = -1; if (i < ranges.length - 1) { diff --git a/src/java/org/apache/fop/fonts/truetype/OpenFont.java b/src/java/org/apache/fop/fonts/truetype/OpenFont.java index b0288b998..b736c9968 100644 --- a/src/java/org/apache/fop/fonts/truetype/OpenFont.java +++ b/src/java/org/apache/fop/fonts/truetype/OpenFont.java @@ -641,6 +641,7 @@ public abstract class OpenFont { /** * Print first char/last char */ + /* not used private void printMaxMin() { int min = 255; int max = 0; @@ -655,6 +656,7 @@ public abstract class OpenFont { log.info("Min: " + min); log.info("Max: " + max); } + */ /** @@ -1606,9 +1608,10 @@ public abstract class OpenFont { Map akpx = new HashMap(); Map ckpx = kerningTab.get(unicodeKey1); - for (Integer unicodeKey2 : ckpx.keySet()) { + for (Map.Entry e : ckpx.entrySet()) { + Integer unicodeKey2 = e.getKey(); Integer cidKey2 = unicodeToGlyph(unicodeKey2.intValue()); - Integer kern = ckpx.get(unicodeKey2); + Integer kern = e.getValue(); Iterator uniMap = mtxTab[cidKey2.intValue()].getUnicodeIndex().listIterator(); while (uniMap.hasNext()) { @@ -1828,7 +1831,7 @@ public abstract class OpenFont { ret.add(new Integer(i)); } } - return ret.toArray(new Integer[0]); + return ret.toArray(new Integer[ret.size()]); } /** diff --git a/src/java/org/apache/fop/fonts/type1/PFMFile.java b/src/java/org/apache/fop/fonts/type1/PFMFile.java index a2d384e7f..8856fdb7f 100644 --- a/src/java/org/apache/fop/fonts/type1/PFMFile.java +++ b/src/java/org/apache/fop/fonts/type1/PFMFile.java @@ -118,26 +118,38 @@ public class PFMFile { * @throws IOException In case of an I/O problem */ private void loadHeader(PFMInputStream inStream) throws IOException { - inStream.skip(80); + if (inStream.skip(80) != 80) { + throw new IOException("premature EOF when skipping 80 bytes"); + } dfItalic = inStream.readByte(); - inStream.skip(2); + if (inStream.skip(2) != 2) { + throw new IOException("premature EOF when skipping 2 bytes"); + } inStream.readShort(); // dfWeight = dfCharSet = inStream.readByte(); - inStream.skip(4); + if (inStream.skip(4) != 4) { + throw new IOException("premature EOF when skipping 4 bytes"); + } dfPitchAndFamily = inStream.readByte(); dfAvgWidth = inStream.readShort(); dfMaxWidth = inStream.readShort(); dfFirstChar = inStream.readByte(); dfLastChar = inStream.readByte(); - inStream.skip(8); + if (inStream.skip(8) != 8) { + throw new IOException("premature EOF when skipping 8 bytes"); + } long faceOffset = inStream.readInt(); inStream.reset(); - inStream.skip(faceOffset); + if (inStream.skip(faceOffset) != faceOffset) { + throw new IOException("premature EOF when skipping faceOffset bytes"); + } windowsName = inStream.readString(); inStream.reset(); - inStream.skip(117); + if (inStream.skip(117) != 117) { + throw new IOException("premature EOF when skipping 117 bytes"); + } } /** @@ -153,29 +165,41 @@ public class PFMFile { } final long extMetricsOffset = inStream.readInt(); final long extentTableOffset = inStream.readInt(); - inStream.skip(4); //Skip dfOriginTable + if (inStream.skip(4) != 4) { //Skip dfOriginTable + throw new IOException("premature EOF when skipping dfOriginTable bytes"); + } final long kernPairOffset = inStream.readInt(); - inStream.skip(4); //Skip dfTrackKernTable + if (inStream.skip(4) != 4) { //Skip dfTrackKernTable + throw new IOException("premature EOF when skipping dfTrackKernTable bytes"); + } long driverInfoOffset = inStream.readInt(); if (kernPairOffset > 0) { inStream.reset(); - inStream.skip(kernPairOffset); + if (inStream.skip(kernPairOffset) != kernPairOffset) { + throw new IOException("premature EOF when skipping kernPairOffset bytes"); + } loadKernPairs(inStream); } inStream.reset(); - inStream.skip(driverInfoOffset); + if (inStream.skip(driverInfoOffset) != driverInfoOffset) { + throw new IOException("premature EOF when skipping driverInfoOffset bytes"); + } postscriptName = inStream.readString(); if (extMetricsOffset != 0) { inStream.reset(); - inStream.skip(extMetricsOffset); + if (inStream.skip(extMetricsOffset) != extMetricsOffset) { + throw new IOException("premature EOF when skipping extMetricsOffset bytes"); + } loadExtMetrics(inStream); } if (extentTableOffset != 0) { inStream.reset(); - inStream.skip(extentTableOffset); + if (inStream.skip(extentTableOffset) != extentTableOffset) { + throw new IOException("premature EOF when skipping extentTableOffset bytes"); + } loadExtentTable(inStream); } @@ -231,8 +255,10 @@ public class PFMFile { log.warn("Size of extension block was expected to be " + "52 bytes, but was " + size + " bytes."); } - inStream.skip(12); //Skip etmPointSize, etmOrientation, etmMasterHeight, - //etmMinScale, etmMaxScale, emtMasterUnits + if (inStream.skip(12) != 12) { //Skip etmPointSize, etmOrientation, etmMasterHeight, + //etmMinScale, etmMaxScale, emtMasterUnits + throw new IOException("premature EOF when skipping etmPointSize, ... bytes"); + } etmCapHeight = inStream.readShort(); etmXHeight = inStream.readShort(); etmLowerCaseAscent = inStream.readShort(); diff --git a/src/java/org/apache/fop/hyphenation/HyphenationTree.java b/src/java/org/apache/fop/hyphenation/HyphenationTree.java index 24730a529..f61e8a11a 100644 --- a/src/java/org/apache/fop/hyphenation/HyphenationTree.java +++ b/src/java/org/apache/fop/hyphenation/HyphenationTree.java @@ -27,7 +27,6 @@ import java.io.FileReader; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.Serializable; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collections; @@ -45,8 +44,7 @@ import org.apache.commons.io.IOUtils; * *

This work was authored by Carlos Villegas (cav@uniscope.co.jp).

*/ -public class HyphenationTree extends TernaryTree - implements PatternConsumer, Serializable { +public class HyphenationTree extends TernaryTree implements PatternConsumer { private static final long serialVersionUID = -7842107987915665573L; @@ -78,6 +76,10 @@ public class HyphenationTree extends TernaryTree vspace.alloc(1); // this reserves index 0, which we don't use } + private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { + ois.defaultReadObject(); + } + /** * Packs the values by storing them in 4 bits, two values into a byte * Values range is from 0 to 9. We use zero as terminator, diff --git a/src/java/org/apache/fop/hyphenation/Hyphenator.java b/src/java/org/apache/fop/hyphenation/Hyphenator.java index 90848cd69..48af67d09 100644 --- a/src/java/org/apache/fop/hyphenation/Hyphenator.java +++ b/src/java/org/apache/fop/hyphenation/Hyphenator.java @@ -43,7 +43,7 @@ import org.apache.fop.apps.io.InternalResourceResolver; public final class Hyphenator { /** logging instance */ - protected static final Log log = LogFactory.getLog(Hyphenator.class); + private static final Log log = LogFactory.getLog(Hyphenator.class); private static HyphenationTreeCache hTreeCache; diff --git a/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java index a1a2735a2..7faa0565e 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java @@ -376,9 +376,9 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa if (currentPageNum % 2 == 0) { // we are now on an even page curPage = makeNewPage(true); } - } else if (forcePageCount == Constants.EN_NO_FORCE) { + } /* else if (forcePageCount == Constants.EN_NO_FORCE) { // i hope: nothing special at all - } + } */ if (curPage != null) { finishPage(); diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index 250e07727..21dcf9ea9 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -141,9 +141,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected void addChildToArea(Area childArea, BlockParent parentArea) { // This should be a block-level Area (Block in the generic sense) - if (!(childArea instanceof Block)) { + /* if (!(childArea instanceof Block)) { //log.error("Child not a Block in BlockStackingLM!"); - } + } */ parentArea.addBlock((Block) childArea); flush(); // hand off current area to parent diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java index 75c61b94f..d37f3b021 100644 --- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java @@ -39,8 +39,7 @@ import org.apache.fop.util.ListUtil; * and filling them with block-level areas generated by its children. * TODO Reintroduce emergency counter (generate error to avoid endless loop) */ -public class FlowLayoutManager extends BlockStackingLayoutManager - implements BlockLevelLayoutManager { +public class FlowLayoutManager extends BlockStackingLayoutManager { /** * logging instance diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java index b16c9dfc4..108402cfa 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java @@ -48,7 +48,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager imp private Block curBlockArea; private int xOffset; - private int itemIPD; + // private int itemIPD; // FIXME: never written! /** * Create a new Cell layout manager. @@ -178,8 +178,8 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager imp curBlockArea.setPositioning(Block.ABSOLUTE); // set position curBlockArea.setXOffset(xOffset); - //TODO: Check - itemIPD never set? - curBlockArea.setIPD(itemIPD); + // FIXME - itemIPD is never written! + curBlockArea.setIPD(/*itemIPD*/0); //curBlockArea.setHeight(); curBlockArea.setBidiLevel(getPartFO().getBidiLevel()); diff --git a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java index a4c8570e8..28cd073e8 100644 --- a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java +++ b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java @@ -47,8 +47,7 @@ public abstract class CollapsingBorderModel { /** Indicates that the cell is/end in the last row of a body/table-header/table-footer */ //public static final int LAST_ROW_IN_GROUP = 8; - //These statics are used singleton-style. No MT issues here. - private static CollapsingBorderModel collapse; + private static CollapsingBorderModel collapse = new CollapsingBorderModelEyeCatching(); // private static CollapsingBorderModel collapseWithPrecedence = null; /** @@ -58,9 +57,6 @@ public abstract class CollapsingBorderModel { public static CollapsingBorderModel getBorderModelFor(int borderCollapse) { switch (borderCollapse) { case Constants.EN_COLLAPSE: - if (collapse == null) { - collapse = new CollapsingBorderModelEyeCatching(); - } return collapse; case Constants.EN_COLLAPSE_WITH_PRECEDENCE: throw new UnsupportedOperationException("collapse-with-precedence not yet supported"); diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index b2851c1b0..b8d5c063a 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -44,7 +44,6 @@ import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo; import org.apache.fop.layoutmgr.AbstractLayoutManager; import org.apache.fop.layoutmgr.AreaAdditionUtil; -import org.apache.fop.layoutmgr.BlockLevelLayoutManager; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; import org.apache.fop.layoutmgr.ElementListObserver; import org.apache.fop.layoutmgr.ElementListUtils; @@ -69,8 +68,7 @@ import org.apache.fop.util.ListUtil; * LayoutManager for a table-cell FO. * A cell contains blocks. These blocks fill the cell. */ -public class TableCellLayoutManager extends BlockStackingLayoutManager - implements BlockLevelLayoutManager { +public class TableCellLayoutManager extends BlockStackingLayoutManager { /** * logging instance diff --git a/src/java/org/apache/fop/pdf/PDFGState.java b/src/java/org/apache/fop/pdf/PDFGState.java index 7306218ae..540917b60 100644 --- a/src/java/org/apache/fop/pdf/PDFGState.java +++ b/src/java/org/apache/fop/pdf/PDFGState.java @@ -19,8 +19,8 @@ package org.apache.fop.pdf; -import java.util.Iterator; import java.util.Map; +import java.util.Set; /** * Class representing a /ExtGState object. @@ -186,10 +186,10 @@ public class PDFGState extends PDFObject { if (vals1.size() != vals2.size()) { return false; } - for (Iterator iter = vals1.keySet().iterator(); iter.hasNext();) { - Object str = iter.next(); + for (Map.Entry e : (Set>) vals2.entrySet()) { + Object str = e.getKey(); Object obj1 = vals1.get(str); - if (!obj1.equals(vals2.get(str))) { + if (!obj1.equals(e.getValue())) { return false; } } diff --git a/src/java/org/apache/fop/pdf/PDFPaintingState.java b/src/java/org/apache/fop/pdf/PDFPaintingState.java index 6278e51a0..ce4296a20 100644 --- a/src/java/org/apache/fop/pdf/PDFPaintingState.java +++ b/src/java/org/apache/fop/pdf/PDFPaintingState.java @@ -244,6 +244,7 @@ public class PDFPaintingState extends org.apache.fop.util.AbstractPaintingState return (PDFData)getData(); } + // @SuppressFBWarnings("SE_INNER_CLASS") private class PDFData extends org.apache.fop.util.AbstractPaintingState.AbstractData { private static final long serialVersionUID = 3527950647293177764L; diff --git a/src/java/org/apache/fop/pdf/PDFResources.java b/src/java/org/apache/fop/pdf/PDFResources.java index dc6319f07..86e771c46 100644 --- a/src/java/org/apache/fop/pdf/PDFResources.java +++ b/src/java/org/apache/fop/pdf/PDFResources.java @@ -122,8 +122,9 @@ public class PDFResources extends PDFDictionary { */ public void addFonts(PDFDocument doc, FontInfo fontInfo) { Map usedFonts = fontInfo.getUsedFonts(); - for (String f : usedFonts.keySet()) { - Typeface font = usedFonts.get(f); + for (Map.Entry e : usedFonts.entrySet()) { + String f = e.getKey(); + Typeface font = e.getValue(); //Check if the font actually had any mapping operations. If not, it is an indication //that it has never actually been used and therefore doesn't have to be embedded. diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java index 3412c3d67..57b65cdcd 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java @@ -38,14 +38,12 @@ import org.apache.fop.render.PrintRendererConfigurator; import org.apache.fop.render.RendererConfig.RendererConfigParser; import org.apache.fop.render.afp.AFPFontConfig.AFPFontConfigData; import org.apache.fop.render.intermediate.IFDocumentHandler; -import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; import org.apache.fop.util.LogUtil; /** * AFP Renderer configurator */ -public class AFPRendererConfigurator extends PrintRendererConfigurator implements - IFDocumentHandlerConfigurator { +public class AFPRendererConfigurator extends PrintRendererConfigurator { private static Log log = LogFactory.getLog(AFPRendererConfigurator.class); private final AFPEventProducer eventProducer; diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java index 6ec1541c9..176f74705 100644 --- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java +++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java @@ -400,9 +400,9 @@ public class IFRenderer extends AbstractPathOrientedRenderer { GoToXYAction action = (GoToXYAction)actionSet.get(targetID); //GoToXYAction action = (GoToXYAction)idGoTos.get(targetID); if (action == null) { - if (pageIndex < 0) { + /* if (pageIndex < 0) { //pageIndex = page - } + } */ Point position = (Point)idPositions.get(targetID); // can the GoTo already be fully filled in? if (pageIndex >= 0 && position != null) { @@ -1094,7 +1094,8 @@ public class IFRenderer extends AbstractPathOrientedRenderer { AbstractTextArea textArea = (AbstractTextArea)space.getParentArea(); renderTextWithAdjustments(s, (int[]) null, false, font, textArea); - if (textUtil.combined && space.isAdjustable()) { + /* COMBINED is always false + if (textUtil.COMBINED && space.isAdjustable()) { //Used for justified text, for example int tws = textArea.getTextWordSpaceAdjust() + 2 * textArea.getTextLetterSpaceAdjust(); @@ -1102,6 +1103,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { textUtil.adjust(tws); } } + */ super.renderSpace(space); } @@ -1124,10 +1126,12 @@ public class IFRenderer extends AbstractPathOrientedRenderer { char ch = s.charAt(i); textUtil.addChar(ch); int glyphAdjust = 0; - if (textUtil.combined && font.hasChar(ch)) { + /* COMBINED is always false + if (textUtil.COMBINED && font.hasChar(ch)) { int tls = (i < l - 1 ? parentArea.getTextLetterSpaceAdjust() : 0); glyphAdjust += tls; } + */ if (dx != null && i < l) { glyphAdjust += dx[i]; } @@ -1147,7 +1151,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { private void renderTextWithAdjustments(String s, int[][] dp, boolean reversed, Font font, AbstractTextArea parentArea) { - assert !textUtil.combined; + // assert !textUtil.COMBINED; for (int i = 0, n = s.length(); i < n; i++) { textUtil.addChar(s.charAt(i)); if (dp != null) { @@ -1164,7 +1168,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { private int starty; private int tls; private int tws; - private final boolean combined = false; + // private final static boolean COMBINED = false; // no longer referenced void addChar(char ch) { text.append(ch); @@ -1221,13 +1225,13 @@ public class IFRenderer extends AbstractPathOrientedRenderer { void flush() { if (text.length() > 0) { try { - if (combined) { + /* if (COMBINED) { // COMBINED is always false painter.drawText(startx, starty, 0, 0, trimAdjustments(dp, text.length()), text.toString()); - } else { + } else { */ painter.drawText(startx, starty, tls, tws, trimAdjustments(dp, text.length()), text.toString()); - } + /* } */ } catch (IFException e) { handleIFException(e); } diff --git a/src/java/org/apache/fop/render/pcl/PCLGenerator.java b/src/java/org/apache/fop/render/pcl/PCLGenerator.java index 05045b7e7..05a0fc666 100644 --- a/src/java/org/apache/fop/render/pcl/PCLGenerator.java +++ b/src/java/org/apache/fop/render/pcl/PCLGenerator.java @@ -21,20 +21,12 @@ package org.apache.fop.render.pcl; import java.awt.Color; import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; -import java.awt.image.BufferedImageOp; -import java.awt.image.ByteLookupTable; -import java.awt.image.ColorModel; import java.awt.image.DataBuffer; import java.awt.image.DataBufferByte; import java.awt.image.IndexColorModel; -import java.awt.image.LookupOp; import java.awt.image.MultiPixelPackedSampleModel; import java.awt.image.Raster; import java.awt.image.RenderedImage; -import java.awt.image.WritableRaster; import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -45,7 +37,6 @@ import java.util.Locale; import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.xmlgraphics.image.GraphicsUtil; import org.apache.xmlgraphics.util.UnitConv; import org.apache.fop.util.bitmap.BitmapImageUtil; @@ -82,7 +73,7 @@ public class PCLGenerator { * true: Standard PCL shades are used (poor quality). false: user-defined pattern are used * to create custom dither patterns for better grayscale quality. */ - private final boolean usePCLShades = false; + private static final boolean USE_PCL_SHADES = false; /** * Main constructor. @@ -390,7 +381,7 @@ public class PCLGenerator { //y += h; } setPatternTransparencyMode(false); - if (usePCLShades + if (USE_PCL_SHADES || Color.black.equals(col) || Color.white.equals(col)) { writeCommand("*c" + formatDouble4(w / 100.0) + "h" @@ -521,7 +512,7 @@ public class PCLGenerator { } else if (Color.white.equals(col)) { selectCurrentPattern(0, 1); //white } else { - if (usePCLShades) { + if (USE_PCL_SHADES) { selectCurrentPattern(convertToPCLShade(col), 2); } else { defineGrayscalePattern(col, 32, DitherUtil.DITHER_MATRIX_4X4); @@ -647,6 +638,7 @@ public class PCLGenerator { } } + /* not used private RenderedImage getMask(RenderedImage img, Dimension targetDim) { ColorModel cm = img.getColorModel(); if (cm.hasAlpha()) { @@ -685,6 +677,7 @@ public class PCLGenerator { return null; } } + */ /** * Paint a bitmap at the current cursor position. The bitmap is converted to a monochrome diff --git a/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java b/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java index 9d9118aaa..93648e975 100644 --- a/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java +++ b/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java @@ -55,7 +55,7 @@ public class PCLGraphics2D extends AbstractGraphics2D { /** The PCL generator */ protected PCLGenerator gen; - private final boolean failOnUnsupportedFeature = true; + private static final boolean FAIL_ON_UNSUPPORTED_FEATURE = true; private boolean clippingDisabled; /** @@ -120,7 +120,7 @@ public class PCLGraphics2D extends AbstractGraphics2D { * @param msg the error message to be displayed */ protected void handleUnsupportedFeature(String msg) { - if (this.failOnUnsupportedFeature) { + if (this.FAIL_ON_UNSUPPORTED_FEATURE) { throw new UnsupportedOperationException(msg); } } diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java b/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java index d103b4796..dcda49059 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java +++ b/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java @@ -29,7 +29,6 @@ import org.apache.fop.fonts.FontCollection; import org.apache.fop.render.PrintRendererConfigurator; import org.apache.fop.render.RendererConfig.RendererConfigParser; import org.apache.fop.render.intermediate.IFDocumentHandler; -import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; import org.apache.fop.render.java2d.Base14FontCollection; import org.apache.fop.render.java2d.ConfiguredFontCollection; import org.apache.fop.render.java2d.InstalledFontCollection; @@ -38,8 +37,7 @@ import org.apache.fop.render.java2d.Java2DFontMetrics; /** * PCL Renderer configurator */ -public class PCLRendererConfigurator extends PrintRendererConfigurator - implements IFDocumentHandlerConfigurator { +public class PCLRendererConfigurator extends PrintRendererConfigurator { /** * Default constructor diff --git a/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java index d76a805c2..306b0b350 100644 --- a/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java +++ b/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java @@ -133,8 +133,9 @@ public class ImageRawJPEGAdapter extends AbstractImageAdapter { // Check for ICC profile byte[] iccString = new byte[11]; din.readFully(iccString); - din.skipBytes(1); //string terminator (null byte) - + if (din.skipBytes(1) != 1) { //string terminator (null byte) + throw new IOException("premature EOF when skipping terminator byte"); + } if ("ICC_PROFILE".equals(new String(iccString, "US-ASCII"))) { skipICCProfile = (this.image.getICCProfile() != null); } diff --git a/src/java/org/apache/fop/render/ps/PSDocumentHandler.java b/src/java/org/apache/fop/render/ps/PSDocumentHandler.java index dcf968e03..158cb0fc1 100644 --- a/src/java/org/apache/fop/render/ps/PSDocumentHandler.java +++ b/src/java/org/apache/fop/render/ps/PSDocumentHandler.java @@ -295,9 +295,9 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { public void startPage(int index, String name, String pageMasterName, Dimension size) throws IFException { try { - if (this.currentPageNumber == 0) { + /* if (this.currentPageNumber == 0) { //writeHeader(); - } + } */ this.currentPageNumber++; diff --git a/src/java/org/apache/fop/render/ps/PSFontUtils.java b/src/java/org/apache/fop/render/ps/PSFontUtils.java index b98919ca2..e8ad32b5e 100644 --- a/src/java/org/apache/fop/render/ps/PSFontUtils.java +++ b/src/java/org/apache/fop/render/ps/PSFontUtils.java @@ -70,6 +70,7 @@ import org.apache.fop.util.HexEncoder; /** * Utility code for font handling in PostScript. */ +// @SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_SUPERCLASS") public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { /** logging instance */ @@ -192,8 +193,9 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { gen.commentln("%FOPBeginFontReencode"); //Rewrite font encodings - for (String key : fonts.keySet()) { - Typeface tf = fonts.get(key); + for (Map.Entry e : fonts.entrySet()) { + String key = e.getKey(); + Typeface tf = e.getValue(); if (tf instanceof LazyFont) { tf = ((LazyFont)tf).getRealFont(); if (tf == null) { diff --git a/src/java/org/apache/fop/render/ps/PSImageUtils.java b/src/java/org/apache/fop/render/ps/PSImageUtils.java index 962f19d10..e9d4ff27f 100644 --- a/src/java/org/apache/fop/render/ps/PSImageUtils.java +++ b/src/java/org/apache/fop/render/ps/PSImageUtils.java @@ -37,6 +37,7 @@ import org.apache.fop.render.RenderingContext; /** * Utility code for rendering images in PostScript. */ +// @SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_SUPERCLASS") public class PSImageUtils extends org.apache.xmlgraphics.ps.PSImageUtils { /** diff --git a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java index b453de413..3540732d7 100644 --- a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java +++ b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java @@ -24,14 +24,12 @@ import org.apache.fop.apps.FOUserAgent; import org.apache.fop.render.DefaultRendererConfigurator; import org.apache.fop.render.RendererConfig.RendererConfigParser; import org.apache.fop.render.intermediate.IFDocumentHandler; -import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; /** * Postscript renderer config */ -public class PSRendererConfigurator extends DefaultRendererConfigurator - implements IFDocumentHandlerConfigurator { +public class PSRendererConfigurator extends DefaultRendererConfigurator { /** * Default constructor diff --git a/src/java/org/apache/fop/render/ps/ResourceHandler.java b/src/java/org/apache/fop/render/ps/ResourceHandler.java index b4e138cff..a12ae5a49 100644 --- a/src/java/org/apache/fop/render/ps/ResourceHandler.java +++ b/src/java/org/apache/fop/render/ps/ResourceHandler.java @@ -19,7 +19,6 @@ package org.apache.fop.render.ps; -import java.awt.geom.Dimension2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.InputStream; @@ -38,7 +37,6 @@ import org.apache.xmlgraphics.image.loader.ImageManager; import org.apache.xmlgraphics.image.loader.ImageSessionContext; import org.apache.xmlgraphics.image.loader.util.ImageUtil; import org.apache.xmlgraphics.ps.DSCConstants; -import org.apache.xmlgraphics.ps.FormGenerator; import org.apache.xmlgraphics.ps.PSGenerator; import org.apache.xmlgraphics.ps.PSResource; import org.apache.xmlgraphics.ps.dsc.DSCException; @@ -334,6 +332,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { } } + /* not used private static FormGenerator createMissingForm(String formName, final Dimension2D dimensions) { FormGenerator formGen = new FormGenerator(formName, null, dimensions) { @@ -357,6 +356,7 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { }; return formGen; } + */ private class IncludeResourceListener implements DSCListener { diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java index 8537d4559..d3810b094 100644 --- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java @@ -215,10 +215,10 @@ final class TextAttributesConverter { attrFontColor(fobj.getColor(), attrib); - if (fobj.getLeaderPatternWidth() != null) { + /* if (fobj.getLeaderPatternWidth() != null) { //TODO calculate pattern width not possible for white spaces, because its using //underlines for tab it would work with LEADER_PATTERN_WIDTH (expndtw) - } + } */ switch(fobj.getLeaderPattern()) { case Constants.EN_DOTS: diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java index 593b2583f..413c9ad87 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java @@ -53,14 +53,14 @@ public final class RtfColorTable { ////////////////////////////////////////////////// /** Singelton instance */ - private static RtfColorTable instance; + private static RtfColorTable instance = new RtfColorTable(); /** Index table for the colors */ private Hashtable colorIndex; /** Used colors to this vector */ private Vector colorTable; - /** Map of color names to color numbers */ - private Hashtable namedColors; + /** Map of color names to color numbers */ + private Hashtable namedColors; ////////////////////////////////////////////////// @@ -73,7 +73,7 @@ public final class RtfColorTable { private RtfColorTable() { colorTable = new Vector(); colorIndex = new Hashtable(); - namedColors = new Hashtable(); + namedColors = new Hashtable(); init(); } @@ -84,10 +84,6 @@ public final class RtfColorTable { * @return The instance of RTFColorTable */ public static RtfColorTable getInstance() { - if (instance == null) { - instance = new RtfColorTable(); - } - return instance; } @@ -124,19 +120,19 @@ public final class RtfColorTable { getColorNumber(192, 192, 192); } - /** define a named color for getColorNumber(String) */ - private void addNamedColor(String name, int colorNumber) { - namedColors.put(name.toLowerCase(), new Integer(colorNumber)); - } + /** define a named color for getColorNumber(String) */ + private void addNamedColor(String name, int colorNumber) { + namedColors.put(name.toLowerCase(), new Integer(colorNumber)); + } ////////////////////////////////////////////////// // @@ Public methods ////////////////////////////////////////////////// - /** - * @param name a named color - * @return the RTF number of a named color, or null if name not found - */ + /** + * @param name a named color + * @return the RTF number of a named color, or null if name not found + */ public Integer getColorNumber(String name) { return ((Integer)namedColors.get(name.toLowerCase())); } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java index 0a48d9b37..4701604c8 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java @@ -41,7 +41,7 @@ public final class RtfFontManager { ////////////////////////////////////////////////// /** Singelton instance */ - private static RtfFontManager instance; + private static RtfFontManager instance = new RtfFontManager(); /** Index table for the fonts */ private Hashtable fontIndex; @@ -69,10 +69,6 @@ public final class RtfFontManager { * @return The instance of RtfFontManager */ public static RtfFontManager getInstance() { - if (instance == null) { - instance = new RtfFontManager(); - } - return instance; } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java index f293d9774..845ee1d28 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHeader.java @@ -41,7 +41,7 @@ import java.util.Map; */ class RtfHeader extends RtfContainer { - private final String charset = "ansi"; + private static final String CHARSET = "ansi"; private final Map userProperties = new HashMap(); /** Create an RTF header */ @@ -54,7 +54,7 @@ class RtfHeader extends RtfContainer { /** Overridden to write our own data before our children's data */ protected void writeRtfContent() throws IOException { - writeControlWord(charset); + writeControlWord(CHARSET); writeUserProperties(); RtfColorTable.getInstance().writeColors(this); super.writeRtfContent(); diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java index d72f7ecb5..48d6efed1 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java @@ -60,7 +60,7 @@ public final class RtfStyleSheetTable { ////////////////////////////////////////////////// /** Singelton instance */ - private static RtfStyleSheetTable instance; + private static RtfStyleSheetTable instance = new RtfStyleSheetTable(); ////////////////////////////////////////////////// @@ -100,10 +100,6 @@ public final class RtfStyleSheetTable { * @return The instance of RtfStyleSheetTable */ public static RtfStyleSheetTable getInstance() { - if (instance == null) { - instance = new RtfStyleSheetTable(); - } - return instance; } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java index f3831da53..6d928765c 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java @@ -36,7 +36,7 @@ import java.io.IOException; public final class RtfTemplate { /** Singelton instance */ - private static RtfTemplate instance; + private static RtfTemplate instance = new RtfTemplate(); private String templateFilePath; @@ -54,10 +54,6 @@ public final class RtfTemplate { * @return The instance of RtfTemplate */ public static RtfTemplate getInstance() { - if (instance == null) { - instance = new RtfTemplate(); - } - return instance; } diff --git a/src/java/org/apache/fop/render/txt/TXTRenderer.java b/src/java/org/apache/fop/render/txt/TXTRenderer.java index 6f646f813..811906f36 100644 --- a/src/java/org/apache/fop/render/txt/TXTRenderer.java +++ b/src/java/org/apache/fop/render/txt/TXTRenderer.java @@ -91,10 +91,10 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { * Every line except the last line on a page (which will end with * pageEnding) will be terminated with this string. */ - private final String lineEnding = "\r\n"; + private static final String LINE_ENDING = "\r\n"; /** Every page except the last one will end with this string. */ - private final String pageEnding = "\f"; + private static final String PAGE_ENDING = "\f"; /** Equals true, if current page is first. */ private boolean firstPage; @@ -211,7 +211,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { if (firstPage) { firstPage = false; } else { - currentStream.add(pageEnding); + currentStream.add(PAGE_ENDING); } Rectangle2D bounds = page.getViewArea(); @@ -286,7 +286,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { currentStream.add(outr.toString()); } if (row < pageHeight) { - currentStream.add(lineEnding); + currentStream.add(LINE_ENDING); } } } diff --git a/src/java/org/apache/fop/svg/GraphicsConfiguration.java b/src/java/org/apache/fop/svg/GraphicsConfiguration.java index 83fd79b9d..f64eab62f 100644 --- a/src/java/org/apache/fop/svg/GraphicsConfiguration.java +++ b/src/java/org/apache/fop/svg/GraphicsConfiguration.java @@ -29,6 +29,7 @@ import java.awt.image.VolatileImage; * for JDK 1.3 because there is no VolatileImage there. * */ +// @SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_SUPERCLASS") public abstract class GraphicsConfiguration extends java.awt.GraphicsConfiguration { /** diff --git a/src/java/org/apache/fop/svg/PDFTextUtil.java b/src/java/org/apache/fop/svg/PDFTextUtil.java index d525ecefc..23fadc542 100644 --- a/src/java/org/apache/fop/svg/PDFTextUtil.java +++ b/src/java/org/apache/fop/svg/PDFTextUtil.java @@ -27,6 +27,7 @@ import org.apache.fop.fonts.Typeface; * Utility class for generating PDF text objects. It needs to be subclassed to add writing * functionality (see {@link #write(String)}). */ +// @SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_SUPERCLASS") public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil { private FontInfo fontInfo; diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java index 8e0d0bca9..d837a29fb 100644 --- a/src/java/org/apache/fop/tools/TestConverter.java +++ b/src/java/org/apache/fop/tools/TestConverter.java @@ -226,9 +226,9 @@ public class TestConverter { runTestCase(node); } else if (nodename.equals("test")) { runTest(tcase, node); - } else if (nodename.equals("result")) { + } /* else if (nodename.equals("result")) { //nop - } + } */ } diff --git a/src/java/org/apache/fop/tools/anttasks/FileCompare.java b/src/java/org/apache/fop/tools/anttasks/FileCompare.java index 2c307869e..7fa588e23 100644 --- a/src/java/org/apache/fop/tools/anttasks/FileCompare.java +++ b/src/java/org/apache/fop/tools/anttasks/FileCompare.java @@ -77,7 +77,7 @@ public class FileCompare { filenameListTmp.add(tokens.nextToken()); } filenameList = new String[filenameListTmp.size()]; - filenameList = (String[])filenameListTmp.toArray(new String[0]); + filenameList = (String[])filenameListTmp.toArray(new String[filenameListTmp.size()]); } /** diff --git a/src/java/org/apache/fop/tools/anttasks/RunTest.java b/src/java/org/apache/fop/tools/anttasks/RunTest.java index 1f46b4abe..1b560802a 100644 --- a/src/java/org/apache/fop/tools/anttasks/RunTest.java +++ b/src/java/org/apache/fop/tools/anttasks/RunTest.java @@ -28,8 +28,8 @@ import java.net.URLClassLoader; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; -import java.util.Iterator; import java.util.Map; +import java.util.Set; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; @@ -105,10 +105,9 @@ public class RunTest extends Task { System.out.println("===================================="); System.out.println("The following files differ:"); boolean broke = false; - for (Iterator keys = diff.keySet().iterator(); - keys.hasNext();) { - Object fname = keys.next(); - Boolean pass = (Boolean)diff.get(fname); + for (Map.Entry e : (Set>) diff.entrySet()) { + Object fname = e.getKey(); + Boolean pass = (Boolean)e.getValue(); System.out.println("file: " + fname + " - reference success: " + pass); if (pass.booleanValue()) { diff --git a/src/java/org/apache/fop/tools/fontlist/FontListMain.java b/src/java/org/apache/fop/tools/fontlist/FontListMain.java index e2f5a651e..794f9306f 100644 --- a/src/java/org/apache/fop/tools/fontlist/FontListMain.java +++ b/src/java/org/apache/fop/tools/fontlist/FontListMain.java @@ -257,6 +257,7 @@ public final class FontListMain { int idx = 0; if ("--help".equals(args[idx]) || "-?".equals(args[idx]) || "-h".equals(args[idx])) { printHelp(); + // @SuppressFBWarnings("DM_EXIT") System.exit(0); } if (idx < args.length - 1 && "-c".equals(args[idx])) { diff --git a/src/java/org/apache/fop/util/AbstractPaintingState.java b/src/java/org/apache/fop/util/AbstractPaintingState.java index ef4c29406..8368383ba 100644 --- a/src/java/org/apache/fop/util/AbstractPaintingState.java +++ b/src/java/org/apache/fop/util/AbstractPaintingState.java @@ -384,6 +384,7 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable { /** * A stack implementation which holds state objects */ + // @SuppressFBWarnings("SE_INNER_CLASS") public class StateStack extends java.util.Stack { private static final long serialVersionUID = 4897178211223823041L; diff --git a/src/java/org/apache/fop/util/ColorUtil.java b/src/java/org/apache/fop/util/ColorUtil.java index cb42b6813..d564d6686 100644 --- a/src/java/org/apache/fop/util/ColorUtil.java +++ b/src/java/org/apache/fop/util/ColorUtil.java @@ -71,7 +71,7 @@ public final class ColorUtil { private static Map colorMap; /** Logger instance */ - protected static final Log log = LogFactory.getLog(ColorUtil.class); + private static final Log log = LogFactory.getLog(ColorUtil.class); static { initializeColorMap(); diff --git a/src/java/org/apache/fop/util/QName.java b/src/java/org/apache/fop/util/QName.java index 1b0708a89..dcf76a985 100644 --- a/src/java/org/apache/fop/util/QName.java +++ b/src/java/org/apache/fop/util/QName.java @@ -26,6 +26,7 @@ package org.apache.fop.util; * hashCode() methods. * @deprecated Use the XML Graphics Commons variant instead! */ +// @SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_SUPERCLASS") public class QName extends org.apache.xmlgraphics.util.QName { private static final long serialVersionUID = -5225376740044770690L;