Class ZipURLConnectionFactory

java.lang.Object
org.faceless.publisher.resource.ZipURLConnectionFactory
All Implemented Interfaces:
URLConnectionFactory

public class ZipURLConnectionFactory extends Object implements URLConnectionFactory
A URLConnectionFactory that can be used to load resources from a Zip file. As well as the plain zip files, the variations used for MS Office, Open Documents and ePub are supported.
  • Constructor Details

    • ZipURLConnectionFactory

      public ZipURLConnectionFactory(BackedZipFile zip, URL2 base, ZipURLConnectionFactory.Flavor flavor) throws IOException
      Create a URLConnectionFactory that will read entries from a ZIP file. If the file contains the entry "[Content_Types].xml" that will be parsed to retrieve the content-type of each item (this is the case for ooxml)
      Parameters:
      zip - the zip file to load
      base - the base URI of the zip file
      flavor - the flavor of this zip-file
      Throws:
      IOException
  • Method Details

    • putMediaType

      public void putMediaType(String key, MediaType mediaType)
      Add a MediaType mapping for a file that (may be) within this Zip file
      Parameters:
      key - the key - either a pathname relative to the root of this zip, the format "*.nnn" to set a mapping for files with extension ".nnn", or null for the content-type of the container itself.
      mediaType - the media-type, or null to remove it
    • getMediaType

      public MediaType getMediaType(String name)
      Return the MediaType of the specified path if known, or null otherwise
      Parameters:
      name - the filename, or null to return the MediaType of the whole Zip
    • getURLConnection

      public URL2Connection getURLConnection(URL2 uri, ReportFactory reportFactory) throws IOException
      Return a URLConnection for the specified URI, or null if not possible with this factory.
      Specified by:
      getURLConnection in interface URLConnectionFactory
      Parameters:
      uri - the URI
      reportFactory - the ReportFactory that owns this connection
      Throws:
      IOException
    • supports

      public boolean supports(URL2 uri)
      Return true if this factory can load the specified URI schema (eg http, ftp, jar, jdbc)
      Specified by:
      supports in interface URLConnectionFactory
      Parameters:
      uri - the URI
    • getInputStream

      public InputStream getInputStream(BackedZipFile.Entry entry) throws IOException
      Return the InputStream for the specified entry.
      Throws:
      IOException