Package patterntesting.runtime.util
Class ArchivEntry
- java.lang.Object
-
- patterntesting.runtime.util.ArchivEntry
-
public final class ArchivEntry extends java.lang.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. The facility to read (compressed) tar files (using org.apache.commons.compress.tar.*) were removed because we use it here only for zip and jar files.
Since 1.5 this class is now final because of performance reasons. If you need to derive it write a feature request.
- Since:
- 20.09.2007
- Version:
- $Revision: 1.26 $
- Author:
- oliver (ob@aosd.de)
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ArchivEntry(java.io.File file)
Instantiates a new archiv entry.ArchivEntry(java.lang.String scheme, java.io.File archive, java.lang.String entry)
Instantiates a new archiv entry.ArchivEntry(java.net.URI uri)
Instantiates a new archiv entry.ArchivEntry(java.net.URL url)
Instantiates a new archiv entry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.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.byte[]
getBytes()
Gets the bytes.java.lang.String
getEntry()
Gets the entry.java.io.File
getFileArchiv()
Gets the file archiv.long
getSize()
Gets the size.java.util.zip.ZipEntry
getZipEntry()
Gets the zip entry.java.util.zip.ZipFile
getZipFile()
Gets the zip file.boolean
hasEntry()
Checks for entry.int
hashCode()
Hash code.boolean
isFile()
Checks if is file.java.lang.String
toString()
To string.java.net.URI
toURI()
To uri.
-
-
-
Constructor Detail
-
ArchivEntry
protected ArchivEntry(java.io.File file)
Instantiates a new archiv entry.- Parameters:
file
- the file
-
ArchivEntry
public ArchivEntry(java.net.URI uri)
Instantiates a new archiv entry.- Parameters:
uri
- the uri
-
ArchivEntry
public ArchivEntry(java.net.URL url)
Instantiates a new archiv entry.- Parameters:
url
- the url
-
ArchivEntry
public ArchivEntry(java.lang.String scheme, java.io.File archive, java.lang.String entry) throws java.net.URISyntaxException
Instantiates a new archiv entry.- Parameters:
scheme
- the schemearchive
- the archiveentry
- the entry- Throws:
java.net.URISyntaxException
- the URI syntax exception
-
-
Method Detail
-
toURI
public java.net.URI toURI()
To uri.- Returns:
- the uRI
-
isFile
public boolean isFile()
Checks if is file.- Returns:
- true, if is file
-
getFileArchiv
public java.io.File getFileArchiv()
Gets the file archiv. The works of course only for JAR and ZIP files.- Returns:
- the file
-
getZipFile
public java.util.zip.ZipFile getZipFile() throws java.io.IOException
Gets the zip file.- Returns:
- the zip file
- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
getEntry
public java.lang.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 java.util.zip.ZipEntry getZipEntry()
Gets the zip entry.- Returns:
- the zip entry
-
getSize
public long getSize() throws java.io.IOException
Gets the size.- Returns:
- the size
- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
getBytes
public byte[] getBytes() throws java.io.IOException
Gets the bytes.- Returns:
- the bytes
- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
equals
public boolean equals(java.lang.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 classjava.lang.Object
- Parameters:
other
- the other- Returns:
- true if they have the same size and the same byte code.
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
Hash code.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hash code
- See Also:
Object.hashCode()
-
toString
public java.lang.String toString()
To string.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the string
- See Also:
Object.toString()
-
-