pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r915544 - in /pdfbox/trunk/src/main/java/org/apache/pdfbox: cos/ pdmodel/ pdmodel/common/ pdmodel/interactive/action/type/ util/
Date Tue, 23 Feb 2010 22:01:47 GMT
Author: jukka
Date: Tue Feb 23 22:01:47 2010
New Revision: 915544

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

More COSName constants

Modified:
    pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSName.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/COSArrayList.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDObjectStream.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/type/PDAction.java
    pdfbox/trunk/src/main/java/org/apache/pdfbox/util/ImageParameters.java

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSName.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSName.java?rev=915544&r1=915543&r2=915544&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSName.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSName.java Tue Feb 23 22:01:47 2010
@@ -86,10 +86,10 @@
     * A common COSName value.
     */
     public static final COSName ASCII_HEX_DECODE_ABBREVIATION = new COSName( "AHx" );
-    /**
-    * A common COSName value.
-    */
+
+    /** "AP" */
     public static final COSName AP = new COSName( "AP" );
+
     /**
      * A common COSName value.
      */
@@ -164,7 +164,7 @@
     public static final COSName CROP_BOX = new COSName(  "CropBox" );
 
     /** "D" */
-    public static final String D = "D";
+    public static final COSName D = new COSName( "D" );
 
     /**
      * A common COSName value.
@@ -174,6 +174,13 @@
      * A common COSName value.
      */
     public static final COSName DCT_DECODE_ABBREVIATION = new COSName( "DCT" );
+
+    /** "DecodeParams" */
+    public static final COSName DECODE_PARAMS = new COSName( "DecodeParams" );
+
+    /** "DecodeParms" */
+    public static final COSName DECODE_PARMS = new COSName( "DecodeParms" );
+
     /**
      * A common COSName value.
      */
@@ -206,6 +213,10 @@
      * A common COSName value.
      */
     public static final COSName DIFFERENCES = new COSName( "Differences" );
+
+    /** "DP" */
+    public static final COSName DP = new COSName( "DP" );
+
     /**
     * A common COSName value.
     */
@@ -240,7 +251,19 @@
     public static final COSName ENCODING_ETEN_B5_V = new COSName( "ETen?B5?V" );
 
     /** "Encrypt" */
-    public static final COSName ENCRYPT = new COSName("Encrypt");
+    public static final COSName ENCRYPT = new COSName( "Encrypt" );
+
+    /** "Extends" */
+    public static final COSName EXTENDS = new COSName( "Extends" );
+
+    /** "F" */
+    public static final COSName F = new COSName( "F" );
+
+    /** "FDecodeParms" */
+    public static final COSName F_DECODE_PARMS = new COSName( "FDecodeParms" );
+
+    /** "FFilter" */
+    public static final COSName F_FILTER = new COSName( "FFilter" );
 
     /**
      * A common COSName value.
@@ -354,10 +377,10 @@
     * A common COSName value.
     */
     public static final COSName JPX_DECODE = new COSName( "JPXDecode" );
-    /**
-    * A common COSName value.
-    */
+
+    /** "Kids" */
     public static final COSName KIDS = new COSName( "Kids" );
+
     /**
     * A common COSName value.
     */
@@ -378,6 +401,10 @@
      * A common COSName value.
      */
     public static final COSName LENGTH1 = new COSName( "Length1" );
+
+    /** "Limits" */
+    public static final COSName LIMITS = new COSName( "Limits" );
+
     /**
     * A common COSName value.
     */
@@ -420,7 +447,10 @@
     public static final COSName NAME = new COSName( "Name" );
 
     /** "Names" */
-    public static final COSName NAMES = new COSName("Names");
+    public static final COSName NAMES = new COSName( "Names" );
+
+    /** "Numbs" */
+    public static final COSName NUMS = new COSName( "Nums" );
 
     /** "Outlines" */
     public static final COSName OUTLINES = new COSName("Outlines");
@@ -570,9 +600,8 @@
     * A common COSName value.
     */
     public static final COSName WIN_ANSI_ENCODING = new COSName( "WinAnsiEncoding" );
