Package org.apache.fop.afp
Class AFPResourceManager
java.lang.Object
org.apache.fop.afp.AFPResourceManager
Manages the creation and storage of document resources
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
private class
private class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AFPDataObjectFactory
private DataStream
The AFP datastream (document tree)private final Factory
Resource creation factoryprotected boolean
private final Map
<AFPResourceInfo, List<AFPResourceManager.AbstractCachedObject>> Mapping of resourceInfo to AbstractCachedObjectprivate int
Maintain a reference count of instream objects for referencing purposesprivate static org.apache.commons.logging.Log
logging instanceprivate AFPResourceLevelDefaults
private final AFPStreamer
-
Constructor Summary
ConstructorsConstructorDescriptionAFPResourceManager
(InternalResourceResolver resourceResolver) Main constructor -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addToCache
(AFPResourceInfo resourceInfo, AFPResourceManager.AbstractCachedObject cachedObject) createDataStream
(AFPPaintingState paintingState, OutputStream outputStream) Sets the outputstreamvoid
createIncludedResource
(String resourceName, URI uri, AFPResourceAccessor accessor, byte resourceObjectType, boolean truetype, String ttc) Creates an included resource object by loading the contained object from a file.void
createIncludedResource
(String resourceName, AFPResourceAccessor accessor, byte resourceObjectType) Creates an included resource object by loading the contained object from a file.void
createIncludedResourceFromExternal
(String resourceName, URI uri, AFPResourceAccessor accessor) Creates an included resource extracting the named resource from an external source.void
createObject
(AFPDataObjectInfo dataObjectInfo) Creates a new data object in the AFP datastreamvoid
embedFont
(AFPFont afpFont, CharacterSet charSet) Handles font embedding.private byte[]
extractTTC
(String ttc, InputStream is) Returns the AFP DataStreamReturns the resource level defaults in use with this resource manager.boolean
includeCachedObject
(AFPResourceInfo resourceInfo, AFPObjectAreaInfo areaInfo) private void
includeObject
(AFPDataObjectInfo dataObjectInfo, String objectName) private void
includeObject
(AbstractNamedAFPObject namedObj, AFPDataObjectInfo dataObjectInfo) private void
includePageSegment
(AFPDataObjectInfo dataObjectInfo, String pageSegmentName) boolean
isObjectCached
(AFPResourceInfo resourceInfo) Returnstrue
if the passedAFPResourceInfo
instance is already cached.void
Sets the default resource group URI.void
Sets resource level defaults.boolean
tryIncludeObject
(AFPDataObjectInfo dataObjectInfo) Tries to create an include of a data object that has been previously added to the AFP data stream.private void
updateResourceInfoUri
(AFPResourceInfo resourceInfo) void
Tells the streamer to write
-
Field Details
-
log
private static org.apache.commons.logging.Log loglogging instance -
dataStream
The AFP datastream (document tree) -
factory
Resource creation factory -
streamer
-
dataObjectFactory
-
instreamObjectCount
private int instreamObjectCountMaintain a reference count of instream objects for referencing purposes -
includeObjectCache
Mapping of resourceInfo to AbstractCachedObject -
resourceLevelDefaults
-
includeCached
protected boolean includeCached
-
-
Constructor Details
-
AFPResourceManager
Main constructor- Parameters:
resourceResolver
- the associatedInternalResourceResolver
instance
-
-
Method Details
-
createDataStream
public DataStream createDataStream(AFPPaintingState paintingState, OutputStream outputStream) throws IOException Sets the outputstream- Parameters:
paintingState
- the AFP painting stateoutputStream
- the outputstream- Returns:
- a new AFP DataStream
- Throws:
IOException
- thrown if an I/O exception of some sort has occurred
-
getDataStream
Returns the AFP DataStream- Returns:
- the AFP DataStream
-
writeToStream
Tells the streamer to write- Throws:
IOException
- thrown if an I/O exception of some sort has occurred.
-
setDefaultResourceGroupUri
Sets the default resource group URI.- Parameters:
uri
- the default resource group URI
-
tryIncludeObject
Tries to create an include of a data object that has been previously added to the AFP data stream. If no such object was available, the method returns false which serves as a signal that the object has to be created.- Parameters:
dataObjectInfo
- the data object info- Returns:
- true if the inclusion succeeded, false if the object was not available
- Throws:
IOException
- thrown if an I/O exception of some sort has occurred.
-
createObject
Creates a new data object in the AFP datastream- Parameters:
dataObjectInfo
- the data object info- Throws:
IOException
- thrown if an I/O exception of some sort has occurred.
-
includeObject
-
addToCache
private void addToCache(AFPResourceInfo resourceInfo, AFPResourceManager.AbstractCachedObject cachedObject) -
isObjectCached
Returnstrue
if the passedAFPResourceInfo
instance is already cached.- Parameters:
resourceInfo
- the resource info to check- Returns:
true
if the object is cached
-
includeCachedObject
- Parameters:
resourceInfo
- the resource info to checkareaInfo
- the area info to check- Returns:
true
if ...
-
updateResourceInfoUri
-
includeObject
-
embedFont
Handles font embedding. If a font is embeddable and has not already been embedded it will be.- Parameters:
afpFont
- the AFP font to be checked for embeddingcharSet
- the associated character set- Throws:
IOException
- if there's a problem while embedding the external resources
-
includePageSegment
-
createIncludedResource
public void createIncludedResource(String resourceName, AFPResourceAccessor accessor, byte resourceObjectType) throws IOException Creates an included resource object by loading the contained object from a file.- Parameters:
resourceName
- the name of the resourceaccessor
- resource accessor to access the resource withresourceObjectType
- the resource object type (ResourceObject
.*)- Throws:
IOException
- if an I/O error occurs while loading the resource
-
createIncludedResource
public void createIncludedResource(String resourceName, URI uri, AFPResourceAccessor accessor, byte resourceObjectType, boolean truetype, String ttc) throws IOException Creates an included resource object by loading the contained object from a file.- Parameters:
resourceName
- the name of the resourceuri
- the URI for the resourceaccessor
- resource accessor to access the resource withresourceObjectType
- the resource object type (ResourceObject
.*)- Throws:
IOException
- if an I/O error occurs while loading the resource
-
extractTTC
- Throws:
IOException
-
createIncludedResourceFromExternal
public void createIncludedResourceFromExternal(String resourceName, URI uri, AFPResourceAccessor accessor) throws IOException Creates an included resource extracting the named resource from an external source.- Parameters:
resourceName
- the name of the resourceuri
- the URI for the resourceaccessor
- resource accessor to access the resource with- Throws:
IOException
- if an I/O error occurs while loading the resource
-
setResourceLevelDefaults
Sets resource level defaults. The existing defaults over merged with the ones passed in as parameter.- Parameters:
defaults
- the new defaults
-
getResourceLevelDefaults
Returns the resource level defaults in use with this resource manager.- Returns:
- the resource level defaults
-