コード例 #1
0
  @Nullable
  private Loader getLoader(final URL url, int index) throws IOException {
    String path;

    if (myAcceptUnescapedUrls) {
      path = url.getFile();
    } else {
      try {
        path = url.toURI().getSchemeSpecificPart();
      } catch (URISyntaxException thisShouldNotHappen) {
        //noinspection CallToPrintStackTrace
        thisShouldNotHappen.printStackTrace();
        path = url.getFile();
      }
    }

    Loader loader = null;
    if (path != null && URLUtil.FILE_PROTOCOL.equals(url.getProtocol())) {
      File file = new File(path);
      if (file.isDirectory()) {
        loader = new FileLoader(url, index);
      } else if (file.isFile()) {
        loader = new JarLoader(url, myCanLockJars, index);
        if (myPreloadJarContents) {
          ((JarLoader) loader).preloadClasses();
        }
      }
    }

    if (loader != null && myCanUseCache) {
      try {
        loader.buildCache(myCache);
      } catch (Throwable e) {
        // TODO: log can't create loader
      }
    }

    return loader;
  }
コード例 #2
0
  @Nullable
  private Loader getLoader(final URL url, int index) throws IOException {
    String s;
    if (myAcceptUnescapedUrls) {
      s = url.getFile();
    } else {
      try {
        s = url.toURI().getSchemeSpecificPart();
      } catch (URISyntaxException thisShouldNotHappen) {
        thisShouldNotHappen.printStackTrace();
        s = url.getFile();
      }
    }

    Loader loader = null;
    if (s != null && new File(s).isDirectory()) {
      if (FILE_PROTOCOL.equals(url.getProtocol())) {
        loader = new FileLoader(url, index);
      }
    } else {
      JarLoader jarLoader = new JarLoader(url, myCanLockJars, index);
      if (myPreloadJarContents) {
        jarLoader.preLoadClasses();
      }
      loader = jarLoader;
    }

    if (loader != null && myCanUseCache) {
      try {
        loader.buildCache(myCache);
      } catch (Throwable e) {
        // TODO: log can't create loader
      }
    }

    return loader;
  }