Package org.apache.tomcat.util.scan
Class ReferenceCountedJar
java.lang.Object
org.apache.tomcat.util.scan.ReferenceCountedJar
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close any resources associated with this JAR.boolean
Determine if the given resource in present in the JAR.Obtains the input stream for the current entry.Obtains the name of the current entry.getInputStream
(String name) Obtain anInputStream
for a given entry in a JAR.long
getLastModified
(String name) Obtain the last modified time for the given resource in the JAR.Obtain the manifest for the JAR file.Obtain, in String form, the URL for an entry in this JAR.void
Moves the internal pointer to the next entry in the JAR.void
reset()
Resets the internal pointer used to track JAR entries to the beginning of the JAR.
-
Constructor Details
-
ReferenceCountedJar
- Throws:
IOException
-
-
Method Details
-
close
public void close()Description copied from interface:Jar
Close any resources associated with this JAR.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceJar
-
getJarFileURL
- Specified by:
getJarFileURL
in interfaceJar
- Returns:
- The URL for accessing the JAR file.
-
getInputStream
Description copied from interface:Jar
Obtain anInputStream
for a given entry in a JAR. The caller is responsible for closing the stream.- Specified by:
getInputStream
in interfaceJar
- Parameters:
name
- Entry to obtain anInputStream
for- Returns:
- An
InputStream
for 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
Description copied from interface:Jar
Obtain the last modified time for the given resource in the JAR.- Specified by:
getLastModified
in 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
Description copied from interface:Jar
Determine if the given resource in present in the JAR.- Specified by:
exists
in interfaceJar
- Parameters:
name
- Entry to look for- Returns:
true
if the entry is present in the JAR, otherwisefalse
- Throws:
IOException
- if an I/O error occurs while processing the JAR file
-
nextEntry
-
getEntryName
Description copied from interface:Jar
Obtains the name of the current entry.- Specified by:
getEntryName
in interfaceJar
- Returns:
- The entry name
-
getEntryInputStream
Description copied from interface:Jar
Obtains the input stream for the current entry.- Specified by:
getEntryInputStream
in interfaceJar
- Returns:
- The input stream
- Throws:
IOException
- If the stream cannot be obtained
-
getURL
Description copied from interface:Jar
Obtain, 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 theJarFactory
to ensure resources are accessed correctly. -
getManifest
Description copied from interface:Jar
Obtain the manifest for the JAR file.- Specified by:
getManifest
in interfaceJar
- Returns:
- The manifest for this JAR file.
- Throws:
IOException
- If an I/O error occurs trying to obtain the manifest
-
reset
Description copied from interface:Jar
Resets the internal pointer used to track JAR entries to the beginning of the JAR.- Specified by:
reset
in interfaceJar
- Throws:
IOException
- If the pointer cannot be reset
-