-    /**
-    * A common COSName value.
-    */
+
+    /** "XObject" */
     public static final COSName XOBJECT = new COSName( "XObject" );
 
     /**

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java?rev=915544&r1=915543&r2=915544&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java Tue Feb 23 22:01:47
2010
@@ -141,12 +141,12 @@
     public Map getXObjects() throws IOException
     {
         Map retval = null;
-        COSDictionary xobjects = (COSDictionary)resources.getDictionaryObject( "XObject"
);
+        COSDictionary xobjects = (COSDictionary)resources.getDictionaryObject( COSName.XOBJECT
);
 
         if( xobjects == null )
         {
             xobjects = new COSDictionary();
-            resources.setItem( "XObject", xobjects );
+            resources.setItem( COSName.XOBJECT, xobjects );
         }
 
         Map actuals = new HashMap();
@@ -176,12 +176,12 @@
     public Map getImages() throws IOException
     {
         Map retval = null;
-        COSDictionary images = (COSDictionary)resources.getDictionaryObject( "XObject" );
+        COSDictionary images = (COSDictionary)resources.getDictionaryObject( COSName.XOBJECT
);
 
         if( images == null )
         {
             images = new COSDictionary();
-            resources.setItem( "XObject", images );
+            resources.setItem( COSName.XOBJECT, images );
         }
 
         Map actuals = new HashMap();

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=915544&r1=915543&r2=915544&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 Tue Feb
23 22:01:47 2010
@@ -44,7 +44,7 @@
     private List actual;
 
     private COSDictionary parentDict;
-    private String dictKey;
+    private COSName dictKey;
 
     /**
      * Default constructor.
@@ -82,7 +82,7 @@
      * @param dictionary The dictionary that holds the item, and will hold the array if an
item is added.
      * @param dictionaryKey The key into the dictionary to set the item.
      */
