pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1674942 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io: RandomAccess.java RandomAccessBuffer.java RandomAccessFile.java
Date Mon, 20 Apr 2015 16:31:21 GMT
Author: lehmi
Date: Mon Apr 20 16:31:20 2015
New Revision: 1674942

URL: http://svn.apache.org/r1674942
Log:
PDFBOX-2301: introduced clear() to reset a buffer before reusing it without creating a new
one

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

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=1674942&r1=1674941&r2=1674942&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 Mon Apr 20 16:31:20
2015
@@ -45,4 +45,8 @@ public interface RandomAccess extends Ra
      */
     void write(byte[] b, int offset, int length) throws IOException;
 
+    /**
+     * Clears all data of the buffer.
+     */
+    void clear();
 }

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=1674942&r1=1674941&r2=1674942&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 Mon Apr
20 16:31:20 2015
@@ -23,7 +23,7 @@ import java.util.List;
 
 /**
  * An implementation of the RandomAccess interface to store a pdf in memory.
- * The data will be stored in chunks organized in an ArrayList.  
+ * The data will be stored in chunks organized in an ArrayList.
  *
  */
 public class RandomAccessBuffer implements RandomAccess, Closeable, Cloneable
@@ -105,6 +105,22 @@ public class RandomAccessBuffer implemen
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void clear()
+    {
+        bufferList.clear();
+        currentBuffer = new byte[CHUNK_SIZE];
+        bufferList.add(currentBuffer);
+        pointer = 0;
+        currentBufferPointer = 0;
+        size = 0;
+        bufferListIndex = 0;
+        bufferListMaxIndex = 0;
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override

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=1674942&r1=1674941&r2=1674942&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 Mon Apr 20
16:31:20 2015
@@ -58,6 +58,15 @@ public class RandomAccessFile implements
      * {@inheritDoc}
      */
     @Override
+    public void clear()
+    {
+        throw new java.lang.UnsupportedOperationException(RandomAccessFile.class.getName()+"clear()
isn't yet supported");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
     public void seek(long position) throws IOException
     {
         ras.seek(position);



Mime
View raw message