Package org.apache.tomcat.util.scan
Class JarFileUrlJar
- java.lang.Object
-
- org.apache.tomcat.util.scan.JarFileUrlJar
-
- All Implemented Interfaces:
AutoCloseable,Jar
public class JarFileUrlJar extends Object implements Jar
Implementation ofJarthat is optimised for file based JAR URLs that refer directly to a JAR file (e.g URLs of the form jar:file: ... .jar!/ or file:... .jar).
-
-
Constructor Summary
Constructors Constructor Description JarFileUrlJar(URL url, boolean startsWithJar)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()Close any resources associated with this JAR.booleanentryExists(String name)Deprecated.booleanexists(String name)Determine if the given resource in present in the JAR.InputStreamgetEntryInputStream()Obtains the input stream for the current entry.StringgetEntryName()Obtains the name of the current entry.InputStreamgetInputStream(String name)Obtain anInputStreamfor a given entry in a JAR.URLgetJarFileURL()longgetLastModified(String name)Obtain the last modified time for the given resource in the JAR.ManifestgetManifest()Obtain the manifest for the JAR file.StringgetURL(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.
-
-
-
Constructor Detail
-
JarFileUrlJar
public JarFileUrlJar(URL url, boolean startsWithJar) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getJarFileURL
public URL getJarFileURL()
- Specified by:
getJarFileURLin interfaceJar- Returns:
- The URL for accessing the JAR file.
-
entryExists
@Deprecated public boolean entryExists(String name)
Deprecated.Description copied from interface:JarDetermines if a specific entry exists within the JAR.- Specified by:
entryExistsin interfaceJar- Parameters:
name- Entry to look for- Returns:
- Implementations will always return
false
-
getInputStream
public InputStream getInputStream(String name) throws IOException
Description 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:
IOException- if an I/O error occurs while processing the JAR file
-
getLastModified
public long getLastModified(String name) throws IOException
Description 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:
IOException- if an I/O error occurs while processing the JAR file
-
exists
public boolean exists(String name) throws IOException
Description copied from interface:JarDetermine if the given resource in present in the JAR.- Specified by:
existsin interfaceJar- Parameters:
name- Entry to look for- Returns:
trueif the entry is present in the JAR, otherwisefalse- Throws:
IOException- if an I/O error occurs while processing the JAR file
-
getURL
public String getURL(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.
-
close
public void close()
Description copied from interface:JarClose any resources associated with this JAR.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceJar
-
nextEntry
public void nextEntry()
Description copied from interface:JarMoves the internal pointer to the next entry in the JAR.
-
getEntryName
public String getEntryName()
Description copied from interface:JarObtains the name of the current entry.- Specified by:
getEntryNamein interfaceJar- Returns:
- The entry name
-
getEntryInputStream
public InputStream getEntryInputStream() throws IOException
Description copied from interface:JarObtains the input stream for the current entry.- Specified by:
getEntryInputStreamin interfaceJar- Returns:
- The input stream
- Throws:
IOException- If the stream cannot be obtained
-
getManifest
public Manifest getManifest() throws IOException
Description copied from interface:JarObtain the manifest for the JAR file.- Specified by:
getManifestin interfaceJar- Returns:
- The manifest for this JAR file.
- Throws:
IOException- If an I/O error occurs trying to obtain the manifest
-
reset
public void reset() throws IOExceptionDescription copied from interface:JarResets the internal pointer used to track JAR entries to the beginning of the JAR.- Specified by:
resetin interfaceJar- Throws:
IOException- If the pointer cannot be reset
-
-