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 2013/03/01 18:44:20 UTC
svn commit: r1451662 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
Author: lehmi
Date: Fri Mar 1 17:44:19 2013
New Revision: 1451662
URL: http://svn.apache.org/r1451662
Log:
PDFBOX-1496: cache the resources of a page to avoid recreating them every time getResources is called, added some generics
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java?rev=1451662&r1=1451661&r2=1451662&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java Fri Mar 1 17:44:19 2013
@@ -73,6 +73,8 @@ public class PDPage implements COSObject
private COSDictionary page;
+ private PDResources pageResources;
+
/**
* A page size of LETTER or 8.5x11.
*/
@@ -224,13 +226,15 @@ public class PDPage implements COSObject
*/
public PDResources getResources()
{
- PDResources retval = null;
- COSDictionary resources = (COSDictionary)page.getDictionaryObject( COSName.RESOURCES );
- if( resources != null )
+ if (pageResources == null)
{
- retval = new PDResources( resources );
+ COSDictionary resources = (COSDictionary)page.getDictionaryObject( COSName.RESOURCES );
+ if (resources != null)
+ {
+ pageResources = new PDResources( resources );
+ }
}
- return retval;
+ return pageResources;
}
/**
@@ -257,6 +261,7 @@ public class PDPage implements COSObject
*/
public void setResources( PDResources resources )
{
+ pageResources = resources;
page.setItem( COSName.RESOURCES, resources );
}
@@ -611,7 +616,7 @@ public class PDPage implements COSObject
*
* @return A list of article threads on this page.
*/
- public List getThreadBeads()
+ public List<PDThreadBead> getThreadBeads()
{
COSArray beads = (COSArray)page.getDictionaryObject( COSName.B );
if( beads == null )
@@ -630,7 +635,7 @@ public class PDPage implements COSObject
}
pdObjects.add( bead );
}
- return new COSArrayList(pdObjects, beads);
+ return new COSArrayList<PDThreadBead>(pdObjects, beads);
}
@@ -792,15 +797,15 @@ public class PDPage implements COSObject
*
* @throws IOException If there is an error while creating the annotations.
*/
- public List getAnnotations() throws IOException
+ public List<PDAnnotation> getAnnotations() throws IOException
{
- COSArrayList retval = null;
+ COSArrayList<PDAnnotation> retval = null;
COSArray annots = (COSArray)page.getDictionaryObject(COSName.ANNOTS);
if (annots == null)
{
annots = new COSArray();
page.setItem(COSName.ANNOTS, annots);
- retval = new COSArrayList(new ArrayList(), annots);
+ retval = new COSArrayList<PDAnnotation>(new ArrayList<PDAnnotation>(), annots);
}
else
{
@@ -811,7 +816,7 @@ public class PDPage implements COSObject
COSBase item = annots.getObject(i);
actuals.add( PDAnnotation.createAnnotation( item ) );
}
- retval = new COSArrayList(actuals, annots);
+ retval = new COSArrayList<PDAnnotation>(actuals, annots);
}
return retval;
}