public static Resource create(URI uri, URIResourceFactory factory)
    throws URISyntaxException {
    """
	Factory method.
	
	@param uri the uri to the jar... note that it can either be jar: or a plain uri to the
	jar (ex: file://tmp/foo.jar and jar:file://tmp/foo.jar!/ are both valid and pointing to the
	same resource!)
    """
    String path = "/";
    
    // case when the URI is already a jar uri
    if("jar".equals(uri.getScheme()))
    {
      String schemeSpecificPart = uri.getSchemeSpecificPart();

      if(schemeSpecificPart == null)
        throw new URISyntaxException(uri.toString(), "no scheme specific part found...");

      int idx = schemeSpecificPart.indexOf("!/");
      if(idx == -1)
        throw new URISyntaxException(uri.toString(), "couldn't find !/");

      uri = new URI(schemeSpecificPart.substring(0, idx));
      path = schemeSpecificPart.substring(idx + 1);
    }

    // case when the URI points directly to the jar resource
    try
    {
      ResourceProvider provider =
        new JarResourceProvider(factory.createResource(uri));

      return provider.createResource("/").createRelative(path);
    }
    catch(UnsupportedURIException e)
    {
      URISyntaxException ex = new URISyntaxException(uri.toString(), "cannot create resource");
      ex.initCause(e);
      throw ex;
    }
  }
public static Resource create(URI uri, URIResourceFactory factory)
    throws URISyntaxException
  {
    String path = "/";
    
    // case when the URI is already a jar uri
    if("jar".equals(uri.getScheme()))
    {
      String schemeSpecificPart = uri.getSchemeSpecificPart();

      if(schemeSpecificPart == null)
        throw new URISyntaxException(uri.toString(), "no scheme specific part found...");

      int idx = schemeSpecificPart.indexOf("!/");
      if(idx == -1)
        throw new URISyntaxException(uri.toString(), "couldn't find !/");

      uri = new URI(schemeSpecificPart.substring(0, idx));
      path = schemeSpecificPart.substring(idx + 1);
    }

    // case when the URI points directly to the jar resource
    try
    {
      ResourceProvider provider =
        new JarResourceProvider(factory.createResource(uri));

      return provider.createResource("/").createRelative(path);
    }
    catch(UnsupportedURIException e)
    {
      URISyntaxException ex = new URISyntaxException(uri.toString(), "cannot create resource");
      ex.initCause(e);
      throw ex;
    }
  }
public static Resource create ( URI uri , URIResourceFactory factory ) throws URISyntaxException { String path = "/" ; // case when the URI is already a jar uri if ( "jar" . equals ( uri . getScheme ( ) ) ) { String schemeSpecificPart = uri . getSchemeSpecificPart ( ) ; if ( schemeSpecificPart == null ) throw new URISyntaxException ( uri . toString ( ) , "no scheme specific part found..." ) ; int idx = schemeSpecificPart . indexOf ( "!/" ) ; if ( idx == - 1 ) throw new URISyntaxException ( uri . toString ( ) , "couldn't find !/" ) ; uri = new URI ( schemeSpecificPart . substring ( 0 , idx ) ) ; path = schemeSpecificPart . substring ( idx + 1 ) ; } // case when the URI points directly to the jar resource try { ResourceProvider provider = new JarResourceProvider ( factory . createResource ( uri ) ) ; return provider . createResource ( "/" ) . createRelative ( path ) ; } catch ( UnsupportedURIException e ) { URISyntaxException ex = new URISyntaxException ( uri . toString ( ) , "cannot create resource" ) ; ex . initCause ( e ) ; throw ex ; } }
Factory method.

@param uri the uri to the jar... note that it can either be jar: or a plain uri to the
jar (ex: file://tmp/foo.jar and jar:file://tmp/foo.jar!/ are both valid and pointing to the
same resource!)
Factory method .