-    public COSArrayList( Object actualObject, COSBase item, COSDictionary dictionary, String
dictionaryKey )
+    public COSArrayList( Object actualObject, COSBase item, COSDictionary dictionary, COSName
dictionaryKey )
     {
         array = new COSArray();
         array.add( item );
@@ -94,6 +94,14 @@
     }
 
     /**
+     * @deprecated use the {@link #COSArrayList(Object, COSBase, COSDictionary, COSName)}
method instead
+     */
+    public COSArrayList( Object actualObject, COSBase item, COSDictionary dictionary, String
dictionaryKey )
+    {
+        this( actualObject, item, dictionary, COSName.getPDFName(dictionaryKey) );
+    }
+
+    /**
      * {@inheritDoc}
      */
     public int size()

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java?rev=915544&r1=915543&r2=915544&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java Tue Feb
23 22:01:47 2010
@@ -27,6 +27,7 @@
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSString;
 
 /**
@@ -93,7 +94,7 @@
     {
 
         List retval = null;
-        COSArray kids = (COSArray)node.getDictionaryObject( "Kids" );
+        COSArray kids = (COSArray)node.getDictionaryObject( COSName.KIDS );
         if( kids != null )
         {
             List pdObjects = new ArrayList();
@@ -162,7 +163,7 @@
     public Map getNames() throws IOException
     {
         Map names = null;
-        COSArray namesArray = (COSArray)node.getDictionaryObject( "Names" );
+        COSArray namesArray = (COSArray)node.getDictionaryObject( COSName.NAMES );
         if( namesArray != null )
         {
             names = new HashMap();
@@ -228,7 +229,7 @@
         if( names == null )
         {
             node.setItem( "Names", (COSObjectable)null );
-            node.setItem( "Limits", (COSObjectable)null);
+            node.setItem( COSName.LIMITS, (COSObjectable)null);
         }
         else
         {
@@ -263,7 +264,7 @@
     public String getUpperLimit()
     {
         String retval = null;
-        COSArray arr = (COSArray)node.getDictionaryObject( "Limits" );
+        COSArray arr = (COSArray)node.getDictionaryObject( COSName.LIMITS );
         if( arr != null )
         {
             retval = arr.getString( 1 );
@@ -278,7 +279,7 @@
      */
     private void setUpperLimit( String upper )
     {
-        COSArray arr = (COSArray)node.getDictionaryObject( "Limits" );
+        COSArray arr = (COSArray)node.getDictionaryObject( COSName.LIMITS );
         if( arr == null )
         {
             arr = new COSArray();
@@ -296,7 +297,7 @@
     public String getLowerLimit()
     {
         String retval = null;
-        COSArray arr = (COSArray)node.getDictionaryObject( "Limits" );
+        COSArray arr = (COSArray)node.getDictionaryObject( COSName.LIMITS );
         if( arr != null )
         {
             retval = arr.getString( 0 );
@@ -311,7 +312,7 @@
      */
     private void setLowerLimit( String lower )
     {
-        COSArray arr = (COSArray)node.getDictionaryObject( "Limits" );
+        COSArray arr = (COSArray)node.getDictionaryObject( COSName.LIMITS );
         if( arr == null )
         {
             arr = new COSArray();

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=915544&r1=915543&r2=915544&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 Tue
Feb 23 22:01:47 2010
@@ -28,6 +28,7 @@
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSInteger;
+import org.apache.pdfbox.cos.COSName;
 
 /**
  * This class represents a PDF Number tree. See the PDF Reference 1.7 section
@@ -94,7 +95,7 @@
     {
 
         List retval = null;
-        COSArray kids = (COSArray)node.getDictionaryObject( "Kids" );
+        COSArray kids = (COSArray)node.getDictionaryObject( COSName.KIDS );
         if( kids != null )
         {
             List pdObjects = new ArrayList();
@@ -163,7 +164,7 @@
     public Map getNumbers()  throws IOException
     {
         Map indices = null;
-        COSArray namesArray = (COSArray)node.getDictionaryObject( "Nums" );
+        COSArray namesArray = (COSArray)node.getDictionaryObject( COSName.NUMS );
         if( namesArray != null )
         {
             indices = new HashMap();
@@ -228,7 +229,7 @@
     {
         if( numbers == null )
         {
-            node.setItem( "Nums", (COSObjectable)null );
+            node.setItem( COSName.NUMS, (COSObjectable)null );
             node.setItem( "Limits", (COSObjectable)null);
         }
         else
@@ -264,7 +265,7 @@
     public Integer getUpperLimit()
     {
         Integer retval = null;
-        COSArray arr = (COSArray)node.getDictionaryObject( "Limits" );
+        COSArray arr = (COSArray)node.getDictionaryObject( COSName.LIMITS );
         if( arr != null )
         {
             retval = Integer.valueOf(arr.getInt( 1 ));
@@ -279,7 +280,7 @@
      */
     private void setUpperLimit( Integer upper )
     {
-        COSArray arr = (COSArray)node.getDictionaryObject( "Limits" );
+        COSArray arr = (COSArray)node.getDictionaryObject( COSName.LIMITS );
         if( arr == null )
         {
             arr = new COSArray();
@@ -297,7 +298,7 @@
     public Integer getLowerLimit()
     {
         Integer retval = null;
-        COSArray arr = (COSArray)node.getDictionaryObject( "Limits" );
+        COSArray arr = (COSArray)node.getDictionaryObject( COSName.LIMITS );
         if( arr != null )
         {
             retval = Integer.valueOf(arr.getInt( 0 ));
@@ -312,7 +313,7 @@
      */
     private void setLowerLimit( Integer lower )
     {
-        COSArray arr = (COSArray)node.getDictionaryObject( "Limits" );
+        COSArray arr = (COSArray)node.getDictionaryObject( COSName.LIMITS );
         if( arr == null )
         {
             arr = new COSArray();

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDObjectStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDObjectStream.java?rev=915544&r1=915543&r2=915544&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDObjectStream.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDObjectStream.java Tue Feb
23 22:01:47 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.pdfbox.pdmodel.common;
 
+import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
 
 import org.apache.pdfbox.pdmodel.PDDocument;
@@ -115,7 +116,7 @@
     public PDObjectStream getExtends()
     {
         PDObjectStream retval = null;
-        COSStream stream = (COSStream)getStream().getDictionaryObject( "Extends" );
+        COSStream stream = (COSStream)getStream().getDictionaryObject( COSName.EXTENDS );
         if( stream != null )
         {
             retval = new PDObjectStream( stream );
@@ -132,6 +133,6 @@
      */
     public void setExtends( PDObjectStream stream )
     {
-        getStream().setItem( "Extends", stream );
+        getStream().setItem( COSName.EXTENDS, stream );
     }
 }

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java?rev=915544&r1=915543&r2=915544&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java (original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java Tue Feb 23 22:01:47
2010
@@ -278,7 +278,7 @@
         if( filters instanceof COSName )
         {
             COSName name = (COSName)filters;
-            retval = new COSArrayList( name.getName(), name, stream, "Filter" );
+            retval = new COSArrayList( name.getName(), name, stream, COSName.FILTER );
         }
         else if( filters instanceof COSArray )
         {
@@ -295,7 +295,7 @@
     public void setFilters( List filters )
     {
         COSBase obj = COSArrayList.convertStringListToCOSNameCOSArray( filters );
-        stream.setItem( "Filter", obj );
+        stream.setItem( COSName.FILTER, obj );
     }
 
     /**
@@ -310,16 +310,16 @@
     {
         List retval = null;
 
-        COSBase dp = stream.getDictionaryObject( "DecodeParms" );
+        COSBase dp = stream.getDictionaryObject( COSName.DECODE_PARMS );
         if( dp == null )
         {
             //See PDF Ref 1.5 implementation note 7, the DP is sometimes used instead.
-            dp = stream.getDictionaryObject( "DP" );
+            dp = stream.getDictionaryObject( COSName.DP );
         }
         if( dp instanceof COSDictionary )
         {
             Map map = COSDictionaryMap.convertBasicTypesToMap( (COSDictionary)dp );
-            retval = new COSArrayList(map, dp, stream, "DecodeParams" );
+            retval = new COSArrayList(map, dp, stream, COSName.DECODE_PARAMS );
         }
         else if( dp instanceof COSArray )
         {
@@ -345,7 +345,7 @@
     public void setDecodeParams( List decodeParams )
     {
         stream.setItem(
-            "DecodeParams", COSArrayList.converterToCOSArray( decodeParams ) );
+            COSName.DECODE_PARAMS, COSArrayList.converterToCOSArray( decodeParams ) );
     }
 
     /**
@@ -358,7 +358,7 @@
      */
     public PDFileSpecification getFile() throws IOException
     {
-        COSBase f = stream.getDictionaryObject( "F" );
+        COSBase f = stream.getDictionaryObject( COSName.F );
         PDFileSpecification retval = PDFileSpecification.createFS( f );
         return retval;
     }
@@ -369,7 +369,7 @@
      */
     public void setFile( PDFileSpecification f )
     {
-        stream.setItem( "F", f );
+        stream.setItem( COSName.F, f );
     }
 
     /**
@@ -380,11 +380,11 @@
     public List getFileFilters()
     {
         List retval = null;
-        COSBase filters = stream.getDictionaryObject( "FFilter" );
+        COSBase filters = stream.getDictionaryObject( COSName.F_FILTER );
         if( filters instanceof COSName )
         {
             COSName name = (COSName)filters;
-            retval = new COSArrayList( name.getName(), name, stream, "FFilter" );
+            retval = new COSArrayList( name.getName(), name, stream, COSName.F_FILTER );
         }
         else if( filters instanceof COSArray )
         {
@@ -401,7 +401,7 @@
     public void setFileFilters( List filters )
     {
         COSBase obj = COSArrayList.convertStringListToCOSNameCOSArray( filters );
-        stream.setItem( "FFilter", obj );
+        stream.setItem( COSName.F_FILTER, obj );
     }
 
     /**
@@ -416,11 +416,11 @@
     {
         List retval = null;
 
-        COSBase dp = stream.getDictionaryObject( "FDecodeParms" );
+        COSBase dp = stream.getDictionaryObject( COSName.F_DECODE_PARMS );
         if( dp instanceof COSDictionary )
         {
             Map map = COSDictionaryMap.convertBasicTypesToMap( (COSDictionary)dp );
-            retval = new COSArrayList(map, dp, stream, "FDecodeParams" );
+            retval = new COSArrayList(map, dp, stream, COSName.F_DECODE_PARMS );
         }
         else if( dp instanceof COSArray )
         {
@@ -504,7 +504,7 @@
     public PDMetadata getMetadata()
     {
         PDMetadata retval = null;
-        COSStream mdStream = (COSStream)stream.getDictionaryObject( "Metadata" );
+        COSStream mdStream = (COSStream)stream.getDictionaryObject( COSName.METADATA );
         if( mdStream != null )
         {
             retval = new PDMetadata( mdStream );
@@ -519,6 +519,6 @@
      */
     public void setMetadata( PDMetadata meta )
     {
-        stream.setItem( "Metadata", meta );
+        stream.setItem( COSName.METADATA, meta );
     }
 }

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/type/PDAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/type/PDAction.java?rev=915544&r1=915543&r2=915544&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/type/PDAction.java
(original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/type/PDAction.java
Tue Feb 23 22:01:47 2010
@@ -22,6 +22,7 @@
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
 
 import org.apache.pdfbox.pdmodel.common.COSArrayList;
 import org.apache.pdfbox.pdmodel.common.PDDestinationOrAction;
@@ -143,7 +144,7 @@
         if( next instanceof COSDictionary )
         {
             PDAction pdAction = PDActionFactory.createAction( (COSDictionary) next );
-            retval = new COSArrayList(pdAction, next, action, "Next" );
+            retval = new COSArrayList(pdAction, next, action, COSName.getPDFName( "Next"
));
         }
         else if( next instanceof COSArray )
         {

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=915544&r1=915543&r2=915544&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 Tue Feb 23 22:01:47
2010
@@ -213,7 +213,7 @@
         if( filters instanceof COSName )
         {
             COSName name = (COSName)filters;
-            retval = new COSArrayList( name.getName(), name, dictionary, "Filter" );
+            retval = new COSArrayList( name.getName(), name, dictionary, COSName.FILTER );
         }
         else if( filters instanceof COSArray )
         {



Mime
View raw message