You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2014/09/13 18:49:49 UTC

svn commit: r1624765 - in /pdfbox/trunk: examples/src/main/java/org/apache/pdfbox/examples/lucene/ pdfbox/src/main/java/org/apache/pdfbox/cos/ pdfbox/src/main/java/org/apache/pdfbox/pdfparser/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ pdfbox/src/...

Author: lehmi
Date: Sat Sep 13 16:49:48 2014
New Revision: 1624765

URL: http://svn.apache.org/r1624765
Log:
PDFBOX-2301: remove the usage of a scratch file

Modified:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/lucene/LucenePDFDocument.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/VisualSignatureParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDObjectStream.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Overlay.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestNonSequentialPDFParser.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestFDF.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/function/TestPDFunctionType4.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
    pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/utils/TestCOSUtils.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFSplit.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/WriteDecodedDoc.java

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/lucene/LucenePDFDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/lucene/LucenePDFDocument.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/lucene/LucenePDFDocument.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/lucene/LucenePDFDocument.java Sat Sep 13 16:49:48 2014
@@ -433,7 +433,7 @@ public class LucenePDFDocument
         {
             if (useNonSeqParser)
             {
-                pdfDocument = PDDocument.loadNonSeq(is, null, "");
+                pdfDocument = PDDocument.loadNonSeq(is, "");
             }
             else
             {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java Sat Sep 13 16:49:48 2014
@@ -28,9 +28,6 @@ import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.io.RandomAccess;
-import org.apache.pdfbox.io.RandomAccessBuffer;
-import org.apache.pdfbox.io.RandomAccessFile;
 import org.apache.pdfbox.pdfparser.NonSequentialPDFParser;
 import org.apache.pdfbox.pdfparser.PDFObjectStreamParser;
 import org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface;
@@ -40,7 +37,7 @@ import org.apache.pdfbox.persistence.uti
  * This is the in-memory representation of the PDF document.  You need to call
  * close() on this object when you are done using it!!
  *
- * @author <a href="ben@benlitchfield.com">Ben Litchfield</a>
+ * @author Ben Litchfield
  * 
  */
 public class COSDocument extends COSBase implements Closeable
@@ -76,13 +73,6 @@ public class COSDocument extends COSBase
      */
     private SignatureInterface signatureInterface;
 
-    /**
-     * This file will store the streams in order to conserve memory.
-     */
-    private final RandomAccess scratchFile;
-
-    private final File tmpFile;
-
     private String headerString = "%PDF-" + version;
 
     private boolean warnMissingClose = true;
@@ -111,10 +101,8 @@ public class COSDocument extends COSBase
      * @param forceParsingValue flag to skip malformed or otherwise unparseable
      *                     document content where possible
      */
-    public COSDocument(RandomAccess scratchFileValue, boolean forceParsingValue) 
+    public COSDocument(boolean forceParsingValue) 
     {
-        scratchFile = scratchFileValue;
-        tmpFile = null;
         forceParsing = forceParsingValue;
     }
 
@@ -131,8 +119,6 @@ public class COSDocument extends COSBase
      */
     public COSDocument(File scratchDir, boolean forceParsingValue) throws IOException 
     {
-        tmpFile = File.createTempFile("pdfbox-", ".tmp", scratchDir);
-        scratchFile = new RandomAccessFile(tmpFile, "rw");
         forceParsing = forceParsingValue;
     }
 
@@ -141,7 +127,7 @@ public class COSDocument extends COSBase
      */
     public COSDocument()
     {
-        this(new RandomAccessBuffer(), false);
+        this(false);
     }
 
     /**
@@ -158,47 +144,13 @@ public class COSDocument extends COSBase
     }
 
     /**
-     * Constructor that will use the following random access file for storage
-     * of the PDF streams.  The client of this method is responsible for deleting
-     * the storage if necessary that this file will write to.  The close method
-     * will close the file though.
-     *
-     * @param file The random access file to use for storage.
-     */
-    public COSDocument(RandomAccess file) 
-    {
-        this(file, false);
-    }
-
-    /**
-     * This will get the scratch file for this document.
-     *
-     * @return The scratch file.
-     * 
-     * 
-     */
-    public RandomAccess getScratchFile()
-    {
-        // TODO the direct access to the scratch file should be removed.
-        if (!closed)
-        {
-            return scratchFile;
-        }
-        else
-        {
-            LOG.error("Can't access the scratch file as it is already closed!");
-            return null;
-        }
-    }
-
-    /**
      * Create a new COSStream using the underlying scratch file.
      * 
      * @return the new COSStream
      */
     public COSStream createCOSStream()
     {
-        return new COSStream( getScratchFile() );
+        return new COSStream( );
     }
 
     /**
@@ -210,7 +162,7 @@ public class COSDocument extends COSBase
      */
     public COSStream createCOSStream(COSDictionary dictionary)
     {
-        return new COSStream( dictionary, getScratchFile() );
+        return new COSStream( dictionary );
     }
 
     /**
@@ -577,11 +529,6 @@ public class COSDocument extends COSBase
     {
         if (!closed) 
         {
-            scratchFile.close();
-            if (tmpFile != null) 
-            {
-                tmpFile.delete();
-            }
             if (trailer != null)
             {
             	trailer.clear();

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java Sat Sep 13 16:49:48 2014
@@ -33,7 +33,6 @@ import org.apache.pdfbox.filter.FilterFa
 import org.apache.pdfbox.io.IOUtils;
 import org.apache.pdfbox.io.RandomAccess;
 import org.apache.pdfbox.io.RandomAccessBuffer;
-import org.apache.pdfbox.io.RandomAccessFile;
 import org.apache.pdfbox.io.RandomAccessFileInputStream;
 import org.apache.pdfbox.io.RandomAccessFileOutputStream;
 import org.apache.pdfbox.pdfparser.PDFStreamParser;
@@ -52,7 +51,7 @@ public class COSStream extends COSDictio
 
     private static final int BUFFER_SIZE=16384;
 
-    private RandomAccess file;
+    private RandomAccess buffer;
     /**
      * The stream with all of the filters applied.
      */
@@ -64,37 +63,48 @@ public class COSStream extends COSDictio
     private RandomAccessFileOutputStream unFilteredStream;
     private DecodeResult decodeResult;
 
-    private RandomAccess clone (RandomAccess file) {
-        if (file == null) {
-            return null;
-        } else if (file instanceof RandomAccessFile) {
-            return file;
-        } else {
-            return ((RandomAccessBuffer)file).clone();
-        }
+    /**
+     * Constructor.  Creates a new stream with an empty dictionary.
+     *
+     */
+    public COSStream( )
+    {
+        super();
+        buffer = new RandomAccessBuffer();
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param dictionary The dictionary that is associated with this stream.
+     * 
+     */
+    public COSStream( COSDictionary dictionary )
+    {
+        super( dictionary );
+        buffer = new RandomAccessBuffer();
     }
 
     /**
      * Constructor.  Creates a new stream with an empty dictionary.
      *
-     * @param storage The intermediate storage for the stream.
      */
-    public COSStream( RandomAccess storage )
+    protected COSStream( RandomAccessBuffer randomBuffer )
     {
         super();
-        file = clone(storage);
+        buffer = randomBuffer;
     }
 
     /**
      * Constructor.
      *
      * @param dictionary The dictionary that is associated with this stream.
-     * @param storage The intermediate storage for the stream.
+     * 
      */
-    public COSStream( COSDictionary dictionary, RandomAccess storage )
+    protected COSStream( COSDictionary dictionary, RandomAccessBuffer randomBuffer  )
     {
         super( dictionary );
-        file = clone(storage);
+        buffer = randomBuffer;
     }
 
     /**
@@ -108,22 +118,12 @@ public class COSStream extends COSDictio
     {
         this.clear();
         this.addAll( stream );
-        file = stream.file;
+        buffer = stream.buffer;
         filteredStream = stream.filteredStream;
         unFilteredStream = stream.unFilteredStream;
     }
 
     /**
-     * This will get the scratch file associated with this stream.
-     *
-     * @return The scratch file where this stream is being stored.
-     */
-    public RandomAccess getScratchFile()
-    {
-        return file;
-    }
-
-    /**
      * This will get all the tokens in the stream.
      *
      * @return All of the tokens in the stream.
@@ -154,7 +154,7 @@ public class COSStream extends COSDictio
         long length = filteredStream.getLengthWritten();
 
         RandomAccessFileInputStream input =
-            new RandomAccessFileInputStream( file, position, length );
+            new RandomAccessFileInputStream( buffer, position, length );
         return new BufferedInputStream( input, BUFFER_SIZE );
     }
 
@@ -196,7 +196,7 @@ public class COSStream extends COSDictio
             long position = unFilteredStream.getPosition();
             long length = unFilteredStream.getLengthWritten();
             RandomAccessFileInputStream input =
-                new RandomAccessFileInputStream( file, position, length );
+                new RandomAccessFileInputStream( buffer, position, length );
             retval = new BufferedInputStream( input, BUFFER_SIZE );
         }
         else
@@ -317,7 +317,7 @@ public class COSStream extends COSDictio
             //some filters don't work when attempting to decode
             //with a zero length stream.  See zlib_error_01.pdf
             IOUtils.closeQuietly(unFilteredStream);
-            unFilteredStream = new RandomAccessFileOutputStream( file );
+            unFilteredStream = new RandomAccessFileOutputStream( buffer );
             done = true;
         }
         else
@@ -331,9 +331,9 @@ public class COSStream extends COSDictio
                 try
                 {
                     input = new BufferedInputStream(
-                        new RandomAccessFileInputStream( file, position, length ), BUFFER_SIZE );
+                        new RandomAccessFileInputStream( buffer, position, length ), BUFFER_SIZE );
                     IOUtils.closeQuietly(unFilteredStream);
-                    unFilteredStream = new RandomAccessFileOutputStream( file );
+                    unFilteredStream = new RandomAccessFileOutputStream( buffer );
                     decodeResult = filter.decode( input, unFilteredStream, this, filterIndex );
                     done = true;
                 }
@@ -359,9 +359,9 @@ public class COSStream extends COSDictio
                     try
                     {
                         input = new BufferedInputStream(
-                            new RandomAccessFileInputStream( file, position, length ), BUFFER_SIZE );
+                            new RandomAccessFileInputStream( buffer, position, length ), BUFFER_SIZE );
                         IOUtils.closeQuietly(unFilteredStream);
-                        unFilteredStream = new RandomAccessFileOutputStream( file );
+                        unFilteredStream = new RandomAccessFileOutputStream( buffer );
                         decodeResult = filter.decode( input, unFilteredStream, this, filterIndex);
                         done = true;
                     }
@@ -426,10 +426,10 @@ public class COSStream extends COSDictio
         Filter filter = FilterFactory.INSTANCE.getFilter( filterName );
 
         InputStream input = new BufferedInputStream(
-            new RandomAccessFileInputStream( file, filteredStream.getPosition(),
+            new RandomAccessFileInputStream( buffer, filteredStream.getPosition(),
                                                    filteredStream.getLength() ), BUFFER_SIZE );
         IOUtils.closeQuietly(filteredStream);
-        filteredStream = new RandomAccessFileOutputStream( file );
+        filteredStream = new RandomAccessFileOutputStream( buffer );
         filter.encode( input, filteredStream, this, filterIndex );
         IOUtils.closeQuietly(input);
     }
@@ -462,7 +462,7 @@ public class COSStream extends COSDictio
         IOUtils.closeQuietly(unFilteredStream);
         unFilteredStream = null;
         IOUtils.closeQuietly(filteredStream);
-        filteredStream = new RandomAccessFileOutputStream( file );
+        filteredStream = new RandomAccessFileOutputStream( buffer );
         return new BufferedOutputStream( filteredStream, BUFFER_SIZE );
     }
 
@@ -516,7 +516,7 @@ public class COSStream extends COSDictio
         IOUtils.closeQuietly(filteredStream);
         filteredStream = null;
         IOUtils.closeQuietly(unFilteredStream);
-        unFilteredStream = new RandomAccessFileOutputStream( file );
+        unFilteredStream = new RandomAccessFileOutputStream( buffer );
         return new BufferedOutputStream( unFilteredStream, BUFFER_SIZE );
     }
     
@@ -525,10 +525,10 @@ public class COSStream extends COSDictio
     {
         try
         {
-            if (file != null)
+            if (buffer != null)
             {
-                file.close();
-                file = null;
+                buffer.close();
+                buffer = null;
             }
         }
         catch (IOException exception)

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java Sat Sep 13 16:49:48 2014
@@ -39,7 +39,6 @@ import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.cos.COSString;
 import org.apache.pdfbox.io.IOUtils;
 import org.apache.pdfbox.io.PushBackInputStream;
-import org.apache.pdfbox.io.RandomAccess;
 import org.apache.pdfbox.persistence.util.COSObjectKey;
 
 /**
@@ -403,16 +402,15 @@ public abstract class BaseParser
     /**
      * This will read a COSStream from the input stream.
      *
-     * @param file The file to write the stream to when reading.
      * @param dic The dictionary that goes with this stream.
      *
      * @return The parsed pdf stream.
      *
      * @throws IOException If there is an error reading the stream.
      */
-    protected COSStream parseCOSStream( COSDictionary dic, RandomAccess file ) throws IOException
+    protected COSStream parseCOSStream( COSDictionary dic ) throws IOException
     {
-        COSStream stream = new COSStream( dic, file );
+        COSStream stream = new COSStream( dic );
         OutputStream out = null;
         try
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java Sat Sep 13 16:49:48 2014
@@ -52,8 +52,6 @@ import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.cos.COSString;
 import org.apache.pdfbox.io.IOUtils;
 import org.apache.pdfbox.io.PushBackInputStream;
-import org.apache.pdfbox.io.RandomAccess;
-import org.apache.pdfbox.io.RandomAccessBuffer;
 import org.apache.pdfbox.io.RandomAccessBufferedFileInputStream;
 import org.apache.pdfbox.pdfparser.XrefTrailerResolver.XRefType;
 import org.apache.pdfbox.pdmodel.PDPage;
@@ -158,24 +156,25 @@ public class NonSequentialPDFParser exte
     }
 
     /**
-     * Constructs parser for given file using given buffer for temporary storage.
+     * Constructs parser for given file using given buffer for temporary
+     * storage.
      * 
      * @param file the pdf to be parsed
-     * @param raBuf the buffer to be used for parsing
      * 
      * @throws IOException If something went wrong.
      */
     /**
-     * Constructs parser for given file using given buffer for temporary storage.
+     * Constructs parser for given file using given buffer for temporary
+     * storage.
      * 
      * @param file the pdf to be parsed
      * @param raBuf the buffer to be used for parsing
      * 
      * @throws IOException If something went wrong.
      */
-    public NonSequentialPDFParser(File file, RandomAccess raBuf) throws IOException
+    public NonSequentialPDFParser(File file) throws IOException
     {
-        this(file, raBuf, "");
+        this(file,  "");
     }
 
     /**
@@ -195,16 +194,16 @@ public class NonSequentialPDFParser exte
      * 
      * @throws IOException If something went wrong.
      */
-    public NonSequentialPDFParser(File file, RandomAccess raBuf, String decryptionPassword)
+    public NonSequentialPDFParser(File file, String decryptionPassword)
             throws IOException
     {
-        super(EMPTY_INPUT_STREAM, null, false);
+        super(EMPTY_INPUT_STREAM, false);
         pdfFile = file;
         raStream = new RandomAccessBufferedFileInputStream(pdfFile);
-        init(file, raBuf, decryptionPassword);
+        init(file, decryptionPassword);
     }
 
-    private void init(File file, RandomAccess raBuf, String decryptionPassword) throws IOException
+    private void init(File file, String decryptionPassword) throws IOException
     {
         String eofLookupRangeStr = System.getProperty(SYSPROP_EOFLOOKUPRANGE);
         if (eofLookupRangeStr != null)
@@ -220,8 +219,7 @@ public class NonSequentialPDFParser exte
             }
         }
 
-        setDocument((raBuf == null) ? new COSDocument(new RandomAccessBuffer(), false) : new COSDocument(
-                raBuf, false));
+        setDocument(new COSDocument(false));
 
         pdfSource = new PushBackInputStream(raStream, 4096);
 
@@ -236,24 +234,23 @@ public class NonSequentialPDFParser exte
      */
     public NonSequentialPDFParser(InputStream input) throws IOException
     {
-        this(input, null, "");
+        this(input, "");
     }
 
     /**
      * Constructor.
      * 
      * @param input input stream representing the pdf.
-     * @param raBuf the buffer to be used for parsing
      * @param decryptionPassword password to be used for decryption.
      * @throws IOException If something went wrong.
      */
-    public NonSequentialPDFParser(InputStream input, RandomAccess raBuf, String decryptionPassword)
+    public NonSequentialPDFParser(InputStream input, String decryptionPassword)
             throws IOException
     {
-        super(EMPTY_INPUT_STREAM, null, false);
+        super(EMPTY_INPUT_STREAM, false);
         pdfFile = createTmpFile(input);
         raStream = new RandomAccessBufferedFileInputStream(pdfFile);
-        init(pdfFile, raBuf, decryptionPassword);
+        init(pdfFile, decryptionPassword);
     }
 
     /**
@@ -511,7 +508,7 @@ public class NonSequentialPDFParser exte
         readPattern(OBJ_MARKER);
 
         COSDictionary dict = parseCOSDictionary();
-        COSStream xrefStream = parseCOSStream(dict, getDocument().getScratchFile());
+        COSStream xrefStream = parseCOSStream(dict);
         parseXrefStream(xrefStream, (int) objByteOffset, isStandalone);
 
         return dict.getLong(COSName.PREV);
@@ -1246,8 +1243,7 @@ public class NonSequentialPDFParser exte
                     pdfSource.unread(' ');
                     if (pb instanceof COSDictionary)
                     {
-                        COSStream stream = parseCOSStream((COSDictionary) pb, getDocument()
-                                .getScratchFile());
+                        COSStream stream = parseCOSStream((COSDictionary) pb);
 
                         if (securityHandler != null)
                         {
@@ -1473,7 +1469,6 @@ public class NonSequentialPDFParser exte
      * 'endstream' to be found after stream data is read.
      * 
      * @param dic dictionary that goes with this stream.
-     * @param file file to write the stream to when reading.
      * 
      * @return parsed pdf stream.
      * 
@@ -1481,9 +1476,9 @@ public class NonSequentialPDFParser exte
      * does not end with 'endstream' after data read, stream too short etc.
      */
     @Override
-    protected COSStream parseCOSStream(COSDictionary dic, RandomAccess file) throws IOException
+    protected COSStream parseCOSStream(COSDictionary dic) throws IOException
     {
-        final COSStream stream = new COSStream(dic, file);
+        final COSStream stream = new COSStream(dic);
         OutputStream out = null;
         try
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java Sat Sep 13 16:49:48 2014
@@ -34,7 +34,6 @@ import org.apache.pdfbox.cos.COSInteger;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.cos.COSStream;
-import org.apache.pdfbox.io.RandomAccess;
 import org.apache.pdfbox.pdfparser.XrefTrailerResolver.XRefType;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.fdf.FDFDocument;
@@ -43,8 +42,7 @@ import org.apache.pdfbox.persistence.uti
 /**
  * This class will handle the parsing of the PDF document.
  *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.53 $
+ * @author Ben Litchfield
  */
 public class PDFParser extends BaseParser
 {
@@ -78,8 +76,6 @@ public class PDFParser extends BaseParse
      */
     private File tempDirectory = null;
 
-    private RandomAccess raf = null;
-
     /**
      * Constructor.
      *
@@ -89,35 +85,21 @@ public class PDFParser extends BaseParse
      */
     public PDFParser( InputStream input ) throws IOException 
     {
-        this(input, null, FORCE_PARSING);
-    }
-
-    /**
-     * Constructor to allow control over RandomAccessFile.
-     * @param input The input stream that contains the PDF document.
-     * @param rafi The RandomAccessFile to be used in internal COSDocument
-     *
-     * @throws IOException If there is an error initializing the stream.
-     */
-    public PDFParser(InputStream input, RandomAccess rafi) throws IOException 
-    {
-        this(input, rafi, FORCE_PARSING);
+        this(input, FORCE_PARSING);
     }
 
     /**
      * Constructor to allow control over RandomAccessFile.
      * Also enables parser to skip corrupt objects to try and force parsing
      * @param input The input stream that contains the PDF document.
-     * @param rafi The RandomAccessFile to be used in internal COSDocument
      * @param force When true, the parser will skip corrupt pdf objects and
      * will continue parsing at the next object in the file
      *
      * @throws IOException If there is an error initializing the stream.
      */
-    public PDFParser(InputStream input, RandomAccess rafi, boolean force) throws IOException 
+    public PDFParser(InputStream input, boolean force) throws IOException 
     {
         super(input, force);
-        this.raf = rafi;
     }
 
     /**
@@ -157,20 +139,13 @@ public class PDFParser extends BaseParse
     {
         try
         {
-            if ( raf == null )
+            if( tempDirectory != null )
             {
-                if( tempDirectory != null )
-                {
-                    document = new COSDocument( tempDirectory );
-                }
-                else
-                {
-                    document = new COSDocument();
-                }
+                document = new COSDocument( tempDirectory );
             }
             else
             {
-                document = new COSDocument( raf );
+                document = new COSDocument();
             }
             setDocument( document );
 
@@ -599,7 +574,7 @@ public class PDFParser extends BaseParse
                 pdfSource.unread( ' ' );
                 if( pb instanceof COSDictionary )
                 {
-                    pb = parseCOSStream( (COSDictionary)pb, getDocument().getScratchFile() );
+                    pb = parseCOSStream( (COSDictionary)pb );
 
                     // test for XRef type
                     final COSStream strmObj = (COSStream) pb;

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java Sat Sep 13 16:49:48 2014
@@ -33,7 +33,6 @@ import org.apache.pdfbox.cos.COSNull;
 import org.apache.pdfbox.cos.COSNumber;
 import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.cos.COSStream;
-import org.apache.pdfbox.io.RandomAccess;
 import org.apache.pdfbox.pdmodel.common.PDStream;
 import org.apache.pdfbox.util.operator.Operator;
 
@@ -46,7 +45,7 @@ import org.apache.pdfbox.util.operator.O
 public class PDFStreamParser extends BaseParser
 {
     private List<Object> streamObjects = new ArrayList<Object>( 100 );
-    private final RandomAccess file;
+//    private final RandomAccess file;
     private final int    maxBinCharTestLength = 10;
     private final byte[] binCharTestArr = new byte[maxBinCharTestLength];
 
@@ -60,26 +59,24 @@ public class PDFStreamParser extends Bas
      *                     input where possible
      * @throws IOException If there is an error reading from the stream.
      */
-    public PDFStreamParser(
-            InputStream stream, RandomAccess raf, boolean forceParsing)
+    public PDFStreamParser(InputStream stream,  boolean forceParsing)
             throws IOException 
     {
         super(stream, forceParsing);
-        file = raf;
+//        file = raf;
     }
 
     /**
      * Constructor that takes a stream to parse.
      *
      * @param stream The stream to read data from.
-     * @param raf The random access file.
      *
      * @throws IOException If there is an error reading from the stream.
      */
-    public PDFStreamParser(InputStream stream, RandomAccess raf)
+    public PDFStreamParser(InputStream stream)
             throws IOException 
     {
-        this(stream, raf, FORCE_PARSING);
+        this(stream, FORCE_PARSING);
     }
 
     /**
@@ -91,7 +88,7 @@ public class PDFStreamParser extends Bas
      */
     public PDFStreamParser( PDStream stream ) throws IOException
     {
-       this( stream.createInputStream(), stream.getStream().getScratchFile() );
+       this( stream.createInputStream() );
     }
 
     /**
@@ -106,7 +103,7 @@ public class PDFStreamParser extends Bas
     public PDFStreamParser(COSStream stream, boolean forceParsing)
             throws IOException 
     {
-       this(stream.getUnfilteredStream(), stream.getScratchFile(), forceParsing);
+       this(stream.getUnfilteredStream(), forceParsing);
     }
 
     /**
@@ -118,7 +115,7 @@ public class PDFStreamParser extends Bas
      */
     public PDFStreamParser( COSStream stream ) throws IOException
     {
-       this( stream.getUnfilteredStream(), stream.getScratchFile() );
+       this( stream.getUnfilteredStream() );
     }
 
     /**
@@ -253,7 +250,7 @@ public class PDFStreamParser extends Bas
                     skipSpaces();
                     if((char)pdfSource.peek() == 's')
                     {
-                        retval = parseCOSStream( pod, file );
+                        retval = parseCOSStream( pod );
                     }
                     else
                     {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java Sat Sep 13 16:49:48 2014
@@ -33,12 +33,10 @@ import org.apache.pdfbox.cos.COSInteger;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.cos.COSStream;
-import org.apache.pdfbox.io.RandomAccessBuffer;
 import org.apache.pdfbox.pdfwriter.COSWriterXRefEntry;
 
 /**
  * @author Alexander Funk
- * @version $Revision: $
  */
 public class PDFXRefStream implements PDFXRef
 {
@@ -62,7 +60,7 @@ public class PDFXRefStream implements PD
      */
     public PDFXRefStream()
     {
-        this.stream = new COSStream(new COSDictionary(), new RandomAccessBuffer());
+        this.stream = new COSStream(new COSDictionary());
         streamData = new TreeMap<Integer, Object>();
         objectNumbers = new TreeSet<Integer>();
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/VisualSignatureParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/VisualSignatureParser.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/VisualSignatureParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/VisualSignatureParser.java Sat Sep 13 16:49:48 2014
@@ -231,7 +231,7 @@ public class VisualSignatureParser exten
                 pdfSource.unread(' ');
                 if(pb instanceof COSDictionary) 
                 {
-                    pb = parseCOSStream((COSDictionary) pb, getDocument().getScratchFile());
+                    pb = parseCOSStream((COSDictionary) pb);
 
                 } 
                 else 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Sat Sep 13 16:49:48 2014
@@ -38,7 +38,6 @@ import org.apache.pdfbox.cos.COSInteger;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.cos.COSStream;
-import org.apache.pdfbox.io.RandomAccess;
 import org.apache.pdfbox.pdfparser.BaseParser;
 import org.apache.pdfbox.pdfparser.NonSequentialPDFParser;
 import org.apache.pdfbox.pdfparser.PDFParser;
@@ -934,21 +933,6 @@ public class PDDocument implements Close
     }
 
     /**
-     * This will load a document from a url.
-     * 
-     * @param url The url to load the PDF from.
-     * @param scratchFile A location to store temp PDFBox data for this document.
-     * 
-     * @return The document that was loaded.
-     * 
-     * @throws IOException If there is an error reading from the stream.
-     */
-    public static PDDocument load(URL url, RandomAccess scratchFile) throws IOException
-    {
-        return load(url.openStream(), scratchFile);
-    }
-
-    /**
      * This will load a document from a file.
      * 
      * @param filename The name of the file to load.
@@ -981,21 +965,6 @@ public class PDDocument implements Close
     /**
      * This will load a document from a file.
      * 
-     * @param filename The name of the file to load.
-     * @param scratchFile A location to store temp PDFBox data for this document.
-     * 
-     * @return The document that was loaded.
-     * 
-     * @throws IOException If there is an error reading from the stream.
-     */
-    public static PDDocument load(String filename, RandomAccess scratchFile) throws IOException
-    {
-        return load(new File(filename), scratchFile, false);
-    }
-
-    /**
-     * This will load a document from a file.
-     * 
      * @param file The name of the file to load.
      * 
      * @return The document that was loaded.
@@ -1020,67 +989,7 @@ public class PDDocument implements Close
      */
     public static PDDocument load(File file, boolean force) throws IOException
     {
-        return load(file, null, force);
-    }
-
-    /**
-     * This will load a document from an input stream.
-     * 
-     * @param input The stream that contains the document.
-     * 
-     * @return The document that was loaded.
-     * 
-     * @throws IOException If there is an error reading from the stream.
-     */
-    public static PDDocument load(InputStream input) throws IOException
-    {
-        return load(input, null);
-    }
-
-    /**
-     * This will load a document from an input stream. Allows for skipping corrupt pdf objects
-     * 
-     * @param input The stream that contains the document.
-     * @param force When true, the parser will skip corrupt pdf objects and will continue parsing at the next object in
-     *            the file
-     * 
-     * @return The document that was loaded.
-     * 
-     * @throws IOException If there is an error reading from the stream.
-     */
-    public static PDDocument load(InputStream input, boolean force) throws IOException
-    {
-        return load(input, null, force);
-    }
-
-    /**
-     * This will load a document from an input stream.
-     *
-     * @param file The name of the file to load.
-     * @param scratchFile A location to store temp PDFBox data for this document.
-     * @return The document that was loaded.
-     *
-     * @throws IOException If there is an error reading from the stream.
-     */
-    public static PDDocument load(File file, RandomAccess scratchFile) throws IOException
-    {
-        return load(file, scratchFile, false);
-    }
-
-    /**
-     * This will load a document from an input stream.
-     *
-     * @param file The name of the file to load.
-     * @param scratchFile A location to store temp PDFBox data for this document.
-     * @param force When true, the parser will skip corrupt pdf objects and will continue parsing at the next object in
-     *            the file
-     * @return The document that was loaded.
-     *
-     * @throws IOException If there is an error reading from the stream.
-     */
-    public static PDDocument load(File file, RandomAccess scratchFile, boolean force) throws IOException
-    {
-        PDFParser parser = new PDFParser(new FileInputStream(file), scratchFile, force);
+        PDFParser parser = new PDFParser(new FileInputStream(file), force);
         parser.parse();
         PDDocument doc = parser.getPDDocument();
         doc.incrementalFile = file;
@@ -1091,15 +1000,14 @@ public class PDDocument implements Close
      * This will load a document from an input stream.
      * 
      * @param input The stream that contains the document.
-     * @param scratchFile A location to store temp PDFBox data for this document.
      * 
      * @return The document that was loaded.
      * 
      * @throws IOException If there is an error reading from the stream.
      */
-    public static PDDocument load(InputStream input, RandomAccess scratchFile) throws IOException
+    public static PDDocument load(InputStream input) throws IOException
     {
-        PDFParser parser = new PDFParser(input, scratchFile);
+        PDFParser parser = new PDFParser(input);
         parser.parse();
         return parser.getPDDocument();
     }
@@ -1108,7 +1016,6 @@ public class PDDocument implements Close
      * This will load a document from an input stream. Allows for skipping corrupt pdf objects
      * 
      * @param input The stream that contains the document.
-     * @param scratchFile A location to store temp PDFBox data for this document.
      * @param force When true, the parser will skip corrupt pdf objects and will continue parsing at the next object in
      *            the file
      * 
@@ -1116,9 +1023,9 @@ public class PDDocument implements Close
      * 
      * @throws IOException If there is an error reading from the stream.
      */
-    public static PDDocument load(InputStream input, RandomAccess scratchFile, boolean force) throws IOException
+    public static PDDocument load(InputStream input, boolean force) throws IOException
     {
-        PDFParser parser = new PDFParser(input, scratchFile, force);
+        PDFParser parser = new PDFParser(input, force);
         parser.parse();
         return parser.getPDDocument();
     }
@@ -1127,31 +1034,29 @@ public class PDDocument implements Close
      * Parses PDF with non sequential parser.
      * 
      * @param file file to be loaded
-     * @param scratchFile location to store temp PDFBox data for this document
      * 
      * @return loaded document
      * 
      * @throws IOException in case of a file reading or parsing error
      */
-    public static PDDocument loadNonSeq(File file, RandomAccess scratchFile) throws IOException
+    public static PDDocument loadNonSeq(File file) throws IOException
     {
-        return loadNonSeq(file, scratchFile, "");
+        return loadNonSeq(file, "");
     }
 
     /**
      * Parses PDF with non sequential parser.
      * 
      * @param file file to be loaded
-     * @param scratchFile location to store temp PDFBox data for this document
      * @param password password to be used for decryption
      * 
      * @return loaded document
      * 
      * @throws IOException in case of a file reading or parsing error
      */
-    public static PDDocument loadNonSeq(File file, RandomAccess scratchFile, String password) throws IOException
+    public static PDDocument loadNonSeq(File file, String password) throws IOException
     {
-        NonSequentialPDFParser parser = new NonSequentialPDFParser(file, scratchFile, password);
+        NonSequentialPDFParser parser = new NonSequentialPDFParser(file, password);
         parser.parse();
         return parser.getPDDocument();
     }
@@ -1160,32 +1065,30 @@ public class PDDocument implements Close
      * Parses PDF with non sequential parser.
      * 
      * @param input stream that contains the document.
-     * @param scratchFile location to store temp PDFBox data for this document
      * 
      * @return loaded document
      * 
      * @throws IOException in case of a file reading or parsing error
      */
-    public static PDDocument loadNonSeq(InputStream input, RandomAccess scratchFile) throws IOException
+    public static PDDocument loadNonSeq(InputStream input) throws IOException
     {
-        return loadNonSeq(input, scratchFile, "");
+        return loadNonSeq(input, "");
     }
 
     /**
      * Parses PDF with non sequential parser.
      * 
      * @param input stream that contains the document.
-     * @param scratchFile location to store temp PDFBox data for this document
      * @param password password to be used for decryption
      * 
      * @return loaded document
      * 
      * @throws IOException in case of a file reading or parsing error
      */
-    public static PDDocument loadNonSeq(InputStream input, RandomAccess scratchFile, String password)
+    public static PDDocument loadNonSeq(InputStream input, String password)
             throws IOException
     {
-        NonSequentialPDFParser parser = new NonSequentialPDFParser(input, scratchFile, password);
+        NonSequentialPDFParser parser = new NonSequentialPDFParser(input, password);
         parser.parse();
         return parser.getPDDocument();
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java Sat Sep 13 16:49:48 2014
@@ -33,8 +33,6 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.cos.ICOSVisitor;
 
-import org.apache.pdfbox.io.RandomAccess;
-
 import org.apache.pdfbox.pdfparser.PDFStreamParser;
 
 /**
@@ -60,7 +58,7 @@ public class COSStreamArray extends COSS
      */
     public COSStreamArray( COSArray array )
     {
-        super( new COSDictionary(), null );
+        super( new COSDictionary() );
         streams = array;
         if( array.size() > 0 )
         {
@@ -90,17 +88,6 @@ public class COSStreamArray extends COSS
     }
 
     /**
-     * This will get the scratch file associated with this stream.
-     *
-     * @return The scratch file where this stream is being stored.
-     * 
-     */
-    public RandomAccess getScratchFile()
-    {
-        return firstStream.getScratchFile();
-    }
-
-    /**
      * This will get an object from this streams dictionary.
      *
      * @param key The key to the object.
@@ -140,9 +127,9 @@ public class COSStreamArray extends COSS
      *
      * @throws IOException If there is an error parsing the stream.
      */
-    public List getStreamTokens() throws IOException
+    public List<Object> getStreamTokens() throws IOException
     {
-        List retval = null;
+        List<Object> retval = null;
         if( streams.size() > 0 )
         {
             PDFStreamParser parser = new PDFStreamParser( this );
@@ -151,7 +138,7 @@ public class COSStreamArray extends COSS
         }
         else
         {
-            retval = new ArrayList();
+            retval = new ArrayList<Object>();
         }
         return retval;
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDObjectStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDObjectStream.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDObjectStream.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDObjectStream.java Sat Sep 13 16:49:48 2014
@@ -27,8 +27,7 @@ import org.apache.pdfbox.pdmodel.PDDocum
  * A PDStream represents a stream in a PDF document.  Streams are tied to a single
  * PDF document.
  *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.3 $
+ * @author Ben Litchfield
  */
 public class PDObjectStream extends PDStream
 {
@@ -53,7 +52,7 @@ public class PDObjectStream extends PDSt
     {
         COSStream cosStream = document.getDocument().createCOSStream();
         PDObjectStream strm = new PDObjectStream( cosStream );
-        strm.getStream().setName( COSName.TYPE, "ObjStm" );
+        strm.getStream().setItem( COSName.TYPE, COSName.OBJ_STM );
         return strm;
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java Sat Sep 13 16:49:48 2014
@@ -45,8 +45,7 @@ import org.apache.pdfbox.pdmodel.common.
  * A PDStream represents a stream in a PDF document. Streams are tied to a
  * single PDF document.
  * 
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.17 $
+ * @author Ben Litchfield
  */
 public class PDStream implements COSObjectable
 {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java Sat Sep 13 16:49:48 2014
@@ -160,7 +160,7 @@ public final class PDAppearanceString
         if( string != null )
         {
             ByteArrayInputStream stream = new ByteArrayInputStream( string.getBytes() );
-            parser = new PDFStreamParser( stream, acroForm.getDocument().getDocument().getScratchFile() );
+            parser = new PDFStreamParser( stream );
             parser.parse();
             tokens = parser.getTokens();
         }
@@ -351,7 +351,7 @@ public final class PDAppearanceString
         if( defaultAppearance != null )
         {
             String daString = defaultAppearance.getString();
-            PDFStreamParser daParser = new PDFStreamParser(new ByteArrayInputStream( daString.getBytes("ISO-8859-1") ), null );
+            PDFStreamParser daParser = new PDFStreamParser(new ByteArrayInputStream( daString.getBytes("ISO-8859-1") ) );
             daParser.parse();
             List<Object> daTokens = daParser.getTokens();
             fontSize = calculateFontSize( pdFont, boundingBox, tokens, daTokens );
@@ -424,7 +424,7 @@ public final class PDAppearanceString
             {
                 String data = da.getString();
                 PDFStreamParser streamParser = new PDFStreamParser(
-                        new ByteArrayInputStream( data.getBytes("ISO-8859-1") ), null );
+                        new ByteArrayInputStream( data.getBytes("ISO-8859-1") ) );
                 streamParser.parse();
                 tokens = streamParser.getTokens();
             }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Overlay.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Overlay.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Overlay.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Overlay.java Sat Sep 13 16:49:48 2014
@@ -32,7 +32,6 @@ import org.apache.pdfbox.cos.COSDictiona
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.cos.COSStream;
-import org.apache.pdfbox.io.RandomAccessBuffer;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
 import org.apache.pdfbox.pdmodel.PDPage;
@@ -217,7 +216,7 @@ public class Overlay
     {
         List<COSStream> contentStreams = createContentStreamList(contents);
         // concatenate streams
-        COSStream concatStream = new COSStream(new RandomAccessBuffer());
+        COSStream concatStream = new COSStream();
         OutputStream out = concatStream.createUnfilteredStream();
         for (COSStream contentStream : contentStreams)
         {
@@ -383,7 +382,7 @@ public class Overlay
 
     private COSStream createStream(String content) throws IOException
     {
-        COSStream stream = new COSStream(new RandomAccessBuffer());
+        COSStream stream = new COSStream();
         OutputStream out = stream.createUnfilteredStream();
         out.write(content.getBytes("ISO-8859-1"));
         out.close();

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestNonSequentialPDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestNonSequentialPDFParser.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestNonSequentialPDFParser.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdfparser/TestNonSequentialPDFParser.java Sat Sep 13 16:49:48 2014
@@ -29,7 +29,6 @@ import java.io.FileInputStream;
 import java.io.FilenameFilter;
 import java.io.IOException;
 
-import org.apache.pdfbox.io.RandomAccessBuffer;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -76,7 +75,7 @@ public class TestNonSequentialPDFParser 
 
 	@Test
 	public void testNonSequentialPDFParserFileRandomAccess() throws IOException {
-		NonSequentialPDFParser nsp = new NonSequentialPDFParser(new File(PATH_OF_PDF), new RandomAccessBuffer());
+		NonSequentialPDFParser nsp = new NonSequentialPDFParser(new File(PATH_OF_PDF));
 		executeParserTest(nsp);
 	}
 

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestFDF.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestFDF.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestFDF.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestFDF.java Sat Sep 13 16:49:48 2014
@@ -278,7 +278,7 @@ public class TestFDF extends TestCase
         if( string != null )
         {
             ByteArrayInputStream stream = new ByteArrayInputStream( string.getBytes() );
-            parser = new PDFStreamParser( stream, doc.getDocument().getScratchFile() );
+            parser = new PDFStreamParser( stream );
             parser.parse();
             tokens = parser.getTokens();
         }

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java Sat Sep 13 16:49:48 2014
@@ -25,7 +25,6 @@ import java.io.InputStream;
 import java.util.Arrays;
 
 import org.apache.pdfbox.io.IOUtils;
-import org.apache.pdfbox.io.RandomAccessBuffer;
 
 import junit.framework.TestCase;
 
@@ -65,7 +64,7 @@ public class TestPDDocument extends Test
         assertEquals("%%EOF\n", new String(Arrays.copyOfRange(pdf, pdf.length - 6, pdf.length), "UTF-8"));
 
         // Load
-        PDDocument loadDoc = PDDocument.load(new ByteArrayInputStream(pdf), new RandomAccessBuffer());
+        PDDocument loadDoc = PDDocument.load(new ByteArrayInputStream(pdf));
         assertEquals(1, loadDoc.getNumberOfPages());
         loadDoc.close();
     }
@@ -94,7 +93,7 @@ public class TestPDDocument extends Test
         assertEquals("%%EOF\n", new String(Arrays.copyOfRange(pdf, pdf.length - 6, pdf.length), "UTF-8"));
 
         // Load
-        PDDocument loadDoc = PDDocument.load(targetFile, new RandomAccessBuffer());
+        PDDocument loadDoc = PDDocument.load(targetFile);
         assertEquals(1, loadDoc.getNumberOfPages());
         loadDoc.close();
     }
@@ -120,7 +119,7 @@ public class TestPDDocument extends Test
         assertEquals("%%EOF\n", new String(Arrays.copyOfRange(pdf, pdf.length - 6, pdf.length), "UTF-8"));
 
         // Load
-        PDDocument loadDoc = PDDocument.loadNonSeq(new ByteArrayInputStream(pdf), new RandomAccessBuffer());
+        PDDocument loadDoc = PDDocument.loadNonSeq(new ByteArrayInputStream(pdf));
         assertEquals(1, loadDoc.getNumberOfPages());
         loadDoc.close();
     }
@@ -149,7 +148,7 @@ public class TestPDDocument extends Test
         assertEquals("%%EOF\n", new String(Arrays.copyOfRange(pdf, pdf.length - 6, pdf.length), "UTF-8"));
 
         // Load
-        PDDocument loadDoc = PDDocument.loadNonSeq(targetFile, new RandomAccessBuffer());
+        PDDocument loadDoc = PDDocument.loadNonSeq(targetFile);
         assertEquals(1, loadDoc.getNumberOfPages());
         loadDoc.close();
     }

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/function/TestPDFunctionType4.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/function/TestPDFunctionType4.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/function/TestPDFunctionType4.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/function/TestPDFunctionType4.java Sat Sep 13 16:49:48 2014
@@ -22,7 +22,6 @@ import java.io.OutputStream;
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSStream;
-import org.apache.pdfbox.io.RandomAccessBuffer;
 
 import junit.framework.TestCase;
 
@@ -46,7 +45,7 @@ public class TestPDFunctionType4 extends
         rangeArray.setFloatArray(range);
         dict.setItem("Range", rangeArray);
 
-        COSStream functionStream = new COSStream(dict, new RandomAccessBuffer());
+        COSStream functionStream = new COSStream(dict);
         OutputStream out = functionStream.createUnfilteredStream();
         byte[] data = function.getBytes("US-ASCII");
         out.write(data, 0, data.length);

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java Sat Sep 13 16:49:48 2014
@@ -215,7 +215,7 @@ public class TestPDFToImage extends Test
             {
                 // Check for version difference between load() and loadNonSeq()
                 new FileOutputStream(new File(outDir + file.getName() + ".parseseqerror")).close();
-                PDDocument doc2 = PDDocument.load(file, null);
+                PDDocument doc2 = PDDocument.load(file);
                 if (doc2.getDocument().getVersion() != document.getDocument().getVersion())
                 {
                     new FileOutputStream(new File(outDir + file.getName() + ".versiondiff")).close();

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java Sat Sep 13 16:49:48 2014
@@ -70,7 +70,6 @@ import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.cos.COSString;
 import org.apache.pdfbox.io.IOUtils;
-import org.apache.pdfbox.io.RandomAccess;
 import org.apache.pdfbox.pdfparser.BaseParser;
 import org.apache.pdfbox.pdfparser.NonSequentialPDFParser;
 import org.apache.pdfbox.pdfparser.PDFObjectStreamParser;
@@ -103,21 +102,16 @@ public class PreflightParser extends Non
 
     protected PreflightContext ctx;
 
-    public PreflightParser(File file, RandomAccess rafi) throws IOException
+    public PreflightParser(File file) throws IOException
     {
-        super(file, rafi);
+        super(file);
         this.setLenient(false);
         this.originalDocument = new FileDataSource(file);
     }
 
-    public PreflightParser(File file) throws IOException
-    {
-        this(file, null);
-    }
-
     public PreflightParser(String filename) throws IOException
     {
-        this(new File(filename), null);
+        this(new File(filename));
     }
 
     public PreflightParser(DataSource input) throws IOException
@@ -441,10 +435,10 @@ public class PreflightParser extends Non
      * {@link #checkStreamKeyWord()} and {@link #checkEndstreamKeyWord()}
      */
     @Override
-    protected COSStream parseCOSStream(COSDictionary dic, RandomAccess file) throws IOException
+    protected COSStream parseCOSStream(COSDictionary dic) throws IOException
     {
         checkStreamKeyWord();
-        COSStream result = super.parseCOSStream(dic, file);
+        COSStream result = super.parseCOSStream(dic);
         checkEndstreamKeyWord();
         return result;
     }
@@ -741,7 +735,7 @@ public class PreflightParser extends Non
                     pdfSource.seek(endObjectOffset);
                     if (pb instanceof COSDictionary)
                     {
-                        COSStream stream = parseCOSStream((COSDictionary) pb, getDocument().getScratchFile());
+                        COSStream stream = parseCOSStream((COSDictionary) pb);
                         if (securityHandler != null)
                         {
                             securityHandler.decryptStream(stream, objNr, objGenNr);

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/utils/TestCOSUtils.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/utils/TestCOSUtils.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/utils/TestCOSUtils.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/utils/TestCOSUtils.java Sat Sep 13 16:49:48 2014
@@ -37,7 +37,6 @@ import org.apache.pdfbox.cos.COSInteger;
 import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.cos.COSString;
-import org.apache.pdfbox.io.RandomAccess;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.persistence.util.COSObjectKey;
 import org.junit.Test;
@@ -116,7 +115,7 @@ public class TestCOSUtils
     {
         try
         {
-            COSObject co = new COSObject(new COSStream(null));
+            COSObject co = new COSObject(new COSStream());
             co.setGenerationNumber(COSInteger.ZERO);
             co.setObjectNumber(COSInteger.get(10));
 
@@ -225,11 +224,6 @@ public class TestCOSUtils
             super(scratchDir);
         }
 
-        IOCOSDocument(RandomAccess file)
-        {
-            super(file);
-        }
-
         @Override
         public void close() throws IOException
         {

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java Sat Sep 13 16:49:48 2014
@@ -170,7 +170,7 @@ public class ExtractImages
         {
             if (useNonSeq)
             {
-                document = PDDocument.loadNonSeq(new File(pdfFile), null, password);
+                document = PDDocument.loadNonSeq(new File(pdfFile), password);
             }
             else
             {

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java Sat Sep 13 16:49:48 2014
@@ -207,7 +207,7 @@ public class ExtractText
                 }
                 if (useNonSeqParser) 
                 {
-                    document = PDDocument.loadNonSeq(new File( pdfFile ), null, password);
+                    document = PDDocument.loadNonSeq(new File( pdfFile ), password);
                 }
                 else
                 {

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java Sat Sep 13 16:49:48 2014
@@ -398,7 +398,7 @@ public class PDFDebugger extends javax.s
     {
         if (useNonSeqParser)
         {
-            document = PDDocument.loadNonSeq(file, null, password);
+            document = PDDocument.loadNonSeq(file, password);
         }
         else
         {

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java Sat Sep 13 16:49:48 2014
@@ -384,7 +384,7 @@ public class PDFReader extends JFrame
         document = null;
         if (useNonSeqParser)
         {
-            document = PDDocument.loadNonSeq(file, null, password);
+            document = PDDocument.loadNonSeq(file, password);
         }
         else
         {

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFSplit.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFSplit.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFSplit.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFSplit.java Sat Sep 13 16:49:48 2014
@@ -134,7 +134,7 @@ public class PDFSplit
             {
                 if (useNonSeqParser) 
                 {
-                    document = PDDocument.loadNonSeq(new File(pdfFile), null, password);
+                    document = PDDocument.loadNonSeq(new File(pdfFile), password);
                 }
                 else
                 {

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java Sat Sep 13 16:49:48 2014
@@ -194,7 +194,7 @@ public class PDFToImage
             {
                 if (useNonSeqParser)
                 {
-                    document = PDDocument.loadNonSeq(new File(pdfFile), null, password);
+                    document = PDDocument.loadNonSeq(new File(pdfFile), password);
                 }
                 else
                 {

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/WriteDecodedDoc.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/WriteDecodedDoc.java?rev=1624765&r1=1624764&r2=1624765&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/WriteDecodedDoc.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/WriteDecodedDoc.java Sat Sep 13 16:49:48 2014
@@ -83,7 +83,7 @@ public class WriteDecodedDoc
         {
             if (useNonSeqParser) 
             {
-                doc = PDDocument.loadNonSeq(new File(in), null, password);
+                doc = PDDocument.loadNonSeq(new File(in), password);
                 doc.setAllSecurityToBeRemoved(true);
             }
             else