org.apache.commons.compress.archivers.zip
Class GeneralPurposeBit

java.lang.Object
  extended by org.apache.commons.compress.archivers.zip.GeneralPurposeBit

public final class GeneralPurposeBit
extends java.lang.Object

Parser/encoder for the "general purpose bit" field in ZIP's local file and central directory headers.

Since:
Apache Commons Compress 1.1

Field Summary
private static int DATA_DESCRIPTOR_FLAG
          Indicates that a data descriptor stored after the file contents will hold CRC and size information.
private  boolean dataDescriptorFlag
           
private static int ENCRYPTION_FLAG
          Indicates that the file is encrypted.
private  boolean encryptionFlag
           
private  boolean languageEncodingFlag
           
private static int STRONG_ENCRYPTION_FLAG
          Indicates strong encryption.
private  boolean strongEncryptionFlag
           
static int UFT8_NAMES_FLAG
          Indicates that filenames are written in utf-8.
 
Constructor Summary
GeneralPurposeBit()
           
 
Method Summary
 byte[] encode()
          Encodes the set bits in a form suitable for ZIP archives.
 boolean equals(java.lang.Object o)
           
 int hashCode()
           
static GeneralPurposeBit parse(byte[] data, int offset)
          Parses the supported flags from the given archive data.
 void useDataDescriptor(boolean b)
          whether the current entry will use the data descriptor to store CRC and size information
 void useEncryption(boolean b)
          whether the current entry will be encrypted
 boolean usesDataDescriptor()
          whether the current entry uses the data descriptor to store CRC and size information
 boolean usesEncryption()
          whether the current entry is encrypted
 boolean usesStrongEncryption()
          whether the current entry is encrypted using strong encryption
 void useStrongEncryption(boolean b)
          whether the current entry will be encrypted using strong encryption
 boolean usesUTF8ForNames()
          whether the current entry uses UTF8 for file name and comment.
 void useUTF8ForNames(boolean b)
          whether the current entry will use UTF8 for file name and comment.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCRYPTION_FLAG

private static final int ENCRYPTION_FLAG
Indicates that the file is encrypted.

See Also:
Constant Field Values

DATA_DESCRIPTOR_FLAG

private static final int DATA_DESCRIPTOR_FLAG
Indicates that a data descriptor stored after the file contents will hold CRC and size information.

See Also:
Constant Field Values

STRONG_ENCRYPTION_FLAG

private static final int STRONG_ENCRYPTION_FLAG
Indicates strong encryption.

See Also:
Constant Field Values

UFT8_NAMES_FLAG

public static final int UFT8_NAMES_FLAG
Indicates that filenames are written in utf-8.

The only reason this is public is that ZipArchiveOutputStream.EFS_FLAG was public in Apache Commons Compress 1.0 and we needed a substitute for it.

See Also:
Constant Field Values

languageEncodingFlag

private boolean languageEncodingFlag

dataDescriptorFlag

private boolean dataDescriptorFlag

encryptionFlag

private boolean encryptionFlag

strongEncryptionFlag

private boolean strongEncryptionFlag
Constructor Detail

GeneralPurposeBit

public GeneralPurposeBit()
Method Detail

usesUTF8ForNames

public boolean usesUTF8ForNames()
whether the current entry uses UTF8 for file name and comment.


useUTF8ForNames

public void useUTF8ForNames(boolean b)
whether the current entry will use UTF8 for file name and comment.


usesDataDescriptor

public boolean usesDataDescriptor()
whether the current entry uses the data descriptor to store CRC and size information


useDataDescriptor

public void useDataDescriptor(boolean b)
whether the current entry will use the data descriptor to store CRC and size information


usesEncryption

public boolean usesEncryption()
whether the current entry is encrypted


useEncryption

public void useEncryption(boolean b)
whether the current entry will be encrypted


usesStrongEncryption

public boolean usesStrongEncryption()
whether the current entry is encrypted using strong encryption


useStrongEncryption

public void useStrongEncryption(boolean b)
whether the current entry will be encrypted using strong encryption


encode

public byte[] encode()
Encodes the set bits in a form suitable for ZIP archives.


parse

public static GeneralPurposeBit parse(byte[] data,
                                      int offset)
Parses the supported flags from the given archive data.

Parameters:
data - local file header or a central directory entry.
offset - offset at which the general purpose bit starts

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object