org.at4j.zip
Class ZipGeneralPurposeBitFlags

java.lang.Object
  extended by org.at4j.zip.ZipGeneralPurposeBitFlags

public class ZipGeneralPurposeBitFlags
extends Object

This object contains boolean properties that represent the general purpose bit flags of a Zip entry. Some of the properties are compression method-specific.

Since:
1.0
Author:
Karl Gustafsson

Constructor Summary
ZipGeneralPurposeBitFlags()
          Create a new general purpose bit flags object with all properties set to false.
ZipGeneralPurposeBitFlags(UnsignedShort s)
          Create a new general purpose bit flags object that is initialized with the contents of the supplied short object read from a Zip entry header.
 
Method Summary
 boolean is3ShannonFanoTrees()
           Bit 2: If the compression method used was type 6, Imploding, then this bit, if set, indicates 3 Shannon-Fano trees were used to encode the sliding dictionary output.
 boolean is8kSlidingDictionary()
           Bit 1: If the compression method used was type 6, Imploding, then this bit, if set, indicates an 8K sliding dictionary was used.
 boolean isCompressedPatchedData()
           Bit 5: If this bit is set, this indicates that the file is compressed patched data.
 boolean isEncrypted()
           Bit 0: If set, indicates that the file is encrypted.
 boolean isEosMarkerUsed()
           (For Method 14 - LZMA) Bit 1: If the compression method used was type 14, LZMA, then this bit, if set, indicates an end-of-stream (EOS) marker is used to mark the end of the compressed data stream.
 boolean isFastCompression()
           (For Methods 8 and 9 - Deflating) Bit 2 Bit 1 1 0 Fast (-ef) compression option was used.
 boolean isLocalHeaderFieldZeroed()
           Bit 3: If this bit is set, the fields crc-32, compressed size and uncompressed size are set to zero in the local header.
 boolean isLocalHeaderValuesMasked()
           Bit 13: Used when encrypting the Central Directory to indicate selected data values in the Local Header are masked to hide their actual values.
 boolean isMaximumCompression()
           (For Methods 8 and 9 - Deflating) Bit 2 Bit 1 0 1 Maximum (-exx/-ex) compression option was used.
 boolean isStrongEncryption()
           Bit 6: Strong encryption.
 boolean isSuperFastCompression()
           (For Methods 8 and 9 - Deflating) Bit 2 Bit 1 1 1 Super Fast (-es) compression option was used.
 boolean isUtf8Encoding()
           Bit 11: Language encoding flag (EFS).
 void set3ShannonFanoTrees(boolean b)
           
 void set8kSlidingDictionary(boolean b)
           
 void setCompressedPatchedData(boolean b)
           
 void setEncrypted(boolean encrypted)
           
 void setEosMarkerUsed(boolean b)
           
 void setFastCompression(boolean b)
           
 void setLocalHeaderFieldsZeroed(boolean b)
           
 void setLocalHeaderValuesMasked(boolean b)
           
 void setMaximumCompression(boolean b)
           
 void setStrongEncryption(boolean b)
           
 void setSuperFastCompression(boolean b)
           
 void setUtf8Encoding(boolean b)
           
 byte[] toBytes(ZipEntryCompressionMethod cm)
          Encode the bit flag values for storing them in a Zip file header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipGeneralPurposeBitFlags

public ZipGeneralPurposeBitFlags()
Create a new general purpose bit flags object with all properties set to false.


ZipGeneralPurposeBitFlags

public ZipGeneralPurposeBitFlags(UnsignedShort s)
Create a new general purpose bit flags object that is initialized with the contents of the supplied short object read from a Zip entry header.

Parameters:
s - The short object containing data read from a Zip entry header.
Method Detail

isEncrypted

public boolean isEncrypted()
 Bit 0: If set, indicates that the file is encrypted.
 

Returns:
true if the file is encrypted.

setEncrypted

public void setEncrypted(boolean encrypted)

is8kSlidingDictionary

public boolean is8kSlidingDictionary()
 Bit 1: If the compression method used was type 6,
        Imploding, then this bit, if set, indicates
        an 8K sliding dictionary was used.  If clear,
        then a 4K sliding dictionary was used.
 

Returns:
true if an 8k sliding dictionary was used.

set8kSlidingDictionary

