Class JBZipEntry

  • All Implemented Interfaces:
    Cloneable

    public class JBZipEntry
    extends Object
    implements Cloneable
    Extension that adds better handling of extra fields and provides access to the internal and external file attributes.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void erase()  
      String getComment()
      Returns the comment string for the entry, or null if none.
      long getCompressedSize()
      Returns the size of the compressed entry data, or -1 if not known.
      long getCrc()
      Returns the CRC-32 checksum of the uncompressed entry data, or -1 if not known.
      byte[] getData()  
      long getExternalAttributes()
      Retrieves the external file attributes.
      byte[] getExtra()
      Returns the extra field data for the entry, or null if none.
      long getHeaderOffset()  
      int getInternalAttributes()
      Retrieves the internal file attributes.
      byte[] getLocalFileDataExtra()
      Retrieves the extra data for the local file data.
      int getMethod()
      Returns the compression method of the entry, or -1 if not specified.
      String getName()
      Get the name of the entry.
      int getPlatform()
      Platform specification to put into the "version made by" part of the central file header.
      long getSize()
      Returns the uncompressed size of the entry data, or -1 if not known.
      long getTime()
      Returns the modification time of the entry, or -1 if not specified.
      int getUnixMode()
      Unix permission.
      int hashCode()
      Get the hashCode of the entry.
      boolean isDirectory()
      Is this entry a directory?
      void setComment​(String comment)
      Sets the optional comment string for the entry.
      void setCompressedSize​(long csize)
      Sets the size of the compressed entry data.
      void setCrc​(long crc)
      Sets the CRC-32 checksum of the uncompressed entry data.
      void setData​(byte[] bytes)  
      void setData​(byte[] bytes, long timestamp)  
      void setExternalAttributes​(long value)
      Sets the external file attributes.
      void setExtra​(byte[] extra)
      Sets the optional extra field data for the entry.
      void setHeaderOffset​(long headerOffset)  
      void setInternalAttributes​(int value)
      Sets the internal file attributes.
      void setMethod​(int method)
      Sets the compression method for the entry.
      protected void setName​(String name)
      Set the name of the entry.
      protected void setPlatform​(int platform)
      Set the platform (UNIX or FAT).
      void setSize​(long size)
      Sets the uncompressed size of the entry data.
      void setTime​(long time)
      Sets the modification time of the entry.
      void setUnixMode​(int mode)
      Sets Unix permissions in a way that is understood by Info-Zip's unzip command.
    • Constructor Detail

      • JBZipEntry

        protected JBZipEntry​(String name,
                             JBZipFile file)
        Creates a new zip entry with the specified name.
        Parameters:
        name - the name of the entry
        file -
        Since:
        1.1
      • JBZipEntry

        protected JBZipEntry​(JBZipFile file)
        Parameters:
        file -
        Since:
        1.9
    • Method Detail

      • getInternalAttributes

        public int getInternalAttributes()
        Retrieves the internal file attributes.
        Returns:
        the internal file attributes
        Since:
        1.1
      • setInternalAttributes

        public void setInternalAttributes​(int value)
        Sets the internal file attributes.
        Parameters:
        value - an int value
        Since:
        1.1
      • getExternalAttributes

        public long getExternalAttributes()
        Retrieves the external file attributes.
        Returns:
        the external file attributes
        Since:
        1.1
      • setExternalAttributes

        public void setExternalAttributes​(long value)
        Sets the external file attributes.
        Parameters:
        value - an long value
        Since:
        1.1
      • getHeaderOffset

        public long getHeaderOffset()
      • setHeaderOffset

        public void setHeaderOffset​(long headerOffset)
      • setUnixMode

        public void setUnixMode​(int mode)
        Sets Unix permissions in a way that is understood by Info-Zip's unzip command.
        Parameters:
        mode - an int value
        Since:
        Ant 1.5.2
      • getUnixMode

        public int getUnixMode()
        Unix permission.
        Returns:
        the unix permissions
        Since:
        Ant 1.6
      • getPlatform

        public int getPlatform()
        Platform specification to put into the "version made by" part of the central file header.
        Returns:
        0 (MS-DOS FAT) unless setUnixMode has been called, in which case 3 (Unix) will be returned.
        Since:
        Ant 1.5.2
      • setPlatform

        protected void setPlatform​(int platform)
        Set the platform (UNIX or FAT).
        Parameters:
        platform - an int value - 0 is FAT, 3 is UNIX
        Since:
        1.9
      • setExtra

        public void setExtra​(byte[] extra)
        Sets the optional extra field data for the entry.
        Parameters:
        extra - the extra field data bytes
        Throws:
        IllegalArgumentException - if the length of the specified extra field data is greater than 0xFFFF bytes
        See Also:
        getExtra()
      • getLocalFileDataExtra

        public byte[] getLocalFileDataExtra()
        Retrieves the extra data for the local file data.
        Returns:
        the extra data for local file
        Since:
        1.1
      • setTime

        public void setTime​(long time)
        Sets the modification time of the entry.
        Parameters:
        time - the entry modification time in number of milliseconds since the epoch
        See Also:
        getTime()
      • getTime

        public long getTime()
        Returns the modification time of the entry, or -1 if not specified.
        Returns:
        the modification time of the entry, or -1 if not specified
        See Also:
        setTime(long)
      • setSize

        public void setSize​(long size)
        Sets the uncompressed size of the entry data.
        Parameters:
        size - the uncompressed size in bytes
        Throws:
        IllegalArgumentException - if the specified size is less than 0 or greater than 0xFFFFFFFF bytes
        See Also:
        getSize()
      • getSize

        public long getSize()
        Returns the uncompressed size of the entry data, or -1 if not known.
        Returns:
        the uncompressed size of the entry data, or -1 if not known
        See Also:
        setSize(long)
      • getName

        public String getName()
        Get the name of the entry.
        Returns:
        the entry name
        Since:
        1.9
      • getCompressedSize

        public long getCompressedSize()
        Returns the size of the compressed entry data, or -1 if not known. In the case of a stored entry, the compressed size will be the same as the uncompressed size of the entry.
        Returns:
        the size of the compressed entry data, or -1 if not known
        See Also:
        setCompressedSize(long)
      • setCompressedSize

        public void setCompressedSize​(long csize)
        Sets the size of the compressed entry data.
        Parameters:
        csize - the compressed size to set to
        See Also:
        getCompressedSize()
      • setCrc

        public void setCrc​(long crc)
        Sets the CRC-32 checksum of the uncompressed entry data.
        Parameters:
        crc - the CRC-32 value
        Throws:
        IllegalArgumentException - if the specified CRC-32 value is less than 0 or greater than 0xFFFFFFFF
        See Also:
        getCrc()
      • getCrc

        public long getCrc()
        Returns the CRC-32 checksum of the uncompressed entry data, or -1 if not known.
        Returns:
        the CRC-32 checksum of the uncompressed entry data, or -1 if not known
        See Also:
        setCrc(long)
      • setMethod

        public void setMethod​(int method)
        Sets the compression method for the entry.
        Parameters:
        method - the compression method, either STORED or DEFLATED
        Throws:
        IllegalArgumentException - if the specified compression method is invalid
        See Also:
        getMethod()
      • getMethod

        public int getMethod()
        Returns the compression method of the entry, or -1 if not specified.
        Returns:
        the compression method of the entry, or -1 if not specified
        See Also:
        setMethod(int)
      • isDirectory

        public boolean isDirectory()
        Is this entry a directory?
        Returns:
        true if the entry is a directory
        Since:
        1.10
      • setName

        protected void setName​(String name)
        Set the name of the entry.
        Parameters:
        name - the name to use
      • hashCode

        public int hashCode()
        Get the hashCode of the entry. This uses the name as the hashcode.
        Overrides:
        hashCode in class Object
        Returns:
        a hashcode.
        Since:
        Ant 1.7
      • getExtra

        public byte[] getExtra()
        Returns the extra field data for the entry, or null if none.
        Returns:
        the extra field data for the entry, or null if none
        See Also:
        setExtra(byte[])
      • setComment

        public void setComment​(String comment)
        Sets the optional comment string for the entry.
        Parameters:
        comment - the comment string
        Throws:
        IllegalArgumentException - if the length of the specified comment string is greater than 0xFFFF bytes
        See Also:
        getComment()
      • getComment

        public String getComment()
        Returns the comment string for the entry, or null if none.
        Returns:
        the comment string for the entry, or null if none
        See Also:
        setComment(String)