jeremias 2003/07/04 13:12:59
Modified: src/java/org/apache/fop/pdf TempFileStreamCache.java
InMemoryStreamCache.java
Log:
Remove unused code
Use IO methods from Commons IO
Revision Changes Path
1.3 +7 -41 xml-fop/src/java/org/apache/fop/pdf/TempFileStreamCache.java
Index: TempFileStreamCache.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/TempFileStreamCache.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TempFileStreamCache.java 27 Mar 2003 10:27:27 -0000 1.2
+++ TempFileStreamCache.java 4 Jul 2003 20:12:59 -0000 1.3
@@ -50,17 +50,15 @@
*/
package org.apache.fop.pdf;
-import org.apache.fop.util.StreamUtilities;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
+// Java
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.File;
+//Commons
+import org.apache.commons.io.IOUtil;
+
/**
* StreamCache implementation that uses temporary files rather than heap.
*/
@@ -96,8 +94,8 @@
*/
public OutputStream getOutputStream() throws IOException {
if (output == null) {
- output = new BufferedOutputStream(
- new FileOutputStream(tempFile));
+ output = new java.io.BufferedOutputStream(
+ new java.io.FileOutputStream(tempFile));
}
return output;
}
@@ -110,38 +108,6 @@
}
/**
- * Filter the cache with the supplied PDFFilter.
- *
- * @param filter the filter to apply
- * @throws IOException if there is an IO error
- */
- public void applyFilter(PDFFilter filter) throws IOException {
- if (output == null) {
- return;
- }
-
- output.close();
- output = null;
-
- // need a place to put results
- File newTempFile =
- File.createTempFile("org.apache.fop.pdf.StreamCache-",
- ".temp");
- newTempFile.deleteOnExit();
-
- // filter may not be buffered
- BufferedInputStream input =
- new BufferedInputStream(new FileInputStream(tempFile));
- BufferedOutputStream output = new BufferedOutputStream(
- new FileOutputStream(newTempFile));
- filter.encode(input, output, (int) tempFile.length());
- input.close();
- output.close();
- tempFile.delete();
- tempFile = newTempFile;
- }
-
- /**
* Outputs the cached bytes to the given stream.
*
* @param out the output stream to write to
@@ -158,7 +124,7 @@
// don't need a buffer because streamCopy is buffered
InputStream input = new java.io.FileInputStream(tempFile);
- final long bytesCopied = StreamUtilities.streamCopy(input, out);
+ final long bytesCopied = IOUtil.copy(input, out);
input.close();
return (int)bytesCopied;
}
1.3 +0 -27 xml-fop/src/java/org/apache/fop/pdf/InMemoryStreamCache.java
Index: InMemoryStreamCache.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/InMemoryStreamCache.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InMemoryStreamCache.java 27 Mar 2003 10:27:27 -0000 1.2
+++ InMemoryStreamCache.java 4 Jul 2003 20:12:59 -0000 1.3
@@ -51,7 +51,6 @@
package org.apache.fop.pdf;
import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
import java.io.OutputStream;
import java.io.IOException;
@@ -105,32 +104,6 @@
getOutputStream().write(data);
}
- /**
- * Filter the cache with the supplied PDFFilter.
- * @param filter the filter to apply
- * @throws IOException if an IO error occurs
- */
- public void applyFilter(PDFFilter filter) throws IOException {
- if (output == null) {
- return;
- }
-
- output.close();
-
- // make inputstream from copy of outputted bytes
- int size = getSize();
- ByteArrayInputStream input =
- new ByteArrayInputStream(output.toByteArray());
-
- // reset output
- output.reset();
-
- // run filter
- filter.encode(input, output, size);
- input.close();
- output.close();
- }
-
/**
* Outputs the cached bytes to the given stream.
* @param out the output stream to write to
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]