org.apache.tomcat.util.scan

## Class AbstractInputStreamJar

- java.lang.Object
- - org.apache.tomcat.util.scan.AbstractInputStreamJar

- All Implemented Interfaces:
    AutoCloseable, Jar
  Direct Known Subclasses:
    JarFileUrlNestedJar, UrlJar

      public abstract class AbstractInputStreamJar
      extends Object
      implements Jar

  Base implementation of Jar for implementations that use a JarInputStream to access the JAR file.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractInputStreamJar(URL jarFileUrl)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `closeStream()`
    `protected abstract NonClosingJarInputStream` | `createJarInputStream()`
    `boolean` | `entryExists(String name)` Deprecated.
    `boolean` | `exists(String name)` Determine if the given resource in present in the JAR.
    `InputStream` | `getEntryInputStream()` Obtains the input stream for the current entry.
    `String` | `getEntryName()` Obtains the name of the current entry.
    `InputStream` | `getInputStream(String name)` Obtain an `InputStream` for a given entry in a JAR.
    `URL` | `getJarFileURL()`
    `long` | `getLastModified(String name)` Obtain the last modified time for the given resource in the JAR.
    `Manifest` | `getManifest()` Obtain the manifest for the JAR file.
    `String` | `getURL(String entry)` Obtain, in String form, the URL for an entry in this JAR.
    `void` | `nextEntry()` 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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.tomcat.Jar

      `close`

- - ### Constructor Detail

    - #### AbstractInputStreamJar

          public AbstractInputStreamJar(URL jarFileUrl)

  - ### Method Detail

    - #### getJarFileURL

          public URL getJarFileURL()

      Specified by:
        `getJarFileURL` in interface `Jar`
      Returns:
        The URL for accessing the JAR file.

    - #### nextEntry

          public void nextEntry()

      Description copied from interface: `Jar`
      Moves the internal pointer to the next entry in the JAR.
      Specified by:
        `nextEntry` in interface `Jar`

    - #### getEntryName

          public String getEntryName()

      Description copied from interface: `Jar`
      Obtains the name of the current entry.
      Specified by:
        `getEntryName` in interface `Jar`
      Returns:
        The entry name

    - #### getEntryInputStream

          public InputStream getEntryInputStream()
                                          throws IOException

      Description copied from interface: `Jar`
      Obtains the input stream for the current entry.
      Specified by:
        `getEntryInputStream` in interface `Jar`
      Returns:
        The input stream
      Throws:
        `IOException` - If the stream cannot be obtained

    - #### entryExists

          @Deprecated
          public boolean entryExists(String name)
                              throws IOException

      Deprecated.
      Description copied from interface: `Jar`
      Determines if a specific entry exists within the JAR.
      Specified by:
        `entryExists` in interface `Jar`
      Parameters:
        `name` - Entry to look for
      Returns:
        Implementations will always return `false`
      Throws:
        `IOException` - if an I/O error occurs while processing the JAR file entries

    - #### getInputStream

          public InputStream getInputStream(String name)
                                     throws IOException

      Description copied from interface: `Jar`
      Obtain an `InputStream` for a given entry in a JAR. The caller is responsible for closing the stream.
      Specified by:
        `getInputStream` in interface `Jar`
      Parameters:
        `name` - Entry to obtain an `InputStream` 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

          public long getLastModified(String name)
                               throws IOException

      Description copied from interface: `Jar`
      Obtain the last modified time for the given resource in the JAR.
      Specified by:
        `getLastModified` in interface `Jar`
      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: `Jar`
      Determine if the given resource in present in the JAR.
      Specified by:
        `exists` in interface `Jar`
      Parameters:
        `name` - Entry to look for
      Returns:
        `true` if the entry is present in the JAR, otherwise `false`
      Throws:
        `IOException` - if an I/O error occurs while processing the JAR file

    - #### getURL

          public String getURL(String entry)

      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 the `JarFactory` to ensure resources are accessed correctly.
      Specified by:
        `getURL` in interface `Jar`
      Parameters:
        `entry` - The entry to generate the URL for
      Returns:
        a URL for the specified entry in the JAR

    - #### getManifest

          public Manifest getManifest()
                               throws IOException

      Description copied from interface: `Jar`
      Obtain the manifest for the JAR file.
      Specified by:
        `getManifest` in interface `Jar`
      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 IOException

      Description copied from interface: `Jar`
      Resets the internal pointer used to track JAR entries to the beginning of the JAR.
      Specified by:
        `reset` in interface `Jar`
      Throws:
        `IOException` - If the pointer cannot be reset

    - #### closeStream

          protected void closeStream()

    - #### createJarInputStream

          protected abstract NonClosingJarInputStream createJarInputStream()
                                                                    throws IOException

      Throws:
        `IOException`

Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.