TrueZIP 6.8.1

de.schlichtherle.io.archive.zip
Class OdfDriver

java.lang.Object
  extended by de.schlichtherle.io.archive.spi.AbstractArchiveDriver
      extended by de.schlichtherle.io.archive.zip.ZipDriver
          extended by de.schlichtherle.io.archive.zip.JarDriver
              extended by de.schlichtherle.io.archive.zip.OdfDriver
All Implemented Interfaces:
ArchiveDriver, Serializable
Direct Known Subclasses:
CheckedOdfDriver

public class OdfDriver
extends JarDriver

An archive driver which supports building archive files according to the specification of the OpenDocument Format (ODF), version 1.1. This driver ensures that the entry named mimetype, if present at all, is always written as the first entry and uses the STORED method rather than the DEFLATED method in the resulting archive file in order to meet the requirements of section 17.4 of the OpenDocument Specification, version 1.1.

Other than this, ODF files are treated like regular JAR files. In particular, this class does not check an ODF file for the existance of the META-INF/manifest.xml entry or any other entry.

Instances of this class are immutable.

How to use this driver

An ODF file is either a plain XML file or a JAR file (called package).

If it's an XML file, the method File.isFile() returns true and this driver is actually never used. It's up to the client application to recognize this and deal with the ODF file appropriately.

If it's a JAR file however, the method File.isDirectory() returns true and this driver is used to access the file. The client application can then access the ODF file transparently as if it were a directory in a path. If a mimetype entry is to be created or modified, this should be done first in order to provide best performance.

Since:
TrueZIP 6.5
Version:
$Id: OdfDriver.java,v 1.4 2010/08/20 13:09:51 christian_schlichtherle Exp $
Author:
Christian Schlichtherle
See Also:
OdfOutputArchive, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class de.schlichtherle.io.archive.spi.AbstractArchiveDriver
AbstractArchiveDriver.InconsistentCharsetSupportError
 
Field Summary
 
Fields inherited from class de.schlichtherle.io.archive.zip.JarDriver
DEFAULT_CHARSET
 
Fields inherited from class de.schlichtherle.io.archive.zip.ZipDriver
DEFAULT_LEVEL
 
Constructor Summary
OdfDriver()
          Equivalent to this(null, null, false, false, DEFAULT_LEVEL).
OdfDriver(Icon openIcon, Icon closedIcon, boolean preambled, boolean postambled, int level)
          Constructs a new ODF driver.
OdfDriver(int level)
          Equivalent to this(null, null, false, false, level).
 
Method Summary
 OutputArchive createOutputArchive(Archive archive, OutputStream out, InputArchive source)
          Creates a new output archive for archive from the given output stream.
 
Methods inherited from class de.schlichtherle.io.archive.zip.JarDriver
createZipEntry, createZipEntry, createZipInputArchive
 
Methods inherited from class de.schlichtherle.io.archive.zip.ZipDriver
createArchiveEntry, createInputArchive, createZip32InputArchive, createZip32OutputArchive, createZipOutputArchive, getLevel, getPostambled, getPreambled
 
Methods inherited from class de.schlichtherle.io.archive.spi.AbstractArchiveDriver
ensureEncodable, getCharset, getClosedIcon, getEncoding, getOpenIcon
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.schlichtherle.io.archive.spi.ArchiveDriver
equals, hashCode
 

Constructor Detail

OdfDriver

public OdfDriver()
Equivalent to this(null, null, false, false, DEFAULT_LEVEL).


OdfDriver

public OdfDriver(int level)
Equivalent to this(null, null, false, false, level).


OdfDriver

public OdfDriver(Icon openIcon,
                 Icon closedIcon,
                 boolean preambled,
                 boolean postambled,
                 int level)
Constructs a new ODF driver.

Method Detail

createOutputArchive

public OutputArchive createOutputArchive(Archive archive,
                                         OutputStream out,
                                         InputArchive source)
                                  throws IOException
Description copied from class: ZipDriver
Creates a new output archive for archive from the given output stream.

The implementation in ZipDriver simply forwards the call to ZipDriver.createZipOutputArchive(de.schlichtherle.io.archive.Archive, java.io.OutputStream, de.schlichtherle.io.archive.zip.ZipInputArchive) and wraps the result in a new MultiplexedOutputArchive.

Specified by:
createOutputArchive in interface ArchiveDriver
Overrides:
createOutputArchive in class ZipDriver
Parameters:
archive - The abstract archive representation which TrueZIP's internal ArchiveController is processing - never null.
out - The OutputStream to write the archive entries to - never null.
source - The source InputArchive if archive is going to get updated. If not null, this is guaranteed to be a product of this driver's ArchiveDriver.createInputArchive(de.schlichtherle.io.archive.Archive, de.schlichtherle.io.rof.ReadOnlyFile) method. This may be used to copy some meta data which is specific to the type of archive this driver supports. For example, this could be used to copy the comment of a ZIP file.
Returns:
A new output archive instance.
Throws:
TransientIOException - If calling this method for the same archive file again may finally succeed. This exception is associated with another IOException as its cause which is unwrapped and interpreted as below.
FileNotFoundException - If the output archive is inaccessible for any reason.
IOException - On any other I/O or data format related issue when writing the output archive.
See Also:
OutputArchive

TrueZIP 6.8.1

Copyright © 2005-2010 Schlichtherle IT Services. All Rights Reserved.