aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2004-02-06 21:49:48 +0000
committerJeremias Maerki <jeremias@apache.org>2004-02-06 21:49:48 +0000
commitd1699f53b71bf38df92430ed019f327156341840 (patch)
treefe14e92249cdff8897b0aa197182763518d6d407 /src/java/org
parente7203e225ba835ba7bd79008d6e36062c335698d (diff)
downloadxmlgraphics-fop-d1699f53b71bf38df92430ed019f327156341840.tar.gz
xmlgraphics-fop-d1699f53b71bf38df92430ed019f327156341840.zip
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
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/fop/fonts/truetype/FontFileReader.java16
-rw-r--r--src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java19
-rw-r--r--src/java/org/apache/fop/fonts/type1/PFBParser.java6
-rw-r--r--src/java/org/apache/fop/fonts/type1/PFMFile.java6
-rw-r--r--src/java/org/apache/fop/pdf/PDFFactory.java6
-rw-r--r--src/java/org/apache/fop/pdf/TempFileStreamCache.java6
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java8
7 files changed, 38 insertions, 29 deletions
diff --git a/src/java/org/apache/fop/fonts/truetype/FontFileReader.java b/src/java/org/apache/fop/fonts/truetype/FontFileReader.java
index d141435c6..61c3a0eda 100644
--- a/src/java/org/apache/fop/fonts/truetype/FontFileReader.java
+++ b/src/java/org/apache/fop/fonts/truetype/FontFileReader.java
@@ -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;
}
/**
diff --git a/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java b/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java
index 6907cb27d..1e89b562c 100644
--- a/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java
+++ b/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java
@@ -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.
+ }
+ }
+
}
diff --git a/src/java/org/apache/fop/fonts/type1/PFBParser.java b/src/java/org/apache/fop/fonts/type1/PFBParser.java
index e59bc94b2..a1badc402 100644
--- a/src/java/org/apache/fop/fonts/type1/PFBParser.java
+++ b/src/java/org/apache/fop/fonts/type1/PFBParser.java
@@ -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));
}
} \ No newline at end of file
diff --git a/src/java/org/apache/fop/fonts/type1/PFMFile.java b/src/java/org/apache/fop/fonts/type1/PFMFile.java
index 58a7cceb5..bc74c6cfe 100644
--- a/src/java/org/apache/fop/fonts/type1/PFMFile.java
+++ b/src/java/org/apache/fop/fonts/type1/PFMFile.java
@@ -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();
diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java
index fc9a19640..ff6afd3e7 100644
--- a/src/java/org/apache/fop/pdf/PDFFactory.java
+++ b/src/java/org/apache/fop/pdf/PDFFactory.java
@@ -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);
}
diff --git a/src/java/org/apache/fop/pdf/TempFileStreamCache.java b/src/java/org/apache/fop/pdf/TempFileStreamCache.java
index a387b9a1b..50cef94ef 100644
--- a/src/java/org/apache/fop/pdf/TempFileStreamCache.java
+++ b/src/java/org/apache/fop/pdf/TempFileStreamCache.java
@@ -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;
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
index ea861511b..0e648a488 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
@@ -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 "