org.apache.fop.afp

## Class AFPResourceManager

- java.lang.Object
- - org.apache.fop.afp.AFPResourceManager

-     public class AFPResourceManager
      extends Object

  Manages the creation and storage of document resources

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `includeCached`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AFPResourceManager(InternalResourceResolver resourceResolver)` Main constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DataStream` | `createDataStream(AFPPaintingState paintingState, OutputStream outputStream)` Sets the outputstream
    `void` | `createIncludedResource(String resourceName, AFPResourceAccessor accessor, byte resourceObjectType)` Creates an included resource object by loading the contained object from a file.
    `void` | `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` | `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 datastream
    `void` | `embedFont(AFPFont afpFont, CharacterSet charSet)` Handles font embedding.
    `DataStream` | `getDataStream()` Returns the AFP DataStream
    `AFPResourceLevelDefaults` | `getResourceLevelDefaults()` Returns the resource level defaults in use with this resource manager.
    `boolean` | `includeCachedObject(AFPResourceInfo resourceInfo, AFPObjectAreaInfo areaInfo)`
    `boolean` | `isObjectCached(AFPResourceInfo resourceInfo)` Returns `true` if the passed `AFPResourceInfo` instance is already cached.
    `void` | `setDefaultResourceGroupUri(URI uri)` Sets the default resource group URI.
    `void` | `setResourceLevelDefaults(AFPResourceLevelDefaults defaults)` 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.
    `void` | `writeToStream()` Tells the streamer to write

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### includeCached

          protected boolean includeCached

  - ### Constructor Detail

    - #### AFPResourceManager

          public AFPResourceManager(InternalResourceResolver resourceResolver)

      Main constructor
      Parameters:
        `resourceResolver` - the associated `InternalResourceResolver` instance

  - ### Method Detail

    - #### createDataStream

          public DataStream createDataStream(AFPPaintingState paintingState,
                                             OutputStream outputStream)
                                      throws IOException

      Sets the outputstream
      Parameters:
        `paintingState` - the AFP painting state
        `outputStream` - the outputstream
      Returns:
        a new AFP DataStream
      Throws:
        `IOException` - thrown if an I/O exception of some sort has occurred

    - #### getDataStream

          public DataStream getDataStream()

      Returns the AFP DataStream
      Returns:
        the AFP DataStream

    - #### writeToStream

          public void writeToStream()
                             throws IOException

      Tells the streamer to write
      Throws:
        `IOException` - thrown if an I/O exception of some sort has occurred.

    - #### setDefaultResourceGroupUri

          public void setDefaultResourceGroupUri(URI uri)

      Sets the default resource group URI.
      Parameters:
        `uri` - the default resource group URI

    - #### tryIncludeObject

          public boolean tryIncludeObject(AFPDataObjectInfo dataObjectInfo)
                                   throws IOException

      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

          public void createObject(AFPDataObjectInfo dataObjectInfo)
                            throws IOException

      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.

    - #### isObjectCached

          public boolean isObjectCached(AFPResourceInfo resourceInfo)

      Returns `true` if the passed `AFPResourceInfo` instance is already cached.
      Parameters:
        `resourceInfo` - the resource info to check
      Returns:
        `true` if the object is cached

    - #### includeCachedObject

          public boolean includeCachedObject(AFPResourceInfo resourceInfo,
                                             AFPObjectAreaInfo areaInfo)

      Parameters:
        `resourceInfo` - the resource info to check
        `areaInfo` - the area info to check
      Returns:
        `true` if ...

    - #### embedFont

          public void embedFont(AFPFont afpFont,
                                CharacterSet charSet)
                         throws IOException

      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 embedding
        `charSet` - the associated character set
      Throws:
        `IOException` - if there's a problem while embedding the external resources

    - #### 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 resource
        `accessor` - resource accessor to access the resource with
        `resourceObjectType` - 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 resource
        `uri` - the URI for the resource
        `accessor` - resource accessor to access the resource with
        `resourceObjectType` - the resource object type (`ResourceObject`.*)
      Throws:
        `IOException` - if an I/O error occurs while loading the resource

    - #### 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 resource
        `uri` - the URI for the resource
        `accessor` - resource accessor to access the resource with
      Throws:
        `IOException` - if an I/O error occurs while loading the resource

    - #### setResourceLevelDefaults

          public void setResourceLevelDefaults(AFPResourceLevelDefaults defaults)

      Sets resource level defaults. The existing defaults over merged with the ones passed in as parameter.
      Parameters:
        `defaults` - the new defaults

    - #### getResourceLevelDefaults

          public AFPResourceLevelDefaults getResourceLevelDefaults()

      Returns the resource level defaults in use with this resource manager.
      Returns:
        the resource level defaults

Copyright © 2023 Apache Software Foundation. All rights reserved.