Browse Source

helper methods for class resources

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@481960 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
ac4255606a
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      src/main/org/apache/tools/ant/util/LoaderUtils.java

+ 21
- 0
src/main/org/apache/tools/ant/util/LoaderUtils.java View File

@@ -114,5 +114,26 @@ public class LoaderUtils {
}
return normalizeSource(Locator.getResourceSource(c, resource));
}

/**
* Return the resource name of a class name.
* @param className the name of the class to convert.
* @return the corresponding resource name.
* @since Ant 1.7.0.
*/
public static String classNameToResource(String className) {
return className.replace('.', '/') + ".class";
}

/**
* Check if a classloader has a classname resource.
* @param loader the classloader to look it.
* @param className the name of the class to look for.
* @return true if the classexists, false otherwise
* @since Ant 1.7.0.
*/
public static boolean classExists(ClassLoader loader, String className) {
return loader.getResource(classNameToResource(className)) != null;
}
}


Loading…
Cancel
Save