Class ArchivEntry

java.lang.Object
clazzfish.monitor.util.ArchivEntry

public final class ArchivEntry extends Object
Unfortunately we can't extends URI because this is a final class. So now it is more or less implemented as URI wrapper and is intended for the use with zip and jar files to describe an entry inside an archive.

Historically some parts of this class were developed for a log browser for Log4J. Next it was part of the PatternTesting project. The facility to read (compressed) tar files (using org.apache.commons.compress.tar.*) was removed because we use it here only for zip and jar files.

This class is final because of performance reasons. If you need to derive it write a feature request.

Author:
oliver (ob@aosd.de)
  • Constructor Details

    • ArchivEntry

      protected ArchivEntry(File file)
      Instantiates a new archiv entry.
      Parameters:
      file - the file
    • ArchivEntry

      public ArchivEntry(URI uri)
      Instantiates a new archiv entry.
      Parameters:
      uri - the uri
    • ArchivEntry

      public ArchivEntry(URL url)
      Instantiates a new archiv entry.
      Parameters:
      url - the url
    • ArchivEntry

      public ArchivEntry(String scheme, File archive, String entry) throws URISyntaxException
      Instantiates a new archiv entry.
      Parameters:
      scheme - the scheme
      archive - the archive
      entry - the entry
      Throws:
      URISyntaxException - the URI syntax exception
  • Method Details

    • toURI

      public URI toURI()
      To uri.
      Returns:
      the uRI
    • isFile

      public boolean isFile()
      Checks if is file.
      Returns:
      true, if is file
    • getFileArchiv

      public File getFileArchiv()
      Gets the file archiv. The works of course only for JAR and ZIP files.
      Returns:
      the file
    • getZipFile

      public ZipFile getZipFile() throws IOException
      Gets the zip file.
      Returns:
      the zip file
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • getEntry

      public String getEntry()
      Gets the entry. If no entry can be found an empty string is returned now. This behaviour has changed with 1.5.
      Returns:
      the entry
    • hasEntry

      public boolean hasEntry()
      Checks for entry.
      Returns:
      true, if successful
    • getZipEntry

      public ZipEntry getZipEntry()
      Gets the zip entry.
      Returns:
      the zip entry
    • getSize

      public long getSize() throws IOException
      Gets the size.
      Returns:
      the size
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • getBytes

      public byte[] getBytes() throws IOException
      Gets the bytes.
      Returns:
      the bytes
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • equals

      public boolean equals(Object other)
      If two entries with the same resource or class name have a different size or not the same byte code they are considered as not equal.
      Overrides:
      equals in class Object
      Parameters:
      other - the other
      Returns:
      true if they have the same size and the same byte code.
      See Also:
    • hashCode

      public int hashCode()
      Hash code.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
      See Also:
    • toString

      public String toString()
      To string.
      Overrides:
      toString in class Object
      Returns:
      the string
      See Also: