Class GeneralPurposeBit

java.lang.Object
org.apache.commons.compress.archivers.zip.GeneralPurposeBit
All Implemented Interfaces:
Cloneable

public final class GeneralPurposeBit extends Object implements Cloneable
Parser/encoder for the "general purpose bit" field in ZIP's local file and central directory headers.
Since:
1.1
This class is not thread-safe
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Indicates that file names are written in UTF-8.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    byte[]
    Encodes the set bits in a form suitable for ZIP archives.
    void
    encode(byte[] buf, int offset)
    Encodes the set bits in a form suitable for ZIP archives.
    boolean
     
    int
     
    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
    whether the current entry uses the data descriptor to store CRC and size information.
    boolean
    whether the current entry is encrypted.
    boolean
    whether the current entry is encrypted using strong encryption.
    void
    whether the current entry will be encrypted using strong encryption.
    boolean
    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

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • 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
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • 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 buffer
      offset - The offset within the output buffer of the first byte to be written. must be non-negative and no larger than buf.length-2
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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
    • useEncryption

      public void useEncryption(boolean b)
      whether the current entry will be encrypted.
      Parameters:
      b - whether the current entry will be encrypted
    • 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
    • usesEncryption

      public boolean usesEncryption()
      whether the current entry is encrypted.
      Returns:
      whether the current entry is 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
    • 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.