ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r481960 - /ant/core/trunk/src/main/org/apache/tools/ant/util/LoaderUtils.java
Date Sun, 03 Dec 2006 22:46:51 GMT
Author: peterreilly
Date: Sun Dec  3 14:46:48 2006
New Revision: 481960

URL: http://svn.apache.org/viewvc?view=rev&rev=481960
Log:
helper methods for class resources

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/util/LoaderUtils.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/LoaderUtils.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/LoaderUtils.java?view=diff&rev=481960&r1=481959&r2=481960
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/LoaderUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/LoaderUtils.java Sun Dec  3 14:46:48
2006
@@ -114,5 +114,26 @@
         }
         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;
+    }
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message