Package org.apache.pdfbox.pdmodel
Class DefaultResourceCache
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.DefaultResourceCache
-
- All Implemented Interfaces:
ResourceCache
public class DefaultResourceCache extends java.lang.Object implements ResourceCache
A resource cached based on SoftReference, retains resources until memory pressure causes them to be garbage collected.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<COSObject,java.lang.ref.SoftReference<PDColorSpace>>
colorSpaces
private java.util.Map<COSObject,java.lang.ref.SoftReference<PDExtendedGraphicsState>>
extGStates
private java.util.Map<COSObject,java.lang.ref.SoftReference<PDFont>>
fonts
private java.util.Map<COSObject,java.lang.ref.SoftReference<PDAbstractPattern>>
patterns
private java.util.Map<COSObject,java.lang.ref.SoftReference<PDPropertyList>>
properties
private java.util.Map<COSObject,java.lang.ref.SoftReference<PDShading>>
shadings
private java.util.Map<COSObject,java.lang.ref.SoftReference<PDXObject>>
xobjects
-
Constructor Summary
Constructors Constructor Description DefaultResourceCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PDColorSpace
getColorSpace(COSObject indirect)
Returns the color space resource for the given indirect object, if it is in the cache.PDExtendedGraphicsState
getExtGState(COSObject indirect)
Returns the extended graphics state resource for the given indirect object, if it is in the cache.PDFont
getFont(COSObject indirect)
Returns the font resource for the given indirect object, if it is in the cache.PDAbstractPattern
getPattern(COSObject indirect)
Returns the pattern resource for the given indirect object, if it is in the cache.PDPropertyList
getProperties(COSObject indirect)
Returns the property list resource for the given indirect object, if it is in the cache.PDShading
getShading(COSObject indirect)
Returns the shading resource for the given indirect object, if it is in the cache.PDXObject
getXObject(COSObject indirect)
Returns the XObject resource for the given indirect object, if it is in the cache.void
put(COSObject indirect, PDPropertyList propertyList)
Puts the given indirect property list resource in the cache.void
put(COSObject indirect, PDFont font)
Puts the given indirect font resource in the cache.void
put(COSObject indirect, PDColorSpace colorSpace)
Puts the given indirect color space resource in the cache.void
put(COSObject indirect, PDAbstractPattern pattern)
Puts the given indirect pattern resource in the cache.void
put(COSObject indirect, PDXObject xobject)
Puts the given indirect XObject resource in the cache.void
put(COSObject indirect, PDShading shading)
Puts the given indirect shading resource in the cache.void
put(COSObject indirect, PDExtendedGraphicsState extGState)
Puts the given indirect extended graphics state resource in the cache.
-
-
-
Field Detail
-
colorSpaces
private final java.util.Map<COSObject,java.lang.ref.SoftReference<PDColorSpace>> colorSpaces
-
extGStates
private final java.util.Map<COSObject,java.lang.ref.SoftReference<PDExtendedGraphicsState>> extGStates
-
patterns
private final java.util.Map<COSObject,java.lang.ref.SoftReference<PDAbstractPattern>> patterns
-
properties
private final java.util.Map<COSObject,java.lang.ref.SoftReference<PDPropertyList>> properties
-
-
Method Detail
-
getFont
public PDFont getFont(COSObject indirect) throws java.io.IOException
Description copied from interface:ResourceCache
Returns the font resource for the given indirect object, if it is in the cache.- Specified by:
getFont
in interfaceResourceCache
- Parameters:
indirect
- the indirect object- Returns:
- the font resource of the given indirect object.
- Throws:
java.io.IOException
- if something went wrong.
-
put
public void put(COSObject indirect, PDFont font) throws java.io.IOException
Description copied from interface:ResourceCache
Puts the given indirect font resource in the cache.- Specified by:
put
in interfaceResourceCache
- Parameters:
indirect
- the indirect object of the resource.font
- the font resource.- Throws:
java.io.IOException
- if something went wrong.
-
getColorSpace
public PDColorSpace getColorSpace(COSObject indirect) throws java.io.IOException
Description copied from interface:ResourceCache
Returns the color space resource for the given indirect object, if it is in the cache.- Specified by:
getColorSpace
in interfaceResourceCache
- Parameters:
indirect
- the indirect object- Returns:
- the color space resource of the given indirect object.
- Throws:
java.io.IOException
- if something went wrong.
-
put
public void put(COSObject indirect, PDColorSpace colorSpace) throws java.io.IOException
Description copied from interface:ResourceCache
Puts the given indirect color space resource in the cache.- Specified by:
put
in interfaceResourceCache
- Parameters:
indirect
- the indirect object of the resource.colorSpace
- the color space resource.- Throws:
java.io.IOException
- if something went wrong.
-
getExtGState
public PDExtendedGraphicsState getExtGState(COSObject indirect)
Description copied from interface:ResourceCache
Returns the extended graphics state resource for the given indirect object, if it is in the cache.- Specified by:
getExtGState
in interfaceResourceCache
- Parameters:
indirect
- the indirect object- Returns:
- the extended graphics resource of the given indirect object.
-
put
public void put(COSObject indirect, PDExtendedGraphicsState extGState)
Description copied from interface:ResourceCache
Puts the given indirect extended graphics state resource in the cache.- Specified by:
put
in interfaceResourceCache
- Parameters:
indirect
- the indirect object of the resource.extGState
- the extended graphics state resource.
-
getShading
public PDShading getShading(COSObject indirect) throws java.io.IOException
Description copied from interface:ResourceCache
Returns the shading resource for the given indirect object, if it is in the cache.- Specified by:
getShading
in interfaceResourceCache
- Parameters:
indirect
- the indirect object- Returns:
- the shading resource of the given indirect object.
- Throws:
java.io.IOException
- if something went wrong.
-
put
public void put(COSObject indirect, PDShading shading) throws java.io.IOException
Description copied from interface:ResourceCache
Puts the given indirect shading resource in the cache.- Specified by:
put
in interfaceResourceCache
- Parameters:
indirect
- the indirect object of the resource.shading
- the shading resource.- Throws:
java.io.IOException
- if something went wrong.
-
getPattern
public PDAbstractPattern getPattern(COSObject indirect) throws java.io.IOException
Description copied from interface:ResourceCache
Returns the pattern resource for the given indirect object, if it is in the cache.- Specified by:
getPattern
in interfaceResourceCache
- Parameters:
indirect
- the indirect object- Returns:
- the pattern resource of the given indirect object.
- Throws:
java.io.IOException
- if something went wrong.
-
put
public void put(COSObject indirect, PDAbstractPattern pattern) throws java.io.IOException
Description copied from interface:ResourceCache
Puts the given indirect pattern resource in the cache.- Specified by:
put
in interfaceResourceCache
- Parameters:
indirect
- the indirect object of the resource.pattern
- the pattern resource.- Throws:
java.io.IOException
- if something went wrong.
-
getProperties
public PDPropertyList getProperties(COSObject indirect)
Description copied from interface:ResourceCache
Returns the property list resource for the given indirect object, if it is in the cache.- Specified by:
getProperties
in interfaceResourceCache
- Parameters:
indirect
- the indirect object- Returns:
- the property list resource of the given indirect object.
-
put
public void put(COSObject indirect, PDPropertyList propertyList)
Description copied from interface:ResourceCache
Puts the given indirect property list resource in the cache.- Specified by:
put
in interfaceResourceCache
- Parameters:
indirect
- the indirect object of the resource.propertyList
- the property list resource.
-
getXObject
public PDXObject getXObject(COSObject indirect) throws java.io.IOException
Description copied from interface:ResourceCache
Returns the XObject resource for the given indirect object, if it is in the cache.- Specified by:
getXObject
in interfaceResourceCache
- Parameters:
indirect
- the indirect object- Returns:
- the XObject resource of the given indirect object.
- Throws:
java.io.IOException
- if something went wrong.
-
put
public void put(COSObject indirect, PDXObject xobject) throws java.io.IOException
Description copied from interface:ResourceCache
Puts the given indirect XObject resource in the cache.- Specified by:
put
in interfaceResourceCache
- Parameters:
indirect
- the indirect object of the resource.xobject
- the XObject resource.- Throws:
java.io.IOException
- if something went wrong.
-
-