Package org.faceless.publisher.resource
Class ZipURLConnectionFactory
java.lang.Object
org.faceless.publisher.resource.ZipURLConnectionFactory
- All Implemented Interfaces:
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Which variation of Zip file we're loading -
Constructor Summary
ConstructorDescriptionZipURLConnectionFactory
(BackedZipFile zip, URL2 base, ZipURLConnectionFactory.Flavor flavor) Create a URLConnectionFactory that will read entries from a ZIP file. -
Method Summary
Modifier and TypeMethodDescriptiongetInputStream
(BackedZipFile.Entry entry) Return the InputStream for the specified entry.getMediaType
(String name) Return the MediaType of the specified path if known, or null otherwisegetURLConnection
(URL2 uri, ReportFactory reportFactory) Return a URLConnection for the specified URI, or null if not possible with this factory.void
putMediaType
(String key, MediaType mediaType) Add a MediaType mapping for a file that (may be) within this Zip fileboolean
Return true if this factory can load the specified URI schema (eg http, ftp, jar, jdbc)Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.faceless.publisher.resource.URLConnectionFactory
close, getExpiry, getURLConnectionProcessors, isTrusted, isUnchanged, setURLConnectionProcessors
-
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 loadbase
- the base URI of the zip fileflavor
- the flavor of this zip-file- Throws:
IOException
-
-
Method Details
-
putMediaType
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
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
Return a URLConnection for the specified URI, or null if not possible with this factory.- Specified by:
getURLConnection
in interfaceURLConnectionFactory
- Parameters:
uri
- the URIreportFactory
- the ReportFactory that owns this connection- Throws:
IOException
-
supports
Return true if this factory can load the specified URI schema (eg http, ftp, jar, jdbc)- Specified by:
supports
in interfaceURLConnectionFactory
- Parameters:
uri
- the URI
-
getInputStream
Return the InputStream for the specified entry.- Throws:
IOException
-