<!-- 4 warnings -->
<Bug pattern="DM_BOOLEAN_CTOR"/>
</Match>
- <Match>
- <!-- 2 warnings -->
- <Bug pattern="DM_BOXED_PRIMITIVE_TOSTRING"/>
- </Match>
<Match>
<!-- 29 warnings -->
<Bug pattern="DM_CONVERT_CASE"/>
<!-- 88 warnings -->
<Bug pattern="DM_NUMBER_CTOR"/>
</Match>
- <Match>
- <!-- 2 warnings -->
- <Bug pattern="DM_STRING_TOSTRING"/>
- </Match>
<Match>
<!-- 4 warnings -->
<Bug pattern="DM_STRING_VOID_CTOR"/>
</Match>
- <Match>
- <!-- 2 warnings -->
- <Bug pattern="DMI_INVOKING_TOSTRING_ON_ARRAY"/>
- </Match>
- <Match>
- <!-- 2 warnings -->
- <Bug pattern="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED"/>
- </Match>
<Match>
<!-- 84 warnings -->
<Bug pattern="EI_EXPOSE_REP"/>
</And>
</Or>
</Match>
- <Match>
- <!-- 2 warnings -->
- <Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS"/>
- </Match>
<Match>
<!-- 3 warnings -->
<Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ"/>
<!-- 12 warnings -->
<Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
</Match>
- <Match>
- <!-- 2 warnings -->
- <Bug pattern="IM_BAD_CHECK_FOR_ODD"/>
- </Match>
<Match>
<!-- 3 warnings -->
<Bug pattern="IS2_INCONSISTENT_SYNC"/>
<!-- 9 warnings -->
<Bug pattern="LI_LAZY_INIT_STATIC"/>
</Match>
- <Match>
- <!-- 2 warnings -->
- <Bug pattern="MF_CLASS_MASKS_FIELD"/>
- </Match>
<Match>
<Bug pattern="MS_EXPOSE_REP"/>
<Or>
<!-- 4 warnings -->
<Bug pattern="NP_NULL_ON_SOME_PATH"/>
</Match>
- <Match>
- <!-- 2 warnings -->
- <Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
- </Match>
<Match>
<!-- 3 warnings -->
<Bug pattern="NS_DANGEROUS_NON_SHORT_CIRCUIT"/>
<!-- 4 warnings -->
<Bug pattern="OS_OPEN_STREAM"/>
</Match>
- <Match>
- <!-- 2 warnings -->
- <Bug pattern="OS_OPEN_STREAM_EXCEPTION_PATH"/>
- </Match>
<Match>
<!-- 46 warnings -->
<Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
<!-- 11 warnings -->
<Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"/>
</Match>
- <Match>
- <!-- 2 warnings -->
- <Bug pattern="SBSC_USE_STRINGBUFFER_CONCATENATION"/>
- </Match>
<Match>
<!-- 33 warnings -->
<Bug pattern="SE_BAD_FIELD"/>
</Match>
- <Match>
- <!-- 2 warnings -->
- <Bug pattern="SE_BAD_FIELD_INNER_CLASS"/>
- </Match>
- <Match>
- <!-- 2 warnings -->
- <Bug pattern="SE_BAD_FIELD_STORE"/>
- </Match>
<Match>
<!-- 6 warnings -->
<Bug pattern="SE_INNER_CLASS"/>
private float bitmapEncodingQuality;
/** color image handler */
- private ColorConverter colorConverter = GrayScaleColorConverter.getInstance();
+ private transient ColorConverter colorConverter = GrayScaleColorConverter.getInstance();
/**
* true if certain image formats may be embedded unchanged in their native
/** {@inheritDoc} */
public String toString() {
- String coordsStr = "";
+ StringBuffer sb = new StringBuffer();
for (int i = 0; i < coords.length; i++) {
- coordsStr += (i % 2 == 0) ? "x" : "y";
- coordsStr += (i / 2) + "=" + coords[i] + ",";
+ if (sb.length() > 0) {
+ sb.append(',');
+ }
+ sb.append((i % 2 == 0) ? 'x' : 'y');
+ sb.append(i / 2);
+ sb.append('=');
+ sb.append(coords[i]);
}
- coordsStr = coordsStr.substring(0, coordsStr.length() - 1);
- return getName() + "{" + coordsStr + "}";
+ return getName() + "{" + sb.toString() + "}";
}
/**
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.List;
import org.apache.commons.io.IOUtils;
*/
public static void startFOPWithDynamicClasspath(String[] args) {
try {
- URL[] urls = getJARList();
+ final URL[] urls = getJARList();
//System.out.println("CCL: "
// + Thread.currentThread().getContextClassLoader().toString());
- ClassLoader loader = new java.net.URLClassLoader(urls, null);
+ ClassLoader loader = (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new java.net.URLClassLoader(urls, null);
+ }
+ });
Thread.currentThread().setContextClassLoader(loader);
Class clazz = Class.forName("org.apache.fop.cli.Main", true, loader);
//System.out.println("CL: " + clazz.getClassLoader().toString());
startingPageNumber++;
}
} else if (pageNumberType == EN_AUTO_EVEN) {
- if (startingPageNumber % 2 == 1) {
+ if (startingPageNumber % 2 != 0) {
startingPageNumber++;
}
}
private static final long serialVersionUID = -5126033718398975158L;
private String localizedMessage;
- private Locator locator;
+ private transient Locator locator;
/**
if (pageSequenceMaster == null) {
return simplePageMaster;
}
- boolean isOddPage = ((page % 2) == 1);
+ boolean isOddPage = ((page % 2) != 0);
if (log.isDebugEnabled()) {
log.debug("getNextSimplePageMaster(page=" + page
+ " isOdd=" + isOddPage
* @return this.character cast as a String
*/
public String getString() {
- return new Character(character).toString();
+ return Character.toString(character);
}
@Override
PropertyList propertyList)
throws PropertyException {
Property prop = null;
- String vProperty = "";
+ StringBuffer vProperty = new StringBuffer();
// Try each of the stored values in turn
Iterator iprop = property.getList().iterator();
while (iprop.hasNext() && prop == null) {
Property p = (Property)iprop.next();
if (p.getNCname() != null) {
- vProperty += p.getNCname() + " ";
+ if (vProperty.length() > 0) {
+ vProperty.append(' ');
+ }
+ vProperty.append(p.getNCname());
}
prop = maker.convertShorthandProperty(propertyList, p, null);
}
- propertyList.validatePropertyValue(vProperty.trim(), prop, property);
+ propertyList.validatePropertyValue(vProperty.toString(), prop, property);
return prop;
}
* @return the name of the glyph
*/
public static String charToGlyphName(char ch) {
- return stringToGlyph(new Character(ch).toString());
+ return stringToGlyph(Character.toString(ch));
}
/**
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
/**
offset = in.readTTFULong();
length = in.readTTFULong();
- String tagStr = new String(tag, "ISO-8859-1");
- return tagStr;
+ return getTagString();
}
@Override
public String toString() {
- return "Read dir tab ["
- + tag[0] + " " + tag[1] + " " + tag[2] + " " + tag[3] + "]"
+ return "Read dir tab [" + Arrays.toString(tag) + "]"
+ " offset: " + offset
+ " length: " + length
- + " name: " + tag;
+ + " name: " + getTagString();
}
/**
/**
* Key-value helper class.
*/
- final static class UnicodeMapping implements Comparable {
+ static final class UnicodeMapping implements Comparable {
private final int unicodeIndex;
private final int glyphIndex;
* Helper class, extending the functionality of the
* basic {@link BlockKnuthSequence}.
*/
- public class BlockSequence extends BlockKnuthSequence {
+ public static class BlockSequence extends BlockKnuthSequence {
private static final long serialVersionUID = -5348831120146774118L;
public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLayoutManager {
/** The page number citation object */
- protected AbstractPageNumberCitation fobj;
+ protected AbstractPageNumberCitation citation;
+
/** Font for the page-number-citation */
protected Font font;
*/
public AbstractPageNumberCitationLayoutManager(AbstractPageNumberCitation node) {
super(node);
- fobj = node;
+ citation = node;
}
/** {@inheritDoc} */
public void initialize() {
- FontInfo fi = fobj.getFOEventHandler().getFontInfo();
- FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
- font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this));
- setCommonBorderPaddingBackground(fobj.getCommonBorderPaddingBackground());
+ FontInfo fi = citation.getFOEventHandler().getFontInfo();
+ FontTriplet[] fontkeys = citation.getCommonFont().getFontState(fi);
+ font = fi.getFontInstance(fontkeys[0], citation.getCommonFont().fontSize.getValue(this));
+ setCommonBorderPaddingBackground(citation.getCommonBorderPaddingBackground());
}
/**
protected AlignmentContext makeAlignmentContext(LayoutContext context) {
return new AlignmentContext(
font
- , fobj.getLineHeight().getOptimum(this).getLength().getValue(this)
- , fobj.getAlignmentAdjust()
- , fobj.getAlignmentBaseline()
- , fobj.getBaselineShift()
- , fobj.getDominantBaseline()
+ , citation.getLineHeight().getOptimum(this).getLength().getValue(this)
+ , citation.getAlignmentAdjust()
+ , citation.getAlignmentBaseline()
+ , citation.getBaselineShift()
+ , citation.getDominantBaseline()
, context.getAlignmentContext()
);
}
protected InlineArea getEffectiveArea(LayoutContext layoutContext) {
InlineArea area = getPageNumberCitationArea();
if (!layoutContext.treatAsArtifact()) {
- TraitSetter.addStructureTreeElement(area, fobj.getStructureTreeElement());
+ TraitSetter.addStructureTreeElement(area, citation.getStructureTreeElement());
}
return area;
}
text = new TextArea();
text.addWord(citationString, 0);
} else {
- UnresolvedPageNumber unresolved = new UnresolvedPageNumber(fobj.getRefId(), font,
+ UnresolvedPageNumber unresolved = new UnresolvedPageNumber(citation.getRefId(), font,
getReferenceType());
- getPSLM().addUnresolvedArea(fobj.getRefId(), unresolved);
+ getPSLM().addUnresolvedArea(citation.getRefId(), unresolved);
text = unresolved;
}
setTraits(text);
protected abstract boolean getReferenceType();
private void setTraits(TextArea text) {
- TraitSetter.setProducerID(text, fobj.getId());
+ TraitSetter.setProducerID(text, citation.getId());
int bidiLevel = getBidiLevel();
text.setBidiLevel(bidiLevel);
int width = getStringWidth(citationString); // TODO: [GA] !I18N!
text.setBPD(font.getAscender() - font.getDescender());
text.setBaselineOffset(font.getAscender());
TraitSetter.addFontTraits(text, font);
- text.addTrait(Trait.COLOR, fobj.getColor());
- TraitSetter.addTextDecoration(text, fobj.getTextDecoration());
+ text.addTrait(Trait.COLOR, citation.getColor());
+ TraitSetter.addTextDecoration(text, citation.getTextDecoration());
}
/**
* @return bidi level governing abstract page number citation
*/
protected int getBidiLevel() {
- return fobj.getBidiLevel();
+ return citation.getBidiLevel();
}
}
}
// this class represents a paragraph
- private class Paragraph extends InlineKnuthSequence {
+ private static class Paragraph extends InlineKnuthSequence {
private static final long serialVersionUID = 5862072380375189105L;
// add the element representing text indentation
// at the beginning of the first paragraph
- if (isFirstInBlock && knuthParagraphs.size() == 0
+ if (layoutManager.isFirstInBlock && layoutManager.knuthParagraphs.size() == 0
&& textIndent != 0) {
this.add(new KnuthInlineBox(textIndent, null,
null, false));
public void endParagraph() {
KnuthSequence finishedPar = this.endSequence();
if (finishedPar != null) {
- knuthParagraphs.add(finishedPar);
+ layoutManager.knuthParagraphs.add(finishedPar);
}
}
@Override
protected PageViewport getCitedPage() {
- if (getPSLM().associateLayoutManagerID(fobj.getRefId())) {
- return getPSLM().getLastPVWithID(fobj.getRefId());
+ if (getPSLM().associateLayoutManagerID(citation.getRefId())) {
+ return getPSLM().getLastPVWithID(citation.getRefId());
} else {
return null;
}
@Override
protected PageViewport getCitedPage() {
- return getPSLM().getFirstPVWithID(fobj.getRefId());
+ return getPSLM().getFirstPVWithID(citation.getRefId());
}
@Override
PDFJavaScriptLaunchAction launch = (PDFJavaScriptLaunchAction) obj;
- if (!launch.script.toString().equals(script.toString())) {
+ if (!launch.script.equals(script)) {
return false;
}
image = (BufferedImage)imageRef.get();
}
- int x = (getWidth() - image.getWidth()) / 2;
- int y = (getHeight() - image.getHeight()) / 2;
-
- graphics.drawImage(image, x, y, image.getWidth(), image.getHeight(), null);
+ if (image != null) {
+ int x = (getWidth() - image.getWidth()) / 2;
+ int y = (getHeight() - image.getHeight()) / 2;
+ graphics.drawImage(image, x, y, image.getWidth(), image.getHeight(), null);
+ }
} catch (FOPException fopEx) {
fopEx.printStackTrace();
}
}
public void run() {
- processStatus.setText(message.toString());
+ processStatus.setText(message);
}
}
// TODO: Implement code to combine image with background color if transparency is not allowed\r
// here we need to inflate the PNG pixel data, which includes alpha, separate the alpha channel\r
// and then deflate it back again\r
- ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
- DeflaterOutputStream dos = new DeflaterOutputStream(baos, new Deflater());\r
- InputStream in = ((ImageRawStream) image).createInputStream();\r
+ ByteArrayOutputStream baos = null;\r
+ DeflaterOutputStream dos = null;\r
+ InputStream in = null;\r
try {\r
- InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());\r
- DataInputStream dataStream = new DataInputStream(infStream);\r
- // offset is the byte offset of the alpha component\r
- int offset = numberOfInterleavedComponents - 1; // 1 for GA, 3 for RGBA\r
- int numColumns = image.getSize().getWidthPx();\r
- int bytesPerRow = numberOfInterleavedComponents * numColumns;\r
- int filter;\r
- // read line by line; the first byte holds the filter\r
- while ((filter = dataStream.read()) != -1) {\r
- byte[] bytes = new byte[bytesPerRow];\r
- dataStream.readFully(bytes, 0, bytesPerRow);\r
- dos.write((byte) filter);\r
- for (int j = 0; j < numColumns; j++) {\r
- dos.write(bytes, offset, 1);\r
- offset += numberOfInterleavedComponents;\r
+ baos = new ByteArrayOutputStream();\r
+ dos = new DeflaterOutputStream(baos, new Deflater());\r
+ in = ((ImageRawStream) image).createInputStream();\r
+ try {\r
+ InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());\r
+ DataInputStream dataStream = new DataInputStream(infStream);\r
+ // offset is the byte offset of the alpha component\r
+ int offset = numberOfInterleavedComponents - 1; // 1 for GA, 3 for RGBA\r
+ int numColumns = image.getSize().getWidthPx();\r
+ int bytesPerRow = numberOfInterleavedComponents * numColumns;\r
+ int filter;\r
+ // read line by line; the first byte holds the filter\r
+ while ((filter = dataStream.read()) != -1) {\r
+ byte[] bytes = new byte[bytesPerRow];\r
+ dataStream.readFully(bytes, 0, bytesPerRow);\r
+ dos.write((byte) filter);\r
+ for (int j = 0; j < numColumns; j++) {\r
+ dos.write(bytes, offset, 1);\r
+ offset += numberOfInterleavedComponents;\r
+ }\r
+ offset = numberOfInterleavedComponents - 1;\r
}\r
- offset = numberOfInterleavedComponents - 1;\r
+ } catch (IOException e) {\r
+ throw new RuntimeException("Error processing transparency channel:", e);\r
}\r
- dos.close();\r
- } catch (IOException e) {\r
- throw new RuntimeException("Error processing transparency channel:", e);\r
+ // set up alpha channel compression\r
+ FlateFilter transFlate;\r
+ try {\r
+ transFlate = new FlateFilter();\r
+ transFlate.setApplied(true);\r
+ transFlate.setPredictor(FlateFilter.PREDICTION_PNG_OPT);\r
+ transFlate.setColors(1);\r
+ transFlate.setColumns(image.getSize().getWidthPx());\r
+ transFlate.setBitsPerComponent(this.getBitsPerComponent());\r
+ } catch (PDFFilterException e) {\r
+ throw new RuntimeException("FlateFilter configuration error", e);\r
+ }\r
+ BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(),\r
+ image.getSize().getHeightPx(), baos.toByteArray(), null);\r
+ IOUtils.closeQuietly(baos);\r
+ alphaMask.setPDFFilter(transFlate);\r
+ alphaMask.disallowMultipleFilters();\r
+ alphaMask.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));\r
+ softMask = doc.addImage(null, alphaMask).makeReference();\r
} finally {\r
IOUtils.closeQuietly(in);\r
+ IOUtils.closeQuietly(dos);\r
+ IOUtils.closeQuietly(baos);\r
}\r
- // set up alpha channel compression\r
- FlateFilter transFlate;\r
- try {\r
- transFlate = new FlateFilter();\r
- transFlate.setApplied(true);\r
- transFlate.setPredictor(FlateFilter.PREDICTION_PNG_OPT);\r
- transFlate.setColors(1);\r
- transFlate.setColumns(image.getSize().getWidthPx());\r
- transFlate.setBitsPerComponent(this.getBitsPerComponent());\r
- } catch (PDFFilterException e) {\r
- throw new RuntimeException("FlateFilter configuration error", e);\r
- }\r
- BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(),\r
- image.getSize().getHeightPx(), baos.toByteArray(), null);\r
- alphaMask.setPDFFilter(transFlate);\r
- alphaMask.disallowMultipleFilters();\r
- alphaMask.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));\r
- softMask = doc.addImage(null, alphaMask).makeReference();\r
}\r
}\r
\r
return this.uri;
}
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return super.equals(obj);
+ }
+
}
extends RtfContainer
implements IRtfParagraphContainer, IRtfExternalGraphicContainer, IRtfTableContainer,
IRtfTextrunContainer {
- protected RtfAttributes attrib;
private RtfParagraph para;
private RtfExternalGraphic externalGraphic;
private RtfTable table;
RtfAfterBeforeBase(RtfSection parent, Writer w, RtfAttributes attrs) throws IOException {
super((RtfContainer)parent, w, attrs);
- attrib = attrs;
}
public RtfParagraph newParagraph() throws IOException {
/** The FopFactory used to create Fop instances */
protected FopFactory fopFactory;
/** URIResolver for use by this servlet */
- protected URIResolver uriResolver;
+ protected transient URIResolver uriResolver;
/**
* {@inheritDoc}
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.fop.apps.FOUserAgent;
outname + makeResultExtension());
outputFile.getParentFile().mkdirs();
- OutputStream outStream = new java.io.BufferedOutputStream(
- new java.io.FileOutputStream(outputFile));
- logger.debug("ddir:" + destdir + " on:" + outputFile.getName());
- inputHandler.renderTo(userAgent, outputFormat, outStream);
- outStream.close();
+ OutputStream outStream = null;
+ try {
+ outStream = new java.io.BufferedOutputStream(
+ new java.io.FileOutputStream(outputFile));
+ logger.debug("ddir:" + destdir + " on:" + outputFile.getName());
+ inputHandler.renderTo(userAgent, outputFormat, outStream);
+ } finally {
+ IOUtils.closeQuietly(outStream);
+ }
// check difference
if (compare != null) {
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
// return;
// } else {
try {
- ClassLoader loader = new URLClassLoader(createUrls(referenceJar));
+ final URL[] urls = createUrls(referenceJar);
+ ClassLoader loader = (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new URLClassLoader(urls);
+ }
+ });
boolean failed = false;
-
try {
Class cla = Class.forName("org.apache.fop.apps.Fop", true,
loader);
+ ", fontName=" + fontName
+ ", fontSize=" + fontSize
+ ", lineWidth=" + lineWidth
- + ", dashArray=" + dashArray
+ + ", dashArray=" + Arrays.toString(dashArray)
+ ", transform=" + transform
+ ", layer=" + layer;
}
return this.fallback;
}
+ @Override
+ public int hashCode() {
+ return super.hashCode() ^ fallback.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (!super.equals(obj)) {
+ return false;
+ } else if (obj instanceof ColorWithFallback) {
+ ColorWithFallback other = (ColorWithFallback) obj;
+ return other.fallback.equals(fallback);
+ } else {
+ return false;
+ }
+ }
+
}