Beispiel #1
0
    private boolean next() {
      if (myRes != null) return true;

      long started = startTiming();
      try {
        Loader loader;
        if (myLoaders != null) {
          while (myIndex < myLoaders.size()) {
            loader = myLoaders.get(myIndex++);
            if (!myCache.loaderHasName(myName, loader)) {
              myRes = null;
              continue;
            }
            myRes = loader.getResource(myName, myCheck);
            if (myRes != null) return true;
          }
        } else {
          while ((loader = getLoader(myIndex++)) != null) {
            if (!myCache.loaderHasName(myName, loader)) continue;
            myRes = loader.getResource(myName, myCheck);
            if (myRes != null) return true;
          }
        }
      } finally {
        logTiming(ClassPath.this, started, myName);
      }

      return false;
    }
    private boolean next() {
      if (myRes != null) return true;
      long started = myDebugTime ? System.nanoTime() : 0;
      Loader loader;
      try {
        if (myLoaders != null) {
          while (myIndex < myLoaders.size()) {
            loader = myLoaders.get(myIndex++);
            if (!myCache.loaderHasName(myName, loader)) {
              myRes = null;
              continue;
            }
            myRes = loader.getResource(myName, myCheck);
            if (myRes != null) return true;
          }
        } else {
          while ((loader = getLoader(myIndex++)) != null) {
            if (!myCache.loaderHasName(myName, loader)) continue;
            myRes = loader.getResource(myName, myCheck);
            if (myRes != null) return true;
          }
        }
      } finally {
        if (myDebugTime) reportTime(started, myName);
      }

      return false;
    }
Beispiel #3
0
  @Nullable
  public Resource getResource(String s, boolean flag) {
    final long started = startTiming();
    try {
      int i;
      if (myCanUseCache) {
        Resource prevResource =
            myCache.iterateLoaders(s, flag ? ourCheckedIterator : ourUncheckedIterator, s, this);
        if (prevResource != null) return prevResource;

        synchronized (myUrls) {
          if (myUrls.isEmpty()) return null;
        }

        i = myLoaders.size();
      } else {
        i = 0;
      }

      Loader loader;
      while ((loader = getLoader(i++)) != null) {
        if (myCanUseCache) {
          if (!myCache.loaderHasName(s, loader)) continue;
        }
        Resource resource = loader.getResource(s, flag);
        if (resource != null) {
          return resource;
        }
      }
    } finally {
      logTiming(this, started, s);
    }

    return null;
  }
  @Nullable
  public Resource getResource(String s, boolean flag) {
    final long started = myDebugTime ? System.nanoTime() : 0;

    try {
      int i;
      if (myCanUseCache) {
        Resource prevResource =
            myCache.iterateLoaders(s, flag ? checkedIterator : uncheckedIterator, s, this);
        if (prevResource != null) return prevResource;

        synchronized (myUrls) {
          if (myUrls.isEmpty()) return null;
        }

        i = myLoaders.size();
      } else {
        i = 0;
      }

      for (Loader loader; (loader = getLoader(i)) != null; i++) {
        if (myCanUseCache) {
          if (!myCache.loaderHasName(s, loader)) continue;
        }
        Resource resource = loader.getResource(s, flag);
        if (resource != null) {
          return resource;
        }
      }

      return null;
    } finally {
      if (myDebugTime) reportTime(started, s);
    }
  }
Beispiel #5
0
 @Override
 Resource process(Loader loader, String s, ClassPath classPath) {
   if (!classPath.myCache.loaderHasName(s, loader)) return null;
   final Resource resource = loader.getResource(s, myFlag);
   if (resource != null) {
     printOrder(loader, s, resource);
     return resource;
   }
   return null;
 }
 /**
  * Finds the first Resource on the URL search path which has the specified name. Returns null if
  * no Resource could be found.
  *
  * @param name the name of the Resource
  * @param check whether to perform a security check
  * @return the Resource, or null if not found
  */
 public Resource getResource(String name, boolean check) {
   Loader loader;
   for (int i = 0; (loader = getLoader(i)) != null; i++) {
     Resource res = loader.getResource(name, check);
     if (res != null) {
       return res;
     }
   }
   return null;
 }