pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1662965 - in /pdfbox/trunk: pdfbox/src/main/java/org/apache/pdfbox/cos/ pdfbox/src/main/java/org/apache/pdfbox/pdfparser/ pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/ preflight/src/main/java/org/apache/pdfbox/preflight/parser/
Date Sat, 28 Feb 2015 16:50:24 GMT
Author: lehmi
Date: Sat Feb 28 16:50:23 2015
New Revision: 1662965

URL: http://svn.apache.org/r1662965
Log:
PDFBOX-2576: changed the internal representation of the object/generation number from long
to int as proposed by Andrea Vacondio

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java?rev=1662965&r1=1662964&r2=1662965&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java Sat Feb 28 16:50:23
2015
@@ -20,12 +20,12 @@ package org.apache.pdfbox.cos;
  * Object representing the physical reference to an indirect pdf object.
  *
  * @author Michael Traut
- * @version $Revision: 1.5 $
+ * 
  */
 public class COSObjectKey implements Comparable<COSObjectKey>
 {
-    private long number;
-    private long generation;
+    private int number;
+    private int generation;
 
     /**
      * PDFObjectKey constructor comment.
@@ -34,7 +34,7 @@ public class COSObjectKey implements Com
      */
     public COSObjectKey(COSObject object)
     {
-        this( object.getObjectNumber().longValue(), object.getGenerationNumber().longValue()
);
+        this( object.getObjectNumber().intValue(), object.getGenerationNumber().intValue()
);
     }
 
     /**
@@ -43,7 +43,7 @@ public class COSObjectKey implements Com
      * @param num The object number.
      * @param gen The object generation number.
      */
-    public COSObjectKey(long num, long gen)
+    public COSObjectKey(int num, int gen)
     {
         number = num;
         generation = gen;
@@ -65,7 +65,7 @@ public class COSObjectKey implements Com
      *
      * @return The objects generation number.
      */
-    public long getGeneration()
+    public int getGeneration()
     {
         return generation;
     }
@@ -74,7 +74,7 @@ public class COSObjectKey implements Com
      *
      * @return The object's id.
      */
-    public long getNumber()
+    public int getNumber()
     {
         return number;
     }
@@ -85,14 +85,14 @@ public class COSObjectKey implements Com
     @Override
     public int hashCode()
     {
-        return (int)(number + generation);
+        return number + generation;
     }
     /**
      * This will set the objects generation number.
      *
      * @param newGeneration The objects generation number.
      */
-    public void setGeneration(long newGeneration)
+    public void setGeneration(int newGeneration)
     {
         generation = newGeneration;
     }
@@ -101,21 +101,17 @@ public class COSObjectKey implements Com
      *
      * @param newNumber The objects number.
      */
-    public void setNumber(long newNumber)
+    public void setNumber(int newNumber)
     {
         number = newNumber;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public String toString()
     {
-        return "" + getNumber() + " " + getGeneration() + " R";
+        return Integer.toString(number) + " " +  Integer.toString(generation) + " R";
     }
 
-    /** {@inheritDoc} */
     @Override
     public int compareTo(COSObjectKey other)
     {

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=1662965&r1=1662964&r2=1662965&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 Feb
28 16:50:23 2015
@@ -1658,9 +1658,9 @@ public abstract class BaseParser impleme
      * @return the object number being read.
      * @throws IOException if an I/O error occurs
      */
-    protected long readObjectNumber() throws IOException
+    protected int readObjectNumber() throws IOException
     {
-        long retval = readLong();
+        int retval = readInt();
         if (retval < 0 || retval >= OBJECT_NUMBER_THRESHOLD)
         {
             throw new IOException("Object Number '" + retval + "' has more than 10 digits
or is negative");
@@ -1826,7 +1826,7 @@ public abstract class BaseParser impleme
     protected COSObjectKey parseObjectKey(boolean continueOnError) throws IOException
     {
         //we are going to parse a normal object
-        long number = -1;
+        int number = -1;
         int genNum;
         boolean missingObjectNumber = false;
         try

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java?rev=1662965&r1=1662964&r2=1662965&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java Sat Feb 28
16:50:23 2015
@@ -569,7 +569,7 @@ public class COSParser extends BaseParse
                                 // object within object stream;
                                 // get offset of object stream
                                 fileOffset = xrefTrailerResolver.getXrefTable().get(
-                                        new COSObjectKey(-fileOffset, 0));
+                                        new COSObjectKey((int)-fileOffset, 0));
                                 if ((fileOffset == null) || (fileOffset <= 0))
                                 {
                                     throw new IOException(
@@ -787,8 +787,7 @@ public class COSParser extends BaseParse
                     parser.close();
                     // get set of object numbers referenced for this object
                     // stream
-                    final Set<Long> refObjNrs = xrefTrailerResolver
-                            .getContainedObjectNumbers(objstmObjNr);
+                    final Set<Integer> refObjNrs = xrefTrailerResolver.getContainedObjectNumbers(objstmObjNr);
 
                     // register all objects which are referenced to be contained
                     // in object stream
@@ -1279,10 +1278,10 @@ public class COSParser extends BaseParse
                                 byte[] objIDBytes = pdfSource.readFully(length);
                                 String objIdString = new String(objIDBytes, 0,
                                         objIDBytes.length, ISO_8859_1);
-                                Long objectID;
+                                Integer objectID;
                                 try
                                 {
-                                    objectID = Long.valueOf(objIdString);
+                                    objectID = Integer.valueOf(objIdString);
                                 }
                                 catch (NumberFormatException exception)
                                 {
@@ -1777,7 +1776,7 @@ public class COSParser extends BaseParse
         while(true)
         {
             // first obj id
-            long currObjID = readObjectNumber(); 
+            int currObjID = readObjectNumber(); 
             
             // the number of objects in the xref table
             long count = readLong();
@@ -1807,7 +1806,7 @@ public class COSParser extends BaseParse
                 {
                     try
                     {
-                        long currOffset = Long.parseLong(splitString[0]);
+                        int currOffset = Integer.parseInt(splitString[0]);
                         int currGenID = Integer.parseInt(splitString[1]);
                         COSObjectKey objKey = new COSObjectKey(currObjID, currGenID);
                         xrefTrailerResolver.setXRef(objKey, currOffset);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java?rev=1662965&r1=1662964&r2=1662965&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java
Sat Feb 28 16:50:23 2015
@@ -51,7 +51,7 @@ import org.apache.pdfbox.cos.COSObjectKe
  * using {@link #setStartxref(long)}. This is used to build the chain of
  * active xref/trailer objects used for creating document trailer and xref table.
  *
- * @author Timo Böhme (timo.boehme at ontochem.com)
+ * @author Timo Böhme
  */
 public class XrefTrailerResolver
 {
@@ -313,14 +313,14 @@ public class XrefTrailerResolver
      *          or <code>null</code> if {@link #setStartxref(long)} was not
      *          called before so that no resolved xref table exists
      */
-    public Set<Long> getContainedObjectNumbers( final int objstmObjNr ) 
+    public Set<Integer> getContainedObjectNumbers( final int objstmObjNr ) 
     {
         if ( resolvedXrefTrailer == null )
         {
             return null;
         }
-        final Set<Long> refObjNrs = new HashSet<Long>();
-        final int       cmpVal    = - objstmObjNr;
+        final Set<Integer> refObjNrs = new HashSet<Integer>();
+        final int cmpVal = - objstmObjNr;
         
         for ( Entry<COSObjectKey,Long> xrefEntry : resolvedXrefTrailer.xrefTable.entrySet()
) 
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1662965&r1=1662964&r2=1662965&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Sat Feb 28
16:50:23 2015
@@ -176,7 +176,7 @@ public class COSWriter implements ICOSVi
     private long startxref = 0;
 
     // the current object number
-    private long number = 0;
+    private int number = 0;
 
     // maps the object to the keys generated in the writer
     // these are used for indirect references in other objects
@@ -265,7 +265,7 @@ public class COSWriter implements ICOSVi
           
           Map<COSObjectKey, Long> xrefTable = cosDoc.getXrefTable();
           Set<COSObjectKey> keySet = xrefTable.keySet();
-          long highestNumber=0;
+          int highestNumber=0;
           for ( COSObjectKey cosObjectKey : keySet ) 
           {
             COSBase object = cosDoc.getObjectFromPool(cosObjectKey).getObject();
@@ -275,7 +275,7 @@ public class COSWriter implements ICOSVi
                 keyObject.put(cosObjectKey,object);
             }
             
-            long num = cosObjectKey.getNumber();
+            int num = cosObjectKey.getNumber();
             if (num > highestNumber)
             {
                 highestNumber=num;
@@ -327,7 +327,7 @@ public class COSWriter implements ICOSVi
      *
      * @return The current object number.
      */
-    protected long getNumber()
+    protected int getNumber()
     {
         return number;
     }
@@ -386,7 +386,7 @@ public class COSWriter implements ICOSVi
      *
      * @param newNumber The new object number.
      */
-    protected void setNumber(long newNumber)
+    protected void setNumber(int newNumber)
     {
         number = newNumber;
     }

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=1662965&r1=1662964&r2=1662965&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 Feb 28 16:50:23 2015
@@ -339,8 +339,8 @@ public class PreflightParser extends PDF
         while (true)
         {
             // just after the xref<EOL> there are an integer
-            long currObjID; // first obj id
-            long count; // the number of objects in the xref table
+            int currObjID; // first obj id
+            int count; // the number of objects in the xref table
 
             long offset = pdfSource.getOffset();
             String line = readLine();
@@ -358,7 +358,7 @@ public class PreflightParser extends PDF
                 // reset pdfSource cursor to read xref information
                 pdfSource.seek(offset);
                 currObjID = readObjectNumber(); // first obj id
-                count = readLong(); // the number of objects in the xref table
+                count = readInt(); // the number of objects in the xref table
             }
 
             skipSpaces();
@@ -390,7 +390,7 @@ public class PreflightParser extends PDF
                 {
                     try
                     {
-                        long currOffset = Long.parseLong(splitString[0]);
+                        int currOffset = Integer.parseInt(splitString[0]);
                         int currGenID = Integer.parseInt(splitString[1]);
                         COSObjectKey objKey = new COSObjectKey(currObjID, currGenID);
                         xrefTrailerResolver.setXRef(objKey, currOffset);
@@ -784,7 +784,7 @@ public class PreflightParser extends PDF
                     parser.close();
 
                     // get set of object numbers referenced for this object stream
-                    final Set<Long> refObjNrs = xrefTrailerResolver.getContainedObjectNumbers(objstmObjNr);
+                    final Set<Integer> refObjNrs = xrefTrailerResolver.getContainedObjectNumbers(objstmObjNr);
 
                     // register all objects which are referenced to be contained in object
stream
                     for (COSObject next : parser.getObjects())



Mime
View raw message