Class EpubResourceLoader

java.lang.Object
org.faceless.publisher.ext.EpubResourceLoader
All Implemented Interfaces:
ResourceLoader

public class EpubResourceLoader extends Object implements ResourceLoader
A top-level ResourceLoader for loading EPUB documents by converting them to first to HTML, for processing with BFO Publisher. Based on EPub 3.2.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the URL of the CSS stylesheet applied to any EPUB documents processed with this ResourceLoader.
    Return the URL of the XSLT stylesheet applied to each item in EPUB documents processed with this ResourceLoader.
    Return the list of processing instructions applied to the EPUB documents processed with this ResourceLaoder.
    Return the URL of the XSLT stylesheet applied to any EPUB documents processed with this ResourceLoader.
    load(ResourceDescriptor descriptor, Resource resource, URL2Connection con)
    Attempt to load a Resource from the specified URL2Connection.
    void
    setCSS(URL2 uri)
    Set the URL of the CSS stylesheet applied to any EPUB documents processed with this ResourceLoader
    void
    Set the URL of the XSLT stylesheet applied to each item included in any EPUB documents processed with this ResourceLoader.
    void
    Set the URL of the XSLT stylesheet applied to any EPUB documents processed with this ResourceLoader
    boolean
    Return true if this ResourceLoader could load a descriptor of the specified type.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.faceless.publisher.resource.ResourceLoader

    isTrustRequired
  • Constructor Details

    • EpubResourceLoader

      public EpubResourceLoader()
  • Method Details

    • setCSS

      public void setCSS(URL2 uri)
      Set the URL of the CSS stylesheet applied to any EPUB documents processed with this ResourceLoader
      Parameters:
      uri - the URL of the CSS stylesheet to use for EPUB, or null to not use any.
    • setXSLT

      public void setXSLT(URL2 uri)
      Set the URL of the XSLT stylesheet applied to any EPUB documents processed with this ResourceLoader
      Parameters:
      uri - the URL of the XSLT stylesheet to use for EPUB, or null to not use any.
    • setItemXSLT

      public void setItemXSLT(URL2 uri)
      Set the URL of the XSLT stylesheet applied to each item included in any EPUB documents processed with this ResourceLoader. This is distinct from the XSLT stylesheet applied to the document as a whole.
      Parameters:
      uri - the URL of the XSLT stylesheet to use for each item in the EPUB, or null to not use any.
    • getCSS

      public URL2 getCSS()
      Return the URL of the CSS stylesheet applied to any EPUB documents processed with this ResourceLoader.
    • getXSLT

      public URL2 getXSLT()
      Return the URL of the XSLT stylesheet applied to any EPUB documents processed with this ResourceLoader.
    • getItemXSLT

      public URL2 getItemXSLT()
      Return the URL of the XSLT stylesheet applied to each item in EPUB documents processed with this ResourceLoader.
    • getProcessingInstructions

      public List<ProcessingInstruction> getProcessingInstructions()
      Return the list of processing instructions applied to the EPUB documents processed with this ResourceLaoder. The list may be modified.
    • supports

      public boolean supports(ResourceDescriptor descriptor)
      Description copied from interface: ResourceLoader
      Return true if this ResourceLoader could load a descriptor of the specified type. The resourceClass, outputClass and mediaType of the descriptor should be checked as appropriate. The MediaType in particular will not be a wildcard for normal use; it may be a wildcard if we're being called from ResourceManager.getResourceLoader(org.faceless.publisher.type.MediaType, java.lang.Class<?>).
      Specified by:
      supports in interface ResourceLoader
    • load

      public ResourceFlavor load(ResourceDescriptor descriptor, Resource resource, URL2Connection con) throws IOException
      Description copied from interface: ResourceLoader
      Attempt to load a Resource from the specified URL2Connection. If the ResourceLoader applies (it should test the resource mediatype and class) then it should load the resource from the URL. If the URI has a fragment and the loaded resource to ALL fragments, it should change the URI to have no fragment. Likewise if any aspect of the MediaType does not apply (i.e. the encoding) then it should remove it, so the Resource describes the widest possible URI and MediaType that would match this object. Finally, on success this method should set the Object on the resource, or throw an exception on failure. The supplied "con" will have an InputStream that is mark-capable already. If the stream is a gzip or brotli compresed stream, decompression will already be applied. The mediatype wil be set on "d". Returning null from this object is considered an error condition - if that happens we shouldn't have got here, and the only reason we did was because "supports" for the same descriptor returned true.
      Specified by:
      load in interface ResourceLoader
      Parameters:
      descriptor - the descriptor of what type of flavor we want.
      resource - the Resource we're populating
      con - the URLConnection to load the resource from
      Returns:
      the new Flavor, or null if it doesn't apply.
      Throws:
      IOException