public void set8kSlidingDictionary(boolean b)

is3ShannonFanoTrees

public boolean is3ShannonFanoTrees()
 Bit 2: If the compression method used was type 6,
        Imploding, then this bit, if set, indicates
        3 Shannon-Fano trees were used to encode the
        sliding dictionary output.  If clear, then 2
        Shannon-Fano trees were used.
 

Returns:
true if 3 Shannon-Fano trees were used.

set3ShannonFanoTrees

public void set3ShannonFanoTrees(boolean b)

isMaximumCompression

public boolean isMaximumCompression()
 (For Methods 8 and 9 - Deflating)
 Bit 2  Bit 1
   0      1    Maximum (-exx/-ex) compression option was used.
 

Returns:
true if the maximum compression option was used.

setMaximumCompression

public void setMaximumCompression(boolean b)

isFastCompression

public boolean isFastCompression()
 (For Methods 8 and 9 - Deflating)
 Bit 2  Bit 1
   1      0    Fast (-ef) compression option was used.
 

Returns:
true if the fast compression option was used.

setFastCompression

public void setFastCompression(boolean b)

isSuperFastCompression

public boolean isSuperFastCompression()
 (For Methods 8 and 9 - Deflating)
 Bit 2  Bit 1
   1      1    Super Fast (-es) compression option was used.
 

Returns:
true if the super fast compression option was used.

setSuperFastCompression

public void setSuperFastCompression(boolean b)

isEosMarkerUsed

public boolean isEosMarkerUsed()
 (For Method 14 - LZMA)
 Bit 1: If the compression method used was type 14,
        LZMA, then this bit, if set, indicates
        an end-of-stream (EOS) marker is used to
        mark the end of the compressed data stream.
        If clear, then an EOS marker is not present
        and the compressed data size must be known
        to extract.
 

Returns:
true if an EOS marker is used.

setEosMarkerUsed

public void setEosMarkerUsed(boolean b)

isLocalHeaderFieldZeroed

public boolean isLocalHeaderFieldZeroed()
 Bit 3: If this bit is set, the fields crc-32, compressed 
        size and uncompressed size are set to zero in the 
        local header.  The correct values are put in the 
        data descriptor immediately following the compressed
        data.  (Note: PKZIP version 2.04g for DOS only 
        recognizes this bit for method 8 compression, newer 
        versions of PKZIP recognize this bit for any 
        compression method.)
 

Returns:
true if the local header fields are zeroed.

setLocalHeaderFieldsZeroed

public void setLocalHeaderFieldsZeroed(boolean b)

isCompressedPatchedData

public boolean isCompressedPatchedData()
 Bit 5: If this bit is set, this indicates that the file is 
              compressed patched data.  (Note: Requires PKZIP 
              version 2.70 or greater)
 

Returns:
true if the file is compressed patched data.

setCompressedPatchedData

public void setCompressedPatchedData(boolean b)

isStrongEncryption

public boolean isStrongEncryption()
 Bit 6: Strong encryption.  If this bit is set, you should
        set the version needed to extract value to at least
        50 and you must also set bit 0.  If AES encryption
        is used, the version needed to extract value must 
        be at least 51.
 

Returns:
true if strong encryption is used.

setStrongEncryption

public void setStrongEncryption(boolean b)

isUtf8Encoding

public boolean isUtf8Encoding()
 Bit 11: Language encoding flag (EFS).  If this bit is set,
         the filename and comment fields for this file
         must be encoded using UTF-8. (see APPENDIX D)
 

Returns:
true if UTF-8 encoding must be used.

setUtf8Encoding

public void setUtf8Encoding(boolean b)

isLocalHeaderValuesMasked

public boolean isLocalHeaderValuesMasked()
 Bit 13: Used when encrypting the Central Directory to indicate 
         selected data values in the Local Header are masked to
         hide their actual values.  See the section describing 
         the Strong Encryption Specification for details.
 

Returns:
true if selected local header data values are masked.

setLocalHeaderValuesMasked

public void setLocalHeaderValuesMasked(boolean b)

toBytes

public byte[] toBytes(ZipEntryCompressionMethod cm)
Encode the bit flag values for storing them in a Zip file header.

Parameters:
cm - The compression method used for the Zip file.
Returns:
The general purpose bit flags, encoded in a two bytes long byte array.