pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1867069 - in /pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox: cos/COSDocument.java pdfparser/FDFParser.java pdfparser/PDFParser.java
Date Tue, 17 Sep 2019 17:53:50 GMT
Author: lehmi
Date: Tue Sep 17 17:53:50 2019
New Revision: 1867069

URL: http://svn.apache.org/viewvc?rev=1867069&view=rev
Log:
PDFBOX-4569: use interface

Modified:
    pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
    pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/FDFParser.java
    pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java

Modified: pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java?rev=1867069&r1=1867068&r2=1867069&view=diff
==============================================================================
--- pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
(original)
+++ pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
Tue Sep 17 17:53:50 2019
@@ -27,7 +27,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.io.IOUtils;
 import org.apache.pdfbox.io.ScratchFile;
-import org.apache.pdfbox.pdfparser.COSParser;
 
 /**
  * This is the in-memory representation of the PDF document.  You need to call
@@ -89,14 +88,24 @@ public class COSDocument extends COSBase
      */
     private long highestXRefObjectNumber;
 
-    public COSParser parser;
+    private ICOSParser parser;
 
     /**
      * Constructor. Uses main memory to buffer PDF streams.
      */
     public COSDocument()
     {
-        this(ScratchFile.getMainMemoryOnlyInstance());
+        this(ScratchFile.getMainMemoryOnlyInstance(), null);
+    }
+
+    /**
+     * Constructor. Uses main memory to buffer PDF streams.
+     * 
+     * @param parser Parser to be used to parse the document on demand
+     */
+    public COSDocument(ICOSParser parser)
+    {
+        this(ScratchFile.getMainMemoryOnlyInstance(), parser);
     }
 
     /**
@@ -108,7 +117,20 @@ public class COSDocument extends COSBase
      */
     public COSDocument(ScratchFile scratchFile)
     {
+        this(scratchFile, null);
+    }
+
+    /**
+     * Constructor that will use the provide memory handler for storage of the PDF streams.
+     *
+     * @param scratchFile memory handler for buffering of PDF streams
+     * @param parser Parser to be used to parse the document on demand
+     * 
+     */
+    public COSDocument(ScratchFile scratchFile, ICOSParser parser)
+    {
         this.scratchFile = scratchFile;
+        this.parser = parser;
     }
 
     /**

Modified: pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/FDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/FDFParser.java?rev=1867069&r1=1867068&r2=1867069&view=diff
==============================================================================
--- pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/FDFParser.java
(original)
+++ pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/FDFParser.java
Tue Sep 17 17:53:50 2019
@@ -100,8 +100,7 @@ public class FDFParser extends COSParser
                         + " does not contain an integer value, but: '" + eofLookupRangeStr
+ "'");
             }
         }
-        document = new COSDocument();
-        document.parser = this;
+        document = new COSDocument(this);
     }
 
     /**

Modified: pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java?rev=1867069&r1=1867068&r2=1867069&view=diff
==============================================================================
--- pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
(original)
+++ pdfbox/branches/issue4569/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
Tue Sep 17 17:53:50 2019
@@ -139,8 +139,7 @@ public class PDFParser extends COSParser
                         + " does not contain an integer value, but: '" + eofLookupRangeStr
+ "'");
             }
         }
-        document = new COSDocument(scratchFile);
-        document.parser = this;
+        document = new COSDocument(scratchFile, this);
     }
     
     /**
@@ -183,7 +182,6 @@ public class PDFParser extends COSParser
         // check pages dictionaries
         checkPages(root);
         document.setDecrypted();
-        document.parser = this;
         initialParseDone = true;
     }
 



Mime
View raw message