TrueZIP Driver ZIP 7.0

de.schlichtherle.truezip.fs.archive.zip
Class ZipDriver

java.lang.Object
  extended by de.schlichtherle.truezip.fs.FsDriver
      extended by de.schlichtherle.truezip.fs.archive.FsArchiveDriver<E>
          extended by de.schlichtherle.truezip.fs.archive.FsCharsetArchiveDriver<ZipArchiveEntry>
              extended by de.schlichtherle.truezip.fs.archive.zip.ZipDriver
All Implemented Interfaces:
EntryFactory<ZipArchiveEntry>, ZipEntryFactory<ZipArchiveEntry>
Direct Known Subclasses:
CheckedZipDriver, JarDriver, ReadOnlySfxDriver

@Immutable
@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class)
public class ZipDriver
extends FsCharsetArchiveDriver<ZipArchiveEntry>
implements ZipEntryFactory<ZipArchiveEntry>

An archive driver which builds ZIP files. Note that this driver does not check the CRC value of any entries in existing archives.

Author:
Christian Schlichtherle
See Also:
CheckedZipDriver

Field Summary
private  IOPool<?> pool
           
private static Charset ZIP_CHARSET
          The default character set for entry names and comments, which is "IBM437".
 
Constructor Summary
  ZipDriver(IOPoolProvider service)
          Equivalent to new ZipDriver(pool, ZIP_CHARSET).
protected ZipDriver(IOPoolProvider provider, Charset charset)
          Constructs a new ZIP driver.
 
Method Summary
 int getLevel()
          Returns the value of the property level.
 int getMethod()
          Returns the value of the property method.
 IOPool<?> getPool()
           
 boolean getPostambled()
          Returns the value of the property postambled.
 boolean getPreambled()
          Returns the value of the property preambled.
 ZipArchiveEntry newEntry(String name)
          Returns a new ZIP entry with the given name.
 ZipArchiveEntry newEntry(String name, Entry.Type type, Entry template)
           
 ZipArchiveEntry newEntry(String name, ZipArchiveEntry template)
           
 ZipInputShop newInputShop(FsConcurrentModel model, InputSocket<?> input)
           The implementation in the class ZipDriver acquires a read only file from the given socket and forwards the call to newZipInputShop(de.schlichtherle.truezip.fs.FsConcurrentModel, de.schlichtherle.truezip.rof.ReadOnlyFile).
 OutputShop<ZipArchiveEntry> newOutputShop(FsConcurrentModel model, OutputSocket<?> output, InputShop<ZipArchiveEntry> source)
           The implementation in ZipDriver simply forwards the call to newZipOutputShop(de.schlichtherle.truezip.fs.FsConcurrentModel, java.io.OutputStream, de.schlichtherle.truezip.fs.archive.zip.ZipInputShop) and wraps the result in a new FsMultiplexedArchiveOutputShop.
protected  ZipInputShop newZipInputShop(FsConcurrentModel model, ReadOnlyFile rof)
           
protected  ZipOutputShop newZipOutputShop(FsConcurrentModel model, OutputStream out, ZipInputShop source)
           
 
Methods inherited from class de.schlichtherle.truezip.fs.archive.FsCharsetArchiveDriver
assertEncodable, getCharset, toString, toZipOrTarEntryName
 
Methods inherited from class de.schlichtherle.truezip.fs.archive.FsArchiveDriver
getClosedIcon, getOpenIcon, isFederated, newController
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZIP_CHARSET

private static final Charset ZIP_CHARSET
The default character set for entry names and comments, which is "IBM437".


pool

private final IOPool<?> pool
Constructor Detail

ZipDriver

public ZipDriver(IOPoolProvider service)
Equivalent to new ZipDriver(pool, ZIP_CHARSET).


ZipDriver

protected ZipDriver(IOPoolProvider provider,
                    Charset charset)
Constructs a new ZIP driver.

Parameters:
provider - the I/O pool service to use for allocating temporary I/O entries.
charset - the character set to use for entry names and comments.
Method Detail

getPool

public final IOPool<?> getPool()
Specified by:
getPool in class FsArchiveDriver<ZipArchiveEntry>

getPreambled

public boolean getPreambled()
Returns the value of the property preambled. If this is true, then a ZIP file is allowed to contain arbitrary data as its preamble before the actual ZIP file data. Self Extracting Archives typically use a preamble to store the application code that is required to extract the ZIP file contents.

Note that searching for a preamble can seriously degrade the performance if the file is not compatible to the ZIP File Format Specification.

The implementation in the class ZipDriver returns false.

Returns:
The value of the property preambled.

getPostambled

public boolean getPostambled()
Returns the value of the property postambled. If this is true, then a ZIP file is allowed to contain arbitrary length data as its postamble after the actual ZIP file data.

If this is false, then a ZIP file may still have a postamble. However, the postamble must not exceed 64KB size, including the End Of Central Directory record and thus the ZIP file comment. This causes the initial ZIP file compatibility test to fail fast if the file is not compatible to the ZIP File Format Specification.

Note that searching for an arbitrary length postamble can seriously degrade the performance if the file is not compatible to the ZIP File Format Specification. So this should be set to true only if Self Extracting Archives with very large postambles need to get supported.

The implementation in the class ZipDriver returns false.

Returns:
The value of the property postambled.

getMethod

public int getMethod()
Returns the value of the property method. This is the compression method to use when writing an entry to a ZIP output stream.

The implementation in the class ZipDriver returns ZipEntry.DEFLATED.

Returns:
The value of the property method.

getLevel

public int getLevel()
Returns the value of the property level. This is the compression level to use when deflating an entry to a ZIP output stream.

The implementation in the class ZipDriver returns Deflater.BEST_COMPRESSION.

Returns:
The value of the property level.

newEntry

public ZipArchiveEntry newEntry(String name,
                                Entry.Type type,
                                Entry template)
                         throws CharConversionException
Specified by:
newEntry in interface EntryFactory<ZipArchiveEntry>
Throws:
CharConversionException

newEntry

public ZipArchiveEntry newEntry(String name)
Description copied from interface: ZipEntryFactory
Returns a new ZIP entry with the given name.

Specified by:
newEntry in interface ZipEntryFactory<ZipArchiveEntry>
Parameters:
name - the entry name - null is not permitted.
Returns:
A new ZIP entry with the given name.

newEntry

public ZipArchiveEntry newEntry(String name,
                                ZipArchiveEntry template)

newInputShop

public ZipInputShop newInputShop(FsConcurrentModel model,
                                 InputSocket<?> input)
                          throws IOException

The implementation in the class ZipDriver acquires a read only file from the given socket and forwards the call to newZipInputShop(de.schlichtherle.truezip.fs.FsConcurrentModel, de.schlichtherle.truezip.rof.ReadOnlyFile).

Specified by:
newInputShop in class FsArchiveDriver<ZipArchiveEntry>
Throws:
IOException

newZipInputShop

protected ZipInputShop newZipInputShop(FsConcurrentModel model,
                                       ReadOnlyFile rof)
                                throws IOException
Throws:
IOException

newOutputShop

public OutputShop<ZipArchiveEntry> newOutputShop(FsConcurrentModel model,
                                                 OutputSocket<?> output,
                                                 @CheckForNull
                                                 InputShop<ZipArchiveEntry> source)
                                          throws IOException

The implementation in ZipDriver simply forwards the call to newZipOutputShop(de.schlichtherle.truezip.fs.FsConcurrentModel, java.io.OutputStream, de.schlichtherle.truezip.fs.archive.zip.ZipInputShop) and wraps the result in a new FsMultiplexedArchiveOutputShop.

Specified by:
newOutputShop in class FsArchiveDriver<ZipArchiveEntry>
Throws:
IOException

newZipOutputShop

protected ZipOutputShop newZipOutputShop(FsConcurrentModel model,
                                         OutputStream out,
                                         @CheckForNull
                                         ZipInputShop source)
                                  throws IOException
Throws:
IOException

TrueZIP Driver ZIP 7.0

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