Package 

Class ZipArchiveEntry

  • All Implemented Interfaces:
    java.lang.Cloneable , org.readium.r2.shared.util.zip.compress.archivers.ArchiveEntry , org.readium.r2.shared.util.zip.compress.archivers.EntryStreamOffsets

    
    public class ZipArchiveEntry
    extends ZipEntry implements ArchiveEntry, EntryStreamOffsets
                        

    Extension that adds better handling of extra fields and provides access to the internal and external file attributes.

    The extra data is expected to follow the recommendation of APPNOTE.TXT:

    • the extra byte array consists of a sequence of extra fields
    • each extra fields starts by a two byte header id followed by a two byte sequence holding the length of the remainder of data.

    Any extra data that cannot be parsed by the rules above will be consumed as "unparseable" extra data and treated differently by the methods of this class. Versions prior to Apache Commons Compress 1.1 would have thrown an exception if any attempt was made to read or write extra data not conforming to the recommendation.

    • Constructor Detail

      • ZipArchiveEntry

        ZipArchiveEntry(File inputFile, String entryName)
        Creates a new ZIP entry taking some information from the givenfile and using the provided name.
        Parameters:
        inputFile - file to create the entry from
        entryName - name of the entry
      • ZipArchiveEntry

        ZipArchiveEntry(ZipEntry entry)
        Creates a new ZIP entry with fields taken from the specified ZIP entry.
        Parameters:
        entry - the entry to get fields from
      • ZipArchiveEntry

        ZipArchiveEntry(String name)
        Creates a new ZIP entry with the specified name.
        Parameters:
        name - the name of the entry
      • ZipArchiveEntry

        ZipArchiveEntry(ZipArchiveEntry entry)
        Creates a new ZIP entry with fields taken from the specified ZIP entry.
        Parameters:
        entry - the entry to get fields from
    • Method Detail

      • getMethod

         int getMethod()

        Returns the compression method of this entry, or -1 if thecompression method has not been specified.

      • setMethod

         void setMethod(int method)

        Sets the compression method of this entry.

        Parameters:
        method - compression method
      • getSize

         long getSize()

        Gets the uncompressed size of the entry data.

      • setSize

         void setSize(long size)

        Sets the uncompressed size of the entry data.

        Parameters:
        size - the uncompressed size in bytes
      • setInternalAttributes

         void setInternalAttributes(int value)

        Sets the internal file attributes.

        Parameters:
        value - an {@code int} value
      • setVersionRequired

         void setVersionRequired(int versionRequired)

        Sets the "version required to expand" field.

        Parameters:
        versionRequired - "version required to expand" field
      • setVersionMadeBy

         void setVersionMadeBy(int versionMadeBy)

        Sets the "version made by" field.

        Parameters:
        versionMadeBy - "version made by" field
      • getPlatform

         int getPlatform()

        Platform specification to put into the "version madeby" part of the central file header.

      • setPlatform

         void setPlatform(int platform)

        Set the platform (UNIX or FAT).

        Parameters:
        platform - an {@code int} value - 0 is FAT, 3 is UNIX
      • getRawFlag

         int getRawFlag()

        The content of the flags field.

      • setRawFlag

         void setRawFlag(int rawFlag)

        Sets the content of the flags field.

        Parameters:
        rawFlag - content of the flags field
      • setExternalAttributes

         void setExternalAttributes(long value)

        Sets the external file attributes.

        Parameters:
        value - an {@code long} value
      • getAlignment

         int getAlignment()

        Gets currently configured alignment.

      • setAlignment

         void setAlignment(int alignment)

        Sets alignment for this entry.

        Parameters:
        alignment - requested alignment, 0 for default.
      • getName

         String getName()

        Get the name of the entry.

        This method returns the raw name as it is stored inside of the archive.

      • setName

         void setName(String name)

        Set the name of the entry.

        Parameters:
        name - the name to use
      • getRawName

         Array<byte> getRawName()

        Returns the raw bytes that made up the name before it has beenconverted using the configured or guessed encoding.

        This method will return null if this instance has not beenread from an archive.

      • getDataOffset

         long getDataOffset()

        Gets the offset of data stream within the archive file,

      • setDataOffset

         void setDataOffset(long dataOffset)

        Sets the data offset.

        Parameters:
        dataOffset - new value of data offset.
      • isStreamContiguous

         boolean isStreamContiguous()

        Indicates whether the stream is contiguous, i.e. not split amongseveral archive parts, interspersed with control blocks, etc.

      • getDiskNumberStart

         long getDiskNumberStart()

        The number of the split segment this entry starts at.

      • setDiskNumberStart

         void setDiskNumberStart(long diskNumberStart)

        The number of the split segment this entry starts at.

        Parameters:
        diskNumberStart - the number of the split segment this entry starts at.
      • setTime

         void setTime(long time)

        Override to work around bug JDK-8130914

        Parameters:
        time - The last modification time of the entry in millisecondssince the epoch
      • addAsFirstExtraField

         void addAsFirstExtraField(ZipExtraField ze)

        Adds an extra field - replacing an already present extra fieldof the same type.

        The new extra field will be the first one.

        Parameters:
        ze - an extra field
      • addExtraField

         void addExtraField(ZipExtraField ze)

        Adds an extra field - replacing an already present extra fieldof the same type.

        If no extra field of the same type exists, the field will beadded as last field.

        Parameters:
        ze - an extra field
      • getLastModifiedDate

         Date getLastModifiedDate()

        Wraps getTime with a Date as theentry's last modified date.

        Changes to the implementation of getTime leak through and the returned value may depend on your localtime zone as well as your version of Java.

      • hashCode

         int hashCode()

        Get the hash code of the entry.This uses the name as the hash code.

      • isDirectory

         boolean isDirectory()

        Is this entry a directory?

      • isUnixSymlink

         boolean isUnixSymlink()

        Returns true if this entry represents a unix symlink,in which case the entry's content contains the target pathfor the symlink.

      • removeExtraField

         void removeExtraField(ZipShort type)

        Remove an extra field.

        Parameters:
        type - the type of extra field to remove
      • setCentralDirectoryExtra

         void setCentralDirectoryExtra(Array<byte> b)

        Sets the central directory part of extra fields.

        Parameters:
        b - an array of bytes to be parsed into extra fields
      • setExtra

         void setExtra(Array<byte> extra)

        Parses the given bytes as extra field data and consumes anyunparseable data as an UnparseableExtraFieldData instance.

        Parameters:
        extra - an array of bytes to be parsed into extra fields
      • setUnixMode

         void setUnixMode(int mode)

        Sets Unix permissions in a way that is understood by Info-Zip'sunzip command.

        Parameters:
        mode - an {@code int} value