Class AbstractUnicodeExtraField

java.lang.Object
org.apache.commons.compress.archivers.zip.AbstractUnicodeExtraField
All Implemented Interfaces:
ZipExtraField
Direct Known Subclasses:
UnicodeCommentExtraField, UnicodePathExtraField

public abstract class AbstractUnicodeExtraField extends Object implements ZipExtraField
A common base class for Unicode extra information extra fields.
This class is not thread-safe
  • Constructor Details

    • AbstractUnicodeExtraField

      Constructs a new instance.
    • AbstractUnicodeExtraField

      protected AbstractUnicodeExtraField(String text, byte[] bytes)
      Assemble as unicode extension from the name/comment and encoding of the original ZIP entry.
      Parameters:
      text - The file name or comment.
      bytes - The encoded of the file name or comment in the ZIP file.
    • AbstractUnicodeExtraField

      protected AbstractUnicodeExtraField(String text, byte[] bytes, int off, int len)
      Assemble as unicode extension from the name/comment and encoding of the original ZIP entry.
      Parameters:
      text - The file name or comment.
      bytes - The encoded of the file name or comment in the ZIP file.
      off - The offset of the encoded file name or comment in bytes.
      len - The length of the encoded file name or comment in bytes.
  • Method Details

    • getCentralDirectoryData

      public byte[] getCentralDirectoryData()
      Description copied from interface: ZipExtraField
      The actual data to put into central directory - without Header-ID or length specifier.
      Specified by:
      getCentralDirectoryData in interface ZipExtraField
      Returns:
      the data
    • getCentralDirectoryLength

      Description copied from interface: ZipExtraField
      Length of the extra field in the central directory - without Header-ID or length specifier.
      Specified by:
      getCentralDirectoryLength in interface ZipExtraField
      Returns:
      the length of the field in the central directory
    • getLocalFileDataData

      public byte[] getLocalFileDataData()
      Description copied from interface: ZipExtraField
      The actual data to put into local file data - without Header-ID or length specifier.
      Specified by:
      getLocalFileDataData in interface ZipExtraField
      Returns:
      the data
    • getLocalFileDataLength

      Description copied from interface: ZipExtraField
      Length of the extra field in the local file data - without Header-ID or length specifier.
      Specified by:
      getLocalFileDataLength in interface ZipExtraField
      Returns:
      the length of the field in the local file data
    • getNameCRC32

      public long getNameCRC32()
      Gets the CRC32 checksum of the file name or comment as encoded in the central directory of the ZIP file.
      Returns:
      The CRC32 checksum of the file name or comment as encoded in the central directory of the ZIP file.
    • getUnicodeName

      public byte[] getUnicodeName()
      Gets The UTF-8 encoded name.
      Returns:
      The UTF-8 encoded name.
    • parseFromCentralDirectoryData

      public void parseFromCentralDirectoryData(byte[] buffer, int offset, int length) throws ZipException
      Doesn't do anything special since this class always uses the same data in central directory and local file data.
      Specified by:
      parseFromCentralDirectoryData in interface ZipExtraField
      Parameters:
      buffer - the buffer to read data from
      offset - offset into buffer to read data
      length - the length of data
      Throws:
      ZipException - on error
    • parseFromLocalFileData

      public void parseFromLocalFileData(byte[] buffer, int offset, int length) throws ZipException
      Description copied from interface: ZipExtraField
      Populate data from this array as if it was in local file data.
      Specified by:
      parseFromLocalFileData in interface ZipExtraField
      Parameters:
      buffer - the buffer to read data from
      offset - offset into buffer to read data
      length - the length of data
      Throws:
      ZipException - on error
    • setNameCRC32

      public void setNameCRC32(long nameCRC32)
      Gets The CRC32 checksum of the file name as encoded in the central directory of the ZIP file to set.
      Parameters:
      nameCRC32 - The CRC32 checksum of the file name as encoded in the central directory of the ZIP file to set.
    • setUnicodeName

      public void setUnicodeName(byte[] unicodeName)
      Gets the UTF-8 encoded name to set.
      Parameters:
      unicodeName - The UTF-8 encoded name to set.