You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2015/07/18 00:35:24 UTC
svn commit: r1691656 - in
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io: RandomAccess.java
RandomAccessBuffer.java RandomAccessFile.java RandomAccessRead.java
RandomAccessWrite.java
Author: jahewson
Date: Fri Jul 17 22:35:24 2015
New Revision: 1691656
URL: http://svn.apache.org/r1691656
Log:
PDFBOX-2301: Split RandomAccessWrite into its own interface
Added:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessWrite.java (with props)
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccess.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessBuffer.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessFile.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessRead.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccess.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccess.java?rev=1691656&r1=1691655&r2=1691656&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccess.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccess.java Fri Jul 17 22:35:24 2015
@@ -16,45 +16,13 @@
*/
package org.apache.pdfbox.io;
-import java.io.IOException;
-
/**
- * An interface to allow PDF files to be stored completely in memory or
+ * An interface to allow data to be stored completely in memory or
* to use a scratch file on the disk.
*
* @author Ben Litchfield
*/
-public interface RandomAccess extends RandomAccessRead
+public interface RandomAccess extends RandomAccessRead, RandomAccessWrite
{
-
- /**
- * Write a byte to the stream.
- *
- * @param b The byte to write.
- * @throws IOException If there is an IO error while writing.
- */
- void write(int b) throws IOException;
-
- /**
- * Write a buffer of data to the stream.
- *
- * @param b The buffer to get the data from.
- * @throws IOException If there is an error while writing the data.
- */
- void write(byte[] b) throws IOException;
-
- /**
- * Write a buffer of data to the stream.
- *
- * @param b The buffer to get the data from.
- * @param offset An offset into the buffer to get the data from.
- * @param length The length of data to write.
- * @throws IOException If there is an error while writing the data.
- */
- void write(byte[] b, int offset, int length) throws IOException;
-
- /**
- * Clears all data of the buffer.
- */
- void clear() throws IOException;
+ // super interface for both read and write
}
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessBuffer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessBuffer.java?rev=1691656&r1=1691655&r2=1691656&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessBuffer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessBuffer.java Fri Jul 17 22:35:24 2015
@@ -16,18 +16,16 @@
*/
package org.apache.pdfbox.io;
-import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
- * An implementation of the RandomAccess interface to store a pdf in memory.
+ * An implementation of the RandomAccess interface to store data in memory.
* The data will be stored in chunks organized in an ArrayList.
- *
*/
-public class RandomAccessBuffer implements RandomAccess, Closeable, Cloneable
+public class RandomAccessBuffer implements RandomAccess, Cloneable
{
// default chunk size is 1kb
private static final int DEFAULT_CHUNK_SIZE = 1024;
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessFile.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessFile.java?rev=1691656&r1=1691655&r2=1691656&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessFile.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessFile.java Fri Jul 17 22:35:24 2015
@@ -16,18 +16,17 @@
*/
package org.apache.pdfbox.io;
-import java.io.Closeable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
- * An interface to allow temp PDF data to be stored in a scratch
- * file on the disk to reduce memory consumption.
+ * A RandomAccess implementation whcih allows data to be stored in a scratch file on the disk to
+ * reduce memory consumption.
*
* @author Ben Litchfield
*/
-public class RandomAccessFile implements RandomAccess, Closeable
+public class RandomAccessFile implements RandomAccess
{
private final java.io.RandomAccessFile ras;
private boolean isClosed;
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessRead.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessRead.java?rev=1691656&r1=1691655&r2=1691656&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessRead.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessRead.java Fri Jul 17 22:35:24 2015
@@ -16,15 +16,44 @@
*/
package org.apache.pdfbox.io;
+import java.io.Closeable;
import java.io.IOException;
/**
* An interface allowing random access read operations.
*/
-public interface RandomAccessRead extends SequentialRead
+public interface RandomAccessRead extends Closeable
{
+ /**
+ * Read a single byte of data.
+ *
+ * @return The byte of data that is being read.
+ *
+ * @throws IOException If there is an error while reading the data.
+ */
+ int read() throws IOException;
+
+ /**
+ * Read a buffer of data.
+ *
+ * @param b The buffer to write the data to.
+ * @return The number of bytes that were actually read.
+ * @throws IOException If there was an error while reading the data.
+ */
+ int read(byte[] b) throws IOException;
/**
+ * Read a buffer of data.
+ *
+ * @param b The buffer to write the data to.
+ * @param offset Offset into the buffer to start writing.
+ * @param length The amount of data to attempt to read.
+ * @return The number of bytes that were actually read.
+ * @throws IOException If there was an error while reading the data.
+ */
+ int read(byte[] b, int offset, int length) throws IOException;
+
+ /**
* Returns offset of next byte to be returned by a read method.
*
* @return offset of next byte which will be returned with next {@link #read()}
Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessWrite.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessWrite.java?rev=1691656&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessWrite.java (added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessWrite.java Fri Jul 17 22:35:24 2015
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pdfbox.io;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+/**
+ * An interface allowing random access write operations.
+ */
+public interface RandomAccessWrite extends Closeable
+{
+ /**
+ * Write a byte to the stream.
+ *
+ * @param b The byte to write.
+ * @throws IOException If there is an IO error while writing.
+ */
+ void write(int b) throws IOException;
+
+ /**
+ * Write a buffer of data to the stream.
+ *
+ * @param b The buffer to get the data from.
+ * @throws IOException If there is an error while writing the data.
+ */
+ void write(byte[] b) throws IOException;
+
+ /**
+ * Write a buffer of data to the stream.
+ *
+ * @param b The buffer to get the data from.
+ * @param offset An offset into the buffer to get the data from.
+ * @param length The length of data to write.
+ * @throws IOException If there is an error while writing the data.
+ */
+ void write(byte[] b, int offset, int length) throws IOException;
+
+ /**
+ * Clears all data of the buffer.
+ */
+ void clear() throws IOException;
+}
Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessWrite.java
------------------------------------------------------------------------------
svn:eol-style = native