Browse Source

Adapt to changes in Commons IO's APIs.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197334 13f79535-47bb-0310-9956-ffa450edef68
pull/30/head
Jeremias Maerki 20 years ago
parent
commit
3e111ddb9f

+ 5
- 11
src/java/org/apache/fop/fonts/truetype/FontFileReader.java View File

@@ -4,7 +4,7 @@
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
* Copyright (C) 1999-2004 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
@@ -54,7 +54,7 @@ import java.io.InputStream;
import java.io.File;
import java.io.IOException;

import org.apache.commons.io.IOUtil;
import org.apache.commons.io.IOUtils;

/**
* Reads a TrueType font file into a byte array and
@@ -73,15 +73,9 @@ public class FontFileReader {
* @throws IOException In case of an I/O problem
*/
private void init(InputStream in) throws java.io.IOException {
java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
try {
IOUtil.copy(in, bout);
this.file = bout.toByteArray();
this.fsize = this.file.length;
this.current = 0;
} finally {
bout.close();
}
this.file = IOUtils.toByteArray(in);
this.fsize = this.file.length;
this.current = 0;
}

/**

+ 17
- 2
src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java View File

@@ -51,6 +51,7 @@
package org.apache.fop.fonts.truetype;

import java.io.IOException;
import java.io.UnsupportedEncodingException;


/**
@@ -76,9 +77,11 @@ class TTFDirTabEntry {

offset = in.readTTFULong();
length = in.readTTFULong();
String tagStr = new String(tag, "ISO-8859-1");
// System.err.println("tag='" + tagStr + "'");

//System.out.println(this.toString());
return new String(tag, "ISO-8859-1");
return tagStr;
}


@@ -115,11 +118,23 @@ class TTFDirTabEntry {
}

/**
* Returns the tag.
* Returns the tag bytes.
* @return byte[]
*/
public byte[] getTag() {
return tag;
}

/**
* Returns the tag bytes.
* @return byte[]
*/
public String getTagString() {
try {
return new String(tag, "ISO-8859-1");
} catch (UnsupportedEncodingException e) {
return this.toString(); // Should never happen.
}
}

}

+ 3
- 3
src/java/org/apache/fop/fonts/type1/PFBParser.java View File

@@ -4,7 +4,7 @@
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
* Copyright (C) 1999-2004 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
@@ -56,7 +56,7 @@ import java.io.DataInputStream;
import java.io.BufferedInputStream;

//Commons
import org.apache.commons.io.IOUtil;
import org.apache.commons.io.IOUtils;

/**
* This class represents a parser for Adobe Type 1 PFB files.
@@ -261,7 +261,7 @@ public class PFBParser {

private void parseRAWFormat(PFBData pfb, BufferedInputStream bin)
throws IOException {
calcLengths(pfb, IOUtil.toByteArray(bin));
calcLengths(pfb, IOUtils.toByteArray(bin));
}

}

+ 3
- 3
src/java/org/apache/fop/fonts/type1/PFMFile.java View File

@@ -4,7 +4,7 @@
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
* Copyright (C) 1999-2004 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
@@ -57,7 +57,7 @@ import java.util.Map;

// Apache libs
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.commons.io.IOUtil;
import org.apache.commons.io.IOUtils;

// FOP
import org.apache.fop.fonts.Glyphs;
@@ -101,7 +101,7 @@ public class PFMFile extends AbstractLogEnabled {
* @throws IOException In case of an I/O problem
*/
public void load(InputStream inStream) throws IOException {
final byte[] buf = IOUtil.toByteArray(inStream);
final byte[] buf = IOUtils.toByteArray(inStream);
final InputStream bufin = new java.io.ByteArrayInputStream(buf);
PFMInputStream in = new PFMInputStream(bufin);
/*final int version =*/ in.readShort();

+ 3
- 3
src/java/org/apache/fop/pdf/PDFFactory.java View File

@@ -4,7 +4,7 @@
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
* Copyright (C) 1999-2004 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
@@ -59,7 +59,7 @@ import java.util.Map;

// Apache libs
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.commons.io.IOUtil;
import org.apache.commons.io.IOUtils;

// FOP
import org.apache.fop.fonts.CIDFont;
@@ -1180,7 +1180,7 @@ public class PDFFactory {
embeddedFont = new PDFT1Stream();
((PDFT1Stream)embeddedFont).setData(pfb);
} else {
byte[] file = IOUtil.toByteArray(in);
byte[] file = IOUtils.toByteArray(in);
embeddedFont = new PDFTTFStream(file.length);
((PDFTTFStream)embeddedFont).setData(file, file.length);
}

+ 3
- 3
src/java/org/apache/fop/pdf/TempFileStreamCache.java View File

@@ -4,7 +4,7 @@
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
* Copyright (C) 1999-2004 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
@@ -57,7 +57,7 @@ import java.io.IOException;
import java.io.File;

//Commons
import org.apache.commons.io.IOUtil;
import org.apache.commons.io.CopyUtils;

/**
* StreamCache implementation that uses temporary files rather than heap.
@@ -124,7 +124,7 @@ public class TempFileStreamCache implements StreamCache {

// don't need a buffer because streamCopy is buffered
InputStream input = new java.io.FileInputStream(tempFile);
final long bytesCopied = IOUtil.copy(input, out);
final long bytesCopied = CopyUtils.copy(input, out);
input.close();
return (int)bytesCopied;
}

+ 4
- 4
src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java View File

@@ -4,7 +4,7 @@
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
* Copyright (C) 1999-2004 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
@@ -58,7 +58,7 @@

package org.apache.fop.render.rtf.rtflib.rtfdoc;

import org.apache.commons.io.IOUtil;
import org.apache.commons.io.IOUtils;
import org.apache.fop.render.rtf.rtflib.tools.ImageConstants;
import org.apache.fop.render.rtf.rtflib.tools.ImageUtil;
//import org.apache.fop.render.rtf.rtflib.tools.jpeg.Encoder;
@@ -248,9 +248,9 @@ public class RtfExternalGraphic extends RtfElement {
try {
final InputStream in = url.openStream();
try {
imagedata = IOUtil.toByteArray(url.openStream());
imagedata = IOUtils.toByteArray(url.openStream());
} finally {
IOUtil.shutdownStream(in);
IOUtils.closeQuietly(in);
}
} catch (Exception e) {
throw new ExternalGraphicException("The attribute 'src' of "

+ 2
- 2
test/java/org/apache/fop/util/ASCII85InputStreamTestCase.java View File

@@ -54,7 +54,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtil;
import org.apache.commons.io.CopyUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.fop.pdf.PDFText;

@@ -85,7 +85,7 @@ public class ASCII85InputStreamTestCase extends TestCase {
InputStream in = new ByteArrayInputStream(ascii85);
InputStream decoder = new ASCII85InputStream(in);
ByteArrayOutputStream baout = new ByteArrayOutputStream();
IOUtil.copy(decoder, baout);
CopyUtils.copy(decoder, baout);
baout.close();
return baout.toByteArray();
}

Loading…
Cancel
Save