Class JarFileResource

All Implemented Interfaces:
Closeable, AutoCloseable, ResourceFactory

public class JarFileResource extends JarResource
  • Field Details

    • LOG

      private static final Logger LOG
    • _jarFile

      private JarFile _jarFile
    • _file

      private File _file
    • _list

      private String[] _list
    • _entry

      private JarEntry _entry
    • _directory

      private boolean _directory
    • _jarUrl

      private String _jarUrl
    • _path

      private String _path
    • _exists

      private boolean _exists
  • Constructor Details

    • JarFileResource

      protected JarFileResource(URL url)
    • JarFileResource

      protected JarFileResource(URL url, boolean useCaches)
  • Method Details

    • close

      public void close()
      Description copied from class: URLResource
      Release any resources held by the resource.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class JarResource
    • checkConnection

      protected boolean checkConnection()
      Overrides:
      checkConnection in class JarResource
    • newConnection

      protected void newConnection() throws IOException
      Overrides:
      newConnection in class JarResource
      Throws:
      IOException - Sub-classes of JarResource may throw an IOException (or subclass)
    • exists

      public boolean exists()
      Returns true if the represented resource exists.
      Overrides:
      exists in class JarResource
      Returns:
      true if the represented resource exists.
    • isDirectory

      public boolean isDirectory()
      Returns true if the represented resource is a container/directory. If the resource is not a file, resources ending with "/" are considered directories.
      Overrides:
      isDirectory in class URLResource
      Returns:
      true if the represented resource is a container/directory. if the resource is not a file, resources ending with "/" are considered directories.
    • lastModified

      public long lastModified()
      Returns the last modified time
      Overrides:
      lastModified in class URLResource
      Returns:
      the last modified time as milliseconds since unix epoch
    • list

      public String[] list()
      Description copied from class: URLResource
      Returns a list of resource names contained in the given resource
      Overrides:
      list in class URLResource
      Returns:
      a list of resource names contained in the given resource, or null. Note: The resource names are not URL encoded.
    • listEntries

      private List<String> listEntries()
    • length

      public long length()
      Return the length of the resource
      Overrides:
      length in class URLResource
      Returns:
      the length of the resource
    • getNonCachingResource

      public static Resource getNonCachingResource(Resource resource)
      Take a Resource that possibly might use URLConnection caching and turn it into one that doesn't.
      Parameters:
      resource - the JarFileResource to obtain without URLConnection caching.
      Returns:
      the non-caching resource
    • isContainedIn

      public boolean isContainedIn(Resource resource) throws MalformedURLException
      Check if this jar:file: resource is contained in the named resource. Eg jar:file:///a/b/c/foo.jar!/x.html isContainedIn file:///a/b/c/foo.jar
      Overrides:
      isContainedIn in class URLResource
      Parameters:
      resource - the resource to test for
      Returns:
      true if resource is contained in the named resource
      Throws:
      MalformedURLException - if unable to process is contained due to invalid URL format
    • getJarFile

      public File getJarFile()