Class GeneralPurposeBit
- java.lang.Object
-
- org.apache.commons.compress.archivers.zip.GeneralPurposeBit
-
- All Implemented Interfaces:
java.lang.Cloneable
public final class GeneralPurposeBit extends java.lang.Object implements java.lang.CloneableParser/encoder for the "general purpose bit" field in ZIP's local file and central directory headers.- Since:
- 1.1
-
-
Field Summary
Fields Modifier and Type Field Description private static intDATA_DESCRIPTOR_FLAGIndicates that a data descriptor stored after the file contents will hold CRC and size information.private booleandataDescriptorFlagprivate static intENCRYPTION_FLAGIndicates that the file is encrypted.private booleanencryptionFlagprivate booleanlanguageEncodingFlagprivate static intNUMBER_OF_SHANNON_FANO_TREES_FLAGIndicates the number of Shannon-Fano trees used by the compression method 6 (imploding).private intnumberOfShannonFanoTreesprivate static intSLIDING_DICTIONARY_SIZE_FLAGIndicates the size of the sliding dictionary used by the compression method 6 (imploding).private intslidingDictionarySizeprivate static intSTRONG_ENCRYPTION_FLAGIndicates strong encryption.private booleanstrongEncryptionFlagstatic intUFT8_NAMES_FLAGIndicates that file names are written in UTF-8.
-
Constructor Summary
Constructors Constructor Description GeneralPurposeBit()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()byte[]encode()Encodes the set bits in a form suitable for ZIP archives.voidencode(byte[] buf, int offset)Encodes the set bits in a form suitable for ZIP archives.booleanequals(java.lang.Object o)(package private) intgetNumberOfShannonFanoTrees()Returns the number of trees used by the compression method 6 (imploding).(package private) intgetSlidingDictionarySize()Returns the sliding dictionary size used by the compression method 6 (imploding).inthashCode()static GeneralPurposeBitparse(byte[] data, int offset)Parses the supported flags from the given archive data.voiduseDataDescriptor(boolean b)whether the current entry will use the data descriptor to store CRC and size information.voiduseEncryption(boolean b)whether the current entry will be encrypted.booleanusesDataDescriptor()whether the current entry uses the data descriptor to store CRC and size information.booleanusesEncryption()whether the current entry is encrypted.booleanusesStrongEncryption()whether the current entry is encrypted using strong encryption.voiduseStrongEncryption(boolean b)whether the current entry will be encrypted using strong encryption.booleanusesUTF8ForNames()whether the current entry uses UTF8 for file name and comment.voiduseUTF8ForNames(boolean b)whether the current entry will use UTF8 for file name and comment.
-
-
-
Field Detail
-
ENCRYPTION_FLAG
private static final int ENCRYPTION_FLAG
Indicates that the file is encrypted.- See Also:
- Constant Field Values
-
SLIDING_DICTIONARY_SIZE_FLAG
private static final int SLIDING_DICTIONARY_SIZE_FLAG
Indicates the size of the sliding dictionary used by the compression method 6 (imploding).- 0: 4096 bytes
- 1: 8192 bytes
- See Also:
- Constant Field Values
-
NUMBER_OF_SHANNON_FANO_TREES_FLAG
private static final int NUMBER_OF_SHANNON_FANO_TREES_FLAG
Indicates the number of Shannon-Fano trees used by the compression method 6 (imploding).- 0: 2 trees (lengths, distances)
- 1: 3 trees (literals, lengths, distances)
- 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 file names are written in UTF-8.The only reason this is public is that
ZipArchiveOutputStream.EFS_FLAGwas 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
-
slidingDictionarySize
private int slidingDictionarySize
-
numberOfShannonFanoTrees
private int numberOfShannonFanoTrees
-
-
Method Detail
-
usesUTF8ForNames
public boolean usesUTF8ForNames()
whether the current entry uses UTF8 for file name and comment.- Returns:
- 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.- Parameters:
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.- Returns:
- 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.- Parameters:
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.- Returns:
- whether the current entry is encrypted
-
useEncryption
public void useEncryption(boolean b)
whether the current entry will be encrypted.- Parameters:
b- whether the current entry will be encrypted
-
usesStrongEncryption
public boolean usesStrongEncryption()
whether the current entry is encrypted using strong encryption.- Returns:
- 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.- Parameters:
b- whether the current entry will be encrypted using strong encryption
-
getSlidingDictionarySize
int getSlidingDictionarySize()
Returns the sliding dictionary size used by the compression method 6 (imploding).
-
getNumberOfShannonFanoTrees
int getNumberOfShannonFanoTrees()
Returns the number of trees used by the compression method 6 (imploding).
-
encode
public byte[] encode()
Encodes the set bits in a form suitable for ZIP archives.- Returns:
- the encoded general purpose bits
-
encode
public void encode(byte[] buf, int offset)Encodes the set bits in a form suitable for ZIP archives.- Parameters:
buf- the output bufferoffset- The offset within the output buffer of the first byte to be written. must be non-negative and no larger thanbuf.length-2
-
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- Returns:
- parsed flags
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
clone
public java.lang.Object clone()
- Overrides:
clonein classjava.lang.Object
-
-