pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r914982 - in /pdfbox/trunk/src/main/java/org/apache/pdfbox: ./ cos/ pdfparser/ pdfwriter/ pdmodel/ pdmodel/common/ pdmodel/documentinterchange/prepress/ pdmodel/encryption/ pdmodel/fdf/ pdmodel/font/ pdmodel/graphics/ pdmodel/graphics/color...
Date Mon, 22 Feb 2010 17:48:19 GMT
Author: jukka
Date: Mon Feb 22 17:48:18 2010
New Revision: 914982

URL: http://svn.apache.org/viewvc?rev=914982&view=rev
Log:
PDFBOX-626: Reduce the memory impact of the COS object model

Use a static cache of common COSInteger values. This reduces the memory impact of PDDocument.load("src/test/resources/input/cweb.pdf")
from about 144kB to 135kB.

Modified:
    pdfbox/trunk/src/main/java/org/apache/pdfbox/Overlay.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSArray.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDocument.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSInteger.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSNumber.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFObjectStreamParser.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFXrefStreamParser.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDPageNode.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/prepress/PDBoxStyle.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/encryption/PDStandardEncryption.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDIndexed.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDBorderStyleDictionary.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoiceField.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/util/ImageParameters.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/Overlay.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/Overlay.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/Overlay.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/Overlay.java Mon Feb 22 17:48:18 2010
@@ -21,7 +21,6 @@
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
-import org.apache.pdfbox.cos.COSInteger;
 import org.apache.pdfbox.exceptions.COSVisitorException;
 import org.apache.pdfbox.pdfparser.PDFParser;
 import org.apache.pdfbox.pdfwriter.COSWriter;
@@ -351,7 +350,7 @@
         }
 
         COSDictionary streamDict = new COSDictionary();
-        streamDict.setItem(COSName.LENGTH, new COSInteger(baos.size()));
+        streamDict.setInt(COSName.LENGTH, baos.size());
         COSStream output = new COSStream(streamDict, pdfDocument.getDocument().getScratchFile());
         output.setFilters(stream.getFilters());
         OutputStream os = output.createUnfilteredStream();

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSArray.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSArray.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSArray.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSArray.java Mon Feb 22 17:48:18 2010
@@ -158,7 +158,7 @@
      */
     public void set( int index, int intVal )
     {
-        objects.set( index, new COSInteger( intVal ) );
+        objects.set( index, COSInteger.get(intVal) );
     }
 
     /**
@@ -254,7 +254,7 @@
      */
     public void setInt( int index, int value )
     {
-        set( index, new COSInteger( value ) );
+        set( index, COSInteger.get( value ) );
     }
 
     /**

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDictionary.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDictionary.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDictionary.java Mon Feb 22 17:48:18
2010
@@ -457,9 +457,7 @@
      */
     public void setInt( COSName key, int value )
     {
-        COSInteger intVal = null;
-        intVal = new COSInteger(value);
-        setItem( key, intVal );
+        setItem( key, COSInteger.get(value) );
     }
 
     /**
@@ -484,7 +482,7 @@
     public void setLong( COSName key, long value )
     {
         COSInteger intVal = null;
-        intVal = new COSInteger(value);
+        intVal = COSInteger.get(value);
         setItem( key, intVal );
     }
 

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDocument.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDocument.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDocument.java Mon Feb 22 17:48:18
2010
@@ -478,8 +478,8 @@
             obj = new COSObject(null);
             if( key != null )
             {
-                obj.setObjectNumber( new COSInteger( key.getNumber() ) );
-                obj.setGenerationNumber( new COSInteger( key.getGeneration() ) );
+                obj.setObjectNumber( COSInteger.get( key.getNumber() ) );
+                obj.setGenerationNumber( COSInteger.get( key.getGeneration() ) );
                 objectPool.put(key, obj);
             }
         }

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSInteger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSInteger.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSInteger.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSInteger.java Mon Feb 22 17:48:18 2010
@@ -31,11 +31,48 @@
 public class COSInteger extends COSNumber
 {
 
+    /**
+     * The lowest integer to be kept in the {@link #STATIC} array.
+     */
+    private static int LOW = -100;
+
+    /**
+     * The highest integer to be kept in the {@link #STATIC} array.
+     */
+    private static int HIGH = 256;
+
+    /**
+     * Static instances of all COSIntegers in the range from {@link #LOW}
+     * to {@link #HIGH}.
+     */
+    private static final COSInteger[] STATIC = new COSInteger[HIGH - LOW + 1];
+
+    static {
+        for (int i = 0; i < STATIC.length; i++) {
+            STATIC[i] = new COSInteger(i + LOW);
+        }
+    }
+
+    /**
+     * Returns a COSInteger instance with the given value.
+     *
+     * @param val integer value
+     * @return COSInteger instance
+     */
+    public static COSInteger get(long val) {
+        if (LOW <= val && val <= HIGH) {
+            return STATIC[(int) val - LOW];
+        } else {
+            return new COSInteger(val);
+        }
+    }
+
     private long value;
 
     /**
      * constructor.
      *
+     * @deprecated use the static {@link #get(long)} method instead
      * @param val The integer value of this object.
      */
     public COSInteger( long val )
@@ -46,6 +83,7 @@
     /**
      * constructor.
      *
+     * @deprecated use the static {@link #get(long)} method instead
      * @param val The integer value of this object.
      */
     public COSInteger( int val )
@@ -57,7 +95,7 @@
      * This will create a new PDF Int object using a string.
      *
      * @param val The string value of the integer.
-     *
+     * @deprecated use the static {@link #get(long)} method instead
      * @throws IOException If the val is not an integer type.
      */
     public COSInteger( String val ) throws IOException

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSNumber.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSNumber.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSNumber.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSNumber.java Mon Feb 22 17:48:18 2010
@@ -30,30 +30,25 @@
     /**
      * ZERO.
     */
-    public static final COSInteger ZERO = new COSInteger( 0 );
+    public static final COSInteger ZERO = COSInteger.get( 0 );
 
     /**
      * ONE.
     */
-    public static final COSInteger ONE = new COSInteger( 1 );
+    public static final COSInteger ONE = COSInteger.get( 1 );
 
     /**
-     * Efficient lookup table for the ten decimal digits.
-     */
-    private static final COSInteger[] DIGITS = new COSInteger[] {
-        ZERO,
-        ONE,
-        new COSInteger(2),
-        new COSInteger(3),
-        new COSInteger(4),
-        new COSInteger(5),
-        new COSInteger(6),
-        new COSInteger(7),
-        new COSInteger(8),
-        new COSInteger(9),
-    };
+     * TWO.
+    */
+    public static final COSInteger TWO = COSInteger.get( 2 );
 
     /**
+     * THREE.
+    */
+    public static final COSInteger THREE = COSInteger.get( 3 );
+
+    
+    /**
      * This will get the float value of this number.
      *
      * @return The float value of this object.
@@ -95,12 +90,19 @@
         if (number.length() == 1) {
             char digit = number.charAt(0);
             if ('0' <= digit && digit <= '9') {
-                return DIGITS[digit - '0'];
+                return COSInteger.get(digit - '0');
             } else {
                 throw new IOException("Not a number: " + number);
             }
         } else if (number.indexOf('.') == -1) {
-            return new COSInteger(number);
+            try
+            {
+                return COSInteger.get( Long.parseLong( number ) );
+            }
+            catch( NumberFormatException e )
+            {
+                throw new IOException( "Value is not an integer: " + number );
+            }
         } else {
             return new COSFloat(number);
         }

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFObjectStreamParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFObjectStreamParser.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFObjectStreamParser.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFObjectStreamParser.java Mon
Feb 22 17:48:18 2010
@@ -90,7 +90,7 @@
                 object = new COSObject(cosObject);
                 object.setGenerationNumber( COSInteger.ZERO );
                 COSInteger objNum =
-                    new COSInteger( objectNumbers.get( objectCounter).intValue() );
+                    COSInteger.get( objectNumbers.get( objectCounter).intValue() );
                 object.setObjectNumber( objNum );
                 streamObjects.add( object );
                 if(log.isDebugEnabled())

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java Mon Feb 22 17:48:18
2010
@@ -614,8 +614,8 @@
     private void addObjectToConflicts(int offset, COSObjectKey key, COSBase pb) throws IOException
     {
         COSObject obj = new COSObject(null);
-        obj.setObjectNumber( new COSInteger( key.getNumber() ) );
-        obj.setGenerationNumber( new COSInteger( key.getGeneration() ) );
+        obj.setObjectNumber( COSInteger.get( key.getNumber() ) );
+        obj.setGenerationNumber( COSInteger.get( key.getGeneration() ) );
         obj.setObject(pb);
         ConflictObj conflictObj = new ConflictObj(offset, key, obj);
         conflictList.add(conflictObj);   

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFXrefStreamParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFXrefStreamParser.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFXrefStreamParser.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFXrefStreamParser.java Mon Feb
22 17:48:18 2010
@@ -24,6 +24,7 @@
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSDocument;
 import org.apache.pdfbox.cos.COSInteger;
+import org.apache.pdfbox.cos.COSNumber;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.persistence.util.COSObjectKey;
 
@@ -69,7 +70,7 @@
             if(indexArray == null)
             {
                 indexArray = new COSArray();
-                indexArray.add(new COSInteger(0));
+                indexArray.add(COSNumber.ZERO);
                 indexArray.add(stream.getDictionaryObject("Size"));
             }
             

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Mon Feb 22 17:48:18
2010
@@ -927,7 +927,7 @@
                 getStandardOutput().write( buffer, 0, amountRead );
                 totalAmountWritten += amountRead;
             }
-            lengthObject.setObject( new COSInteger( totalAmountWritten ) );
+            lengthObject.setObject( COSInteger.get( totalAmountWritten ) );
             getStandardOutput().writeCRLF();
             getStandardOutput().write(ENDSTREAM);
             getStandardOutput().writeEOL();

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Mon Feb 22 17:48:18
2010
@@ -41,6 +41,7 @@
 import org.apache.pdfbox.cos.COSDocument;
 import org.apache.pdfbox.cos.COSInteger;
 import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.cos.COSNumber;
 import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.exceptions.COSVisitorException;
@@ -142,7 +143,7 @@
         pages.setItem( COSName.TYPE, COSName.PAGES );
         COSArray kidsArray = new COSArray();
         pages.setItem( COSName.KIDS, kidsArray );
-        pages.setItem( COSName.COUNT, new COSInteger( 0 ) );
+        pages.setItem( COSName.COUNT, COSNumber.ZERO );
     }
 
     private void generatePageMap() 

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java Mon Feb 22 17:48:18 2010
@@ -21,7 +21,6 @@
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
-import org.apache.pdfbox.cos.COSInteger;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSNumber;
 import org.apache.pdfbox.cos.COSStream;
@@ -560,7 +559,7 @@
      */
     public void setRotation( int rotation )
     {
-        page.setItem( COSName.ROTATE, new COSInteger( rotation ) );
+        page.setInt( COSName.ROTATE, rotation );
     }
 
     /**

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDPageNode.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDPageNode.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDPageNode.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDPageNode.java Mon Feb 22 17:48:18
2010
@@ -21,7 +21,6 @@
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSNumber;
-import org.apache.pdfbox.cos.COSInteger;
 
 import org.apache.pdfbox.pdmodel.common.COSArrayList;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
@@ -49,7 +48,7 @@
         page = new COSDictionary();
         page.setItem( COSName.TYPE, COSName.PAGES );
         page.setItem( COSName.KIDS, new COSArray() );
-        page.setItem( COSName.COUNT, new COSInteger( 0 ) );
+        page.setItem( COSName.COUNT, COSNumber.ZERO );
     }
 
     /**
@@ -88,7 +87,7 @@
                 totalCount += node.updateCount();
             }
         }
-        page.setItem( COSName.COUNT, new COSInteger( totalCount ) );
+        page.setLong( COSName.COUNT, totalCount );
         return totalCount;
     }
 
@@ -440,6 +439,6 @@
      */
     public void setRotation( int rotation )
     {
-        page.setItem( COSName.ROTATE, new COSInteger( rotation ) );
+        page.setInt( COSName.ROTATE, rotation );
     }
 }

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java Mon Feb
22 17:48:18 2010
@@ -407,7 +407,7 @@
                     }
                     else if( next instanceof Integer || next instanceof Long )
                     {
-                        array.add( new COSInteger( ((Number)next).longValue() ) );
+                        array.add( COSInteger.get( ((Number)next).longValue() ) );
                     }
                     else if( next instanceof Float || next instanceof Double )
                     {

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java Mon
Feb 22 17:48:18 2010
@@ -239,7 +239,7 @@
             for( int i=0; i<keys.size(); i++ )
             {
                 Integer key = (Integer)keys.get(i);
-                array.add( new COSInteger( key.intValue() ) );
+                array.add( COSInteger.get( key ) );
                 COSObjectable obj = (COSObjectable)numbers.get( key );
                 array.add( obj );
             }

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.java Mon Feb
22 17:48:18 2010
@@ -151,7 +151,7 @@
         COSArray arr = new COSArray();
         for (Entry<Integer, PDPageLabelRange> i : labels.entrySet())
         {
-            arr.add(new COSInteger(i.getKey()));
+            arr.add(COSInteger.get(i.getKey()));
             arr.add(i.getValue());
         }
         dict.setItem("Nums", arr);

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/prepress/PDBoxStyle.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/prepress/PDBoxStyle.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/prepress/PDBoxStyle.java
(original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/prepress/PDBoxStyle.java
Mon Feb 22 17:48:18 2010
@@ -20,6 +20,7 @@
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSInteger;
+import org.apache.pdfbox.cos.COSNumber;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.pdmodel.graphics.PDLineDashPattern;
 import org.apache.pdfbox.pdmodel.graphics.color.PDColorState;
@@ -180,13 +181,13 @@
         if( d == null )
         {
             d = new COSArray();
-            d.add( new COSInteger(3) );
+            d.add( COSNumber.THREE );
             dictionary.setItem( "D", d );
         }
         COSArray lineArray = new COSArray();
         lineArray.add( d );
         //dash phase is not specified and assumed to be zero.
-        lineArray.add( new COSInteger( 0 ) );
+        lineArray.add( COSNumber.ZERO );
         pattern = new PDLineDashPattern( lineArray );
         return pattern;
     }

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/encryption/PDStandardEncryption.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/encryption/PDStandardEncryption.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/encryption/PDStandardEncryption.java
(original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/encryption/PDStandardEncryption.java
Mon Feb 22 17:48:18 2010
@@ -123,7 +123,7 @@
      */
     public void setRevision( int revision )
     {
-        encryptionDictionary.setItem( COSName.getPDFName( "R" ), new COSInteger( revision
) );
+        encryptionDictionary.setInt( COSName.getPDFName( "R" ), revision );
     }
 
     /**
@@ -209,7 +209,7 @@
      */
     public void setPermissions( int p )
     {
-        encryptionDictionary.setItem( COSName.getPDFName( "P" ), new COSInteger( p ) );
+        encryptionDictionary.setInt( COSName.getPDFName( "P" ), p );
     }
 
     private boolean isPermissionBitOn( int bit )

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java Mon Feb 22
17:48:18 2010
@@ -237,7 +237,7 @@
      */
     public void setPage( int page )
     {
-        annot.setItem( "Page", new COSInteger( page ) );
+        annot.setInt( "Page", page );
     }
 
     /**

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java Mon Feb 22 17:48:18
2010
@@ -320,7 +320,7 @@
         COSInteger value = null;
         if( ff != null )
         {
-            value = new COSInteger( ff.intValue() );
+            value = COSInteger.get( ff );
         }
         field.setItem( "Ff", value );
     }
@@ -333,7 +333,7 @@
      */
     public void setFieldFlags( int ff )
     {
-        field.setItem( "Ff", new COSInteger( ff ) );
+        field.setInt( "Ff", ff );
     }
 
     /**
@@ -364,7 +364,7 @@
         COSInteger value = null;
         if( ff != null )
         {
-            value = new COSInteger( ff.intValue() );
+            value = COSInteger.get( ff );
         }
         field.setItem( "SetFf", value );
     }
@@ -377,7 +377,7 @@
      */
     public void setSetFieldFlags( int ff )
     {
-        field.setItem( "SetFf", new COSInteger( ff ) );
+        field.setInt( "SetFf", ff );
     }
 
     /**
@@ -408,7 +408,7 @@
         COSInteger value = null;
         if( ff != null )
         {
-            value = new COSInteger( ff.intValue() );
+            value = COSInteger.get( ff );
         }
         field.setItem( "ClrFf", value );
     }
@@ -421,7 +421,7 @@
      */
     public void setClearFieldFlags( int ff )
     {
-        field.setItem( "ClrFf", new COSInteger( ff ) );
+        field.setInt( "ClrFf", ff );
     }
 
     /**
@@ -452,7 +452,7 @@
         COSInteger value = null;
         if( f != null )
         {
-            value = new COSInteger( f.intValue() );
+            value = COSInteger.get( f );
         }
         field.setItem( "F", value );
     }
@@ -465,7 +465,7 @@
      */
     public void setWidgetFieldFlags( int f )
     {
-        field.setItem( "F", new COSInteger( f ) );
+        field.setInt( "F", f );
     }
 
     /**
@@ -496,7 +496,7 @@
         COSInteger value = null;
         if( ff != null )
         {
-            value = new COSInteger( ff.intValue() );
+            value = COSInteger.get( ff );
         }
         field.setItem( "SetF", value );
     }
@@ -509,7 +509,7 @@
      */
     public void setSetWidgetFieldFlags( int ff )
     {
-        field.setItem( "SetF", new COSInteger( ff ) );
+        field.setInt( "SetF", ff );
     }
 
     /**
@@ -540,7 +540,7 @@
         COSInteger value = null;
         if( ff != null )
         {
-            value = new COSInteger( ff.intValue() );
+            value = COSInteger.get( ff );
         }
         field.setItem( "ClrF", value );
     }
@@ -553,7 +553,7 @@
      */
     public void setClearWidgetFieldFlags( int ff )
     {
-        field.setItem( "ClrF", new COSInteger( ff ) );
+        field.setInt( "ClrF", ff );
     }
 
     /**

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java Mon Feb 22 17:48:18
2010
@@ -129,7 +129,7 @@
      */
     public void setDefaultWidth( long dw )
     {
-        font.setItem( COSName.DW, new COSInteger( dw ) );
+        font.setLong( COSName.DW, dw );
     }
 
     /**

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java Mon
Feb 22 17:48:18 2010
@@ -44,7 +44,7 @@
     {
         lineDashPattern = new COSArray();
         lineDashPattern.add( new COSArray() );
-        lineDashPattern.add( new COSInteger( 0 ) );
+        lineDashPattern.add( COSNumber.ZERO );
     }
 
     /**
@@ -67,7 +67,7 @@
     {
         lineDashPattern = new COSArray();
         lineDashPattern.add( ldp );
-        lineDashPattern.add( new COSInteger( phase ) );
+        lineDashPattern.add( COSInteger.get( phase ) );
     }
 
     /**
@@ -116,7 +116,7 @@
      */
     public void setPhaseStart( int phase )
     {
-        lineDashPattern.set( 1, new COSInteger( phase ) );
+        lineDashPattern.set( 1, phase );
     }
 
     /**

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java Mon
Feb 22 17:48:18 2010
@@ -185,7 +185,7 @@
      */
     public void setNumberOfComponents( int n )
     {
-        stream.getStream().setItem( COSName.getPDFName( "N" ), new COSInteger( n ) );
+        stream.getStream().setInt( COSName.getPDFName( "N" ), n );
     }
 
     /**

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDIndexed.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDIndexed.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDIndexed.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDIndexed.java Mon
Feb 22 17:48:18 2010
@@ -62,7 +62,7 @@
         array = new COSArray();
         array.add( COSName.getPDFName( NAME ) );
         array.add( COSName.getPDFName( PDDeviceRGB.NAME ) );
-        array.add( new COSInteger( 255 ) );
+        array.add( COSInteger.get( 255 ) );
         array.add( org.apache.pdfbox.cos.COSNull.NULL );
     }
 
@@ -199,7 +199,7 @@
      */
     public void setHighValue( int high )
     {
-        array.set( 2, new COSInteger( high ) );
+        array.set( 2, high );
     }
 
     /**

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDBorderStyleDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDBorderStyleDictionary.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDBorderStyleDictionary.java
(original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDBorderStyleDictionary.java
Mon Feb 22 17:48:18 2010
@@ -19,7 +19,7 @@
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSArray;
-import org.apache.pdfbox.cos.COSInteger;
+import org.apache.pdfbox.cos.COSNumber;
 
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.pdmodel.graphics.PDLineDashPattern;
@@ -174,7 +174,7 @@
         if (d == null)
         {
             d = new COSArray();
-            d.add( new COSInteger( 3 ) );
+            d.add( COSNumber.THREE );
             getDictionary().setItem( "D", d );
         }
         return new PDLineDashPattern( d, 0 );

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoiceField.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoiceField.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoiceField.java
(original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDChoiceField.java
Mon Feb 22 17:48:18 2010
@@ -104,7 +104,7 @@
             if( indexArray != null )
             {
                 indexArray.clear();
-                indexArray.add( new COSInteger( indexSelected ) );
+                indexArray.add( COSInteger.get( indexSelected ) );
             }
         }
     }

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java Mon
Feb 22 17:48:18 2010
@@ -278,8 +278,7 @@
      */
     public void setFieldFlags( int flags )
     {
-        COSInteger ff = new COSInteger( flags );
-        getDictionary().setItem( COSName.getPDFName( "Ff" ), ff );
+        getDictionary().setInt( COSName.getPDFName( "Ff" ), flags );
     }
 
     /**

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java
(original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDVariableText.java
Mon Feb 22 17:48:18 2010
@@ -304,7 +304,7 @@
      */
     public void setQ( int q )
     {
-        getDictionary().setItem( COSName.getPDFName( "Q" ), new COSInteger( q ) );
+        getDictionary().setInt( COSName.getPDFName( "Q" ), q );
     }
 
 }

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/util/ImageParameters.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/ImageParameters.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/util/ImageParameters.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/util/ImageParameters.java Mon Feb 22 17:48:18
2010
@@ -108,7 +108,7 @@
      */
     public void setBitsPerComponent( int bpc )
     {
-        dictionary.setItem( COSName.getPDFName( "BPC" ), new COSInteger( bpc ) );
+        dictionary.setInt( COSName.getPDFName( "BPC" ), bpc );
     }
 
 
@@ -177,7 +177,7 @@
      */
     public void setHeight( int h )
     {
-        dictionary.setItem( COSName.getPDFName( "H" ), new COSInteger( h ) );
+        dictionary.setInt( COSName.getPDFName( "H" ), h );
     }
 
     /**
@@ -198,7 +198,7 @@
      */
     public void setWidth( int w )
     {
-        dictionary.setItem( COSName.getPDFName( "W" ), new COSInteger( w ) );
+        dictionary.setInt( COSName.getPDFName( "W" ), w );
     }
 
     /**

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java?rev=914982&r1=914981&r2=914982&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java Mon Feb 22 17:48:18
2010
@@ -280,7 +280,7 @@
                 {
                     COSNumber labelIndex = (COSNumber)srcNums.getObject( i );
                     long labelIndexValue = labelIndex.intValue();
-                    destNums.add( new COSInteger( labelIndexValue + destPageCount ) );
+                    destNums.add( COSInteger.get( labelIndexValue + destPageCount ) );
                     destNums.add( cloneForNewDocument( destination, srcNums.getObject( i+1
) ) );
                 }
             }



Mime
View raw message