<!-- 27 warnings -->
<Bug pattern="DLS_DEAD_LOCAL_STORE"/>
</Match>
- <Match>
- <!-- 4 warnings -->
- <Bug pattern="DM_BOOLEAN_CTOR"/>
- </Match>
<Match>
<!-- 29 warnings -->
<Bug pattern="DM_CONVERT_CASE"/>
<!-- 88 warnings -->
<Bug pattern="DM_NUMBER_CTOR"/>
</Match>
- <Match>
- <!-- 4 warnings -->
- <Bug pattern="DM_STRING_VOID_CTOR"/>
- </Match>
<Match>
<!-- 84 warnings -->
<Bug pattern="EI_EXPOSE_REP"/>
<!-- 5 warnings -->
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS"/>
</Match>
- <Match>
- <!-- 4 warnings -->
- <Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE"/>
- </Match>
- <Match>
- <!-- 4 warnings -->
- <Bug pattern="NP_NULL_ON_SOME_PATH"/>
- </Match>
- <Match>
- <!-- 4 warnings -->
- <Bug pattern="OS_OPEN_STREAM"/>
- </Match>
<Match>
<!-- 46 warnings -->
<Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
public static String lpad(String input, char padding, int length) {
if (input == null) {
- input = new String();
+ input = "";
}
if (input.length() >= length) {
public static String rpad(String input, char padding, int length) {
if (input == null) {
- input = new String();
+ input = "";
}
if (input.length() >= length) {
import java.io.InputStreamReader;
import java.util.List;
+import org.apache.commons.io.IOUtils;
+
/**
* FontFinder for native Windows platforms
*/
} else {
process = runtime.exec("cmd.exe /c echo %windir%");
}
- BufferedReader bufferedReader = new BufferedReader(
- new InputStreamReader(process.getInputStream()));
- return bufferedReader.readLine();
+ InputStreamReader isr = null;
+ BufferedReader bufferedReader = null;
+ String dir = "";
+ try {
+ isr = new InputStreamReader(process.getInputStream());
+ bufferedReader = new BufferedReader(isr);
+ dir = bufferedReader.readLine();
+ } finally {
+ IOUtils.closeQuietly(bufferedReader);
+ IOUtils.closeQuietly(isr);
+ }
+ return dir;
}
/**
* {@inheritDoc}
*/
public String toString() {
- String str = new String();
+ String str = "";
if (fontFamilyAttributeValue != null) {
str += "font-family=" + fontFamilyAttributeValue;
}
= BitmapRendererEventProducer.Provider.get(
getUserAgent().getEventBroadcaster());
eventProducer.noImageWriterFound(this, getMimeType());
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Writing image using " + writer.getClass().getName());
+ }
+ writer.writeImage(image, os, params);
}
- if (log.isDebugEnabled()) {
- log.debug("Writing image using " + writer.getClass().getName());
- }
- writer.writeImage(image, os, params);
}
/**
= BitmapRendererEventProducer.Provider.get(
getUserAgent().getEventBroadcaster());
eventProducer.noImageWriterFound(this, getMimeType());
- }
- if (writer.supportsMultiImageWriter()) {
- MultiImageWriter multiWriter = writer.createMultiImageWriter(outputStream);
- try {
- // Write all pages/images
- while (pageImagesItr.hasNext()) {
- RenderedImage img = (RenderedImage) pageImagesItr.next();
- multiWriter.writeImage(img, imageSettings.getWriterParams());
- }
- } finally {
- multiWriter.close();
- }
} else {
- RenderedImage renderedImage = null;
- if (pageImagesItr.hasNext()) {
- renderedImage = (RenderedImage) pageImagesItr.next();
- }
- writer.writeImage(renderedImage, outputStream, imageSettings.getWriterParams());
- if (pageImagesItr.hasNext()) {
- BitmapRendererEventProducer eventProducer
- = BitmapRendererEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.stoppingAfterFirstPageNoFilename(this);
+ if (writer.supportsMultiImageWriter()) {
+ MultiImageWriter multiWriter = writer.createMultiImageWriter(outputStream);
+ try {
+ // Write all pages/images
+ while (pageImagesItr.hasNext()) {
+ RenderedImage img = (RenderedImage) pageImagesItr.next();
+ multiWriter.writeImage(img, imageSettings.getWriterParams());
+ }
+ } finally {
+ multiWriter.close();
+ }
+ } else {
+ RenderedImage renderedImage = null;
+ if (pageImagesItr.hasNext()) {
+ renderedImage = (RenderedImage) pageImagesItr.next();
+ }
+ writer.writeImage(renderedImage, outputStream, imageSettings.getWriterParams());
+ if (pageImagesItr.hasNext()) {
+ BitmapRendererEventProducer eventProducer
+ = BitmapRendererEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.stoppingAfterFirstPageNoFilename(this);
+ }
}
+ // Cleaning
+ outputStream.flush();
+ clearViewportList();
}
-
- // Cleaning
- outputStream.flush();
- clearViewportList();
log.debug("TIFF encoding done.");
}
ByteArrayOutputStream baos = null;\r
DeflaterOutputStream dos = null;\r
InputStream in = null;\r
+ InflaterInputStream infStream = null;\r
+ DataInputStream dataStream = null;\r
try {\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
+ infStream = new InflaterInputStream(in, new Inflater());\r
+ 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
}\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(infStream);\r
+ IOUtils.closeQuietly(dataStream);\r
IOUtils.closeQuietly(in);\r
IOUtils.closeQuietly(dos);\r
IOUtils.closeQuietly(baos);\r
/** {@inheritDoc} */\r
public void outputContents(OutputStream out) throws IOException {\r
InputStream in = ((ImageRawStream) image).createInputStream();\r
-\r
+ InflaterInputStream infStream = null;\r
+ DataInputStream dataStream = null;\r
+ DeflaterOutputStream dos = null;\r
try {\r
if (numberOfInterleavedComponents == 1 || numberOfInterleavedComponents == 3) {\r
// means we have Gray, RGB, or Palette\r
// TODO: since we have alpha here do this when the alpha channel is extracted\r
int numBytes = numberOfInterleavedComponents - 1; // 1 for Gray, 3 for RGB\r
int numColumns = image.getSize().getWidthPx();\r
- InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());\r
- DataInputStream dataStream = new DataInputStream(infStream);\r
+ infStream = new InflaterInputStream(in, new Inflater());\r
+ dataStream = new DataInputStream(infStream);\r
int offset = 0;\r
int bytesPerRow = numberOfInterleavedComponents * numColumns;\r
int filter;\r
// here we need to inflate the PNG pixel data, which includes alpha, separate the alpha\r
// channel and then deflate the RGB channels back again\r
- DeflaterOutputStream dos = new DeflaterOutputStream(out, new Deflater());\r
+ dos = new DeflaterOutputStream(out, new Deflater());\r
while ((filter = dataStream.read()) != -1) {\r
byte[] bytes = new byte[bytesPerRow];\r
dataStream.readFully(bytes, 0, bytesPerRow);\r
}\r
offset = 0;\r
}\r
- dos.close();\r
}\r
} finally {\r
+ IOUtils.closeQuietly(dos);\r
+ IOUtils.closeQuietly(dataStream);\r
+ IOUtils.closeQuietly(infStream);\r
IOUtils.closeQuietly(in);\r
}\r
}\r
public void writeTo(OutputStream out) throws IOException {
// TODO: refactor this code with equivalent PDF code
InputStream in = ((ImageRawStream) image).createInputStream();
+ InflaterInputStream infStream = null;
+ DataInputStream dataStream = null;
+ ByteArrayOutputStream baos = null;
+ DeflaterOutputStream dos = null;
try {
if (numberOfInterleavedComponents == 1 || numberOfInterleavedComponents == 3) {
// means we have Gray, RGB, or Palette
// means we have Gray + alpha or RGB + alpha
int numBytes = numberOfInterleavedComponents - 1; // 1 for Gray, 3 for RGB
int numColumns = image.getSize().getWidthPx();
- InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());
- DataInputStream dataStream = new DataInputStream(infStream);
+ infStream = new InflaterInputStream(in, new Inflater());
+ dataStream = new DataInputStream(infStream);
int offset = 0;
int bytesPerRow = numberOfInterleavedComponents * numColumns;
int filter;
// TODO: not using the baos below and using the original out instead (as happens in PDF)
// would be preferable but that does not work with the rest of the postscript code; this
// needs to be revisited
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DeflaterOutputStream dos = new DeflaterOutputStream(/* out */baos, new Deflater());
+ baos = new ByteArrayOutputStream();
+ dos = new DeflaterOutputStream(/* out */baos, new Deflater());
while ((filter = dataStream.read()) != -1) {
byte[] bytes = new byte[bytesPerRow];
dataStream.readFully(bytes, 0, bytesPerRow);
IOUtils.copy(new ByteArrayInputStream(baos.toByteArray()), out);
}
} finally {
+ IOUtils.closeQuietly(dos);
+ IOUtils.closeQuietly(baos);
+ IOUtils.closeQuietly(dataStream);
+ IOUtils.closeQuietly(infStream);
IOUtils.closeQuietly(in);
}
}
}
//check for keep-together
- if (attrib != null && attrib.isSet(ITableAttributes.ROW_KEEP_TOGETHER)) {
+ if (attrib.isSet(ITableAttributes.ROW_KEEP_TOGETHER)) {
writeControlWord(ROW_KEEP_TOGETHER);
}
* number The digits as integer
*/
public static int getInt(String value) {
- String retString = new String();
+ String retString = "";
StringBuffer s = new StringBuffer(value);
int len = s.length();
while (colIndex >= colFirstSpanningCol.size()) {
setNextFirstSpanningCol(false);
}
- colFirstSpanningCol.set(colIndex, new Boolean(bFirstSpanningCol));
+ colFirstSpanningCol.set(colIndex, Boolean.valueOf(bFirstSpanningCol));
} else {
- colFirstSpanningCol.add(new Boolean(bFirstSpanningCol));
+ colFirstSpanningCol.add(Boolean.valueOf(bFirstSpanningCol));
}
}
*/
public void setNextFirstSpanningCol(
boolean bFirstSpanningCol) {
- colFirstSpanningCol.add(new Boolean(bFirstSpanningCol));
+ colFirstSpanningCol.add(Boolean.valueOf(bFirstSpanningCol));
}
/**
if (i.intValue() == 0) {
colRowSpanningAttrs.set(z, null);
- colFirstSpanningCol.set(z, new Boolean(false));
+ colFirstSpanningCol.set(z, Boolean.valueOf(false));
}
}
}
import org.apache.fop.fonts.EmbedFontInfo;
import org.apache.fop.fonts.FontCacheManagerFactory;
import org.apache.fop.fonts.FontDetectorFactory;
-import org.apache.fop.fonts.FontEventListener;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontManager;
import org.apache.fop.fonts.FontSetup;
//TODO Make use of fontBaseURL, font substitution and referencing configuration
//Requires a change to the expected configuration layout
- final FontEventListener listener = null;
DefaultFontConfig.DefaultFontConfigParser parser
= new DefaultFontConfig.DefaultFontConfigParser();
DefaultFontConfig fontInfoConfig = parser.parse(cfg, strict);
DefaultFontConfigurator fontInfoConfigurator
- = new DefaultFontConfigurator(fontManager, listener, strict);
+ = new DefaultFontConfigurator(fontManager, null, strict);
List<EmbedFontInfo> fontInfoList = fontInfoConfigurator.configure(fontInfoConfig);
fontManager.saveCache();
FontSetup.setup(fontInfo, fontInfoList, resourceResolver, useComplexScriptFeatures);
public static void main(String[] args) {
if (args == null || args.length == 0) {
System.out.println("test suite file name required");
+ return;
}
TestConverter tc = new TestConverter();
FopFactory fopFactory = FopFactory.newInstance(baseUri);
FOUserAgent userAgent = fopFactory.newFOUserAgent();
- userAgent.getRendererOptions().put("fineDetail", new Boolean(false));
- userAgent.getRendererOptions().put("consistentOutput", new Boolean(true));
+ userAgent.getRendererOptions().put("fineDetail", Boolean.valueOf(false));
+ userAgent.getRendererOptions().put("consistentOutput", Boolean.valueOf(true));
userAgent.setProducer("Testsuite Converter");
String outname = res;
File f1 = new File(destdir, outname + ".at.xml");
File f2 = new File(compare, outname + ".at.xml");
if (!compareFiles(f1, f2)) {
- differ.put(outname + ".at.xml", new Boolean(pass));
+ differ.put(outname + ".at.xml", Boolean.valueOf(pass));
}
}
} catch (Exception e) {
import java.io.OutputStream;
import java.net.URI;
import java.util.List;
-import java.util.Vector;
import org.xml.sax.SAXException;
private void render(File xmlFile, File xsltFile, File outFile, String outputFormat) {
//TODO: implement support for XSLT params
- final Vector xsltParams = null;
- InputHandler inputHandler = new InputHandler(xmlFile, xsltFile, xsltParams);
+ InputHandler inputHandler = new InputHandler(xmlFile, xsltFile, null);
try {
renderInputHandler(inputHandler, outFile, outputFormat);
} catch (Exception ex) {