Package org.apache.tomcat.util.scan
Class AbstractInputStreamJar
- java.lang.Object
-
- org.apache.tomcat.util.scan.AbstractInputStreamJar
-
- All Implemented Interfaces:
java.lang.AutoCloseable,Jar
- Direct Known Subclasses:
JarFileUrlNestedJar,UrlJar
public abstract class AbstractInputStreamJar extends java.lang.Object implements Jar
Base implementation of Jar for implementations that use a JarInputStream to access the JAR file.
-
-
Constructor Summary
Constructors Constructor Description AbstractInputStreamJar(java.net.URL jarFileUrl)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcloseStream()protected abstract NonClosingJarInputStreamcreateJarInputStream()booleanexists(java.lang.String name)Determine if the given resource in present in the JAR.java.io.InputStreamgetEntryInputStream()Obtains the input stream for the current entry.java.lang.StringgetEntryName()Obtains the name of the current entry.java.io.InputStreamgetInputStream(java.lang.String name)Obtain anInputStreamfor a given entry in a JAR.java.net.URLgetJarFileURL()longgetLastModified(java.lang.String name)Obtain the last modified time for the given resource in the JAR.java.util.jar.ManifestgetManifest()Obtain the manifest for the JAR file.java.lang.StringgetURL(java.lang.String entry)Obtain, in String form, the URL for an entry in this JAR.voidnextEntry()Moves the internal pointer to the next entry in the JAR.voidreset()Resets the internal pointer used to track JAR entries to the beginning of the JAR.
-
-
-
Method Detail
-
getJarFileURL
public java.net.URL getJarFileURL()
- Specified by:
getJarFileURLin interfaceJar- Returns:
- The URL for accessing the JAR file.
-
nextEntry
public void nextEntry()
Description copied from interface:JarMoves the internal pointer to the next entry in the JAR.
-
getEntryName
public java.lang.String getEntryName()
Description copied from interface:JarObtains the name of the current entry.- Specified by:
getEntryNamein interfaceJar- Returns:
- The entry name
-
getEntryInputStream
public java.io.InputStream getEntryInputStream() throws java.io.IOExceptionDescription copied from interface:JarObtains the input stream for the current entry.- Specified by:
getEntryInputStreamin interfaceJar- Returns:
- The input stream
- Throws:
java.io.IOException- If the stream cannot be obtained
-
getInputStream
public java.io.InputStream getInputStream(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:JarObtain anInputStreamfor a given entry in a JAR. The caller is responsible for closing the stream.- Specified by:
getInputStreamin interfaceJar- Parameters:
name- Entry to obtain anInputStreamfor- Returns:
- An
InputStreamfor the specified entry or null if the entry does not exist - Throws:
java.io.IOException- if an I/O error occurs while processing the JAR file
-
getLastModified
public long getLastModified(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:JarObtain the last modified time for the given resource in the JAR.- Specified by:
getLastModifiedin interfaceJar- Parameters:
name- Entry to obtain the modification time for- Returns:
- The time (in the same format as
System.currentTimeMillis()that the resource was last modified. Returns -1 if the entry does not exist - Throws:
java.io.IOException- if an I/O error occurs while processing the JAR file
-
exists
public boolean exists(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:JarDetermine if the given resource in present in the JAR.
-
getURL
public java.lang.String getURL(java.lang.String entry)
Description copied from interface:JarObtain, in String form, the URL for an entry in this JAR. Note that for JARs nested in WAR files, the Tomcat specific war:file:... form will not be used, rather the jar:jar:file:... form (that the JRE does not understand will be used). Note that this means that any code using these URLs will need to understand the jar:jar:file:... form and use theJarFactoryto ensure resources are accessed correctly.
-
getManifest
public java.util.jar.Manifest getManifest() throws java.io.IOExceptionDescription copied from interface:JarObtain the manifest for the JAR file.- Specified by:
getManifestin interfaceJar- Returns:
- The manifest for this JAR file.
- Throws:
java.io.IOException- If an I/O error occurs trying to obtain the manifest
-
reset
public void reset() throws java.io.IOExceptionDescription copied from interface:JarResets the internal pointer used to track JAR entries to the beginning of the JAR.
-
closeStream
protected void closeStream()
-
createJarInputStream
protected abstract NonClosingJarInputStream createJarInputStream() throws java.io.IOException
- Throws:
java.io.IOException
-
-