Class JarResource

All Implemented Interfaces:
AsyncResource, Resource, AutoCloseable

public class JarResource extends ZipResource

A Resource implementation that identifies resources by a URI of the form jar:file:/path/to/jar!/path/to/resource and looks up data in a jar file on the file system system.

A typical usage is:


 JarResource resource = new JarResource(URI.create("jar:file:/path/to/jar!/path/to/resource"));
 ...
 
Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • Constructor Details

    • JarResource

      public JarResource(URI uri) throws IllegalArgumentException

      Creates a jar resource with the specified URI.

      Parameters:
      uri - the resource URI
      Throws:
      IllegalArgumentException - if the specified URI does not designate a jar resource
    • JarResource

      public JarResource(URI uri, MediaTypeService mediaTypeService) throws IllegalArgumentException

      Creates a jar resource with the specified URI and media type service.

      Parameters:
      uri - the resource URI
      mediaTypeService - a media type service
      Throws:
      IllegalArgumentException - if the specified URI does not designate a jar resource
  • Method Details

    • checkUri

      public static URI checkUri(URI uri) throws IllegalArgumentException

      Checks that the specified URI is a jar resource URI.

      Parameters:
      uri - the uri to check
      Returns:
      the uri if it is a jar resource URI
      Throws:
      IllegalArgumentException - if the specified URI does not designate a jar resource
    • resolve

      public Resource resolve(Path path) throws ResourceException
      Description copied from interface: Resource

      Resolves the specified URI against the resource URI as defined by Path.resolve(Path).

      Specified by:
      resolve in interface Resource
      Overrides:
      resolve in class ZipResource
      Parameters:
      path - the path to resolve
      Returns:
      a new resource resulting from the resolution of the specified path against the resource
      Throws:
      ResourceException - if there was an error resolving the resource