/* (non-Javadoc)
   * @see edu.umd.cs.findbugs.classfile.ICodeBase#lookupResource(java.lang.String)
   */
  public ICodeBaseEntry lookupResource(String resourceName) {

    // Translate resource name, in case a resource name
    // has been overridden and the resource is being accessed
    // using the overridden name.
    resourceName = translateResourceName(resourceName);
    if (!entries.contains(resourceName)) {
      return null;
    }

    try {
      ZipInputStreamCodeBaseEntry z = map.get(resourceName);
      if (z != null) {
        return z;
      }
      ZipInputStream zis = new ZipInputStream(new FileInputStream(file));
      try {
        ZipEntry ze;

        boolean found = false;
        int countDown = 20;
        while ((ze = zis.getNextEntry()) != null && countDown >= 0) {
          if (ze.getName().equals(resourceName)) {
            found = true;
          }
          if (found) {
            countDown--;
            if (map.containsKey(ze.getName())) {
              continue;
            }
            z = build(zis, ze);
            map.put(ze.getName(), z);
          }
          zis.closeEntry();
        }
      } finally {
        zis.close();
      }
      z = map.get(resourceName);
      if (z == null) {
        throw new AssertionError("Could not find " + resourceName);
      }
      return z;
    } catch (IOException e) {
      return null;
    }
  }