org.apache.tools.ant.util
Class LoaderUtils
java.lang.Objectorg.apache.tools.ant.util.LoaderUtils
public class LoaderUtils
extends java.lang.Object
ClassLoader utility methods
static boolean | classExists(ClassLoader loader, String className)- Check if a classloader has a classname resource.
|
static String | classNameToResource(String className)- Return the resource name of a class name.
|
static File | getClassSource(Class c)- Find the directory or jar file the class has been loaded from.
|
static ClassLoader | getContextClassLoader()- JDK1.1 compatible access to set the context class loader.
|
static File | getResourceSource(ClassLoader c, String resource)- Find the directory or a give resource has been loaded from.
|
static boolean | isContextLoaderAvailable()- Indicates if the context class loader methods are available
|
static void | setContextClassLoader(ClassLoader loader)- Set the context classloader
|
classExists
public static boolean classExists(ClassLoader loader,
String className) Check if a classloader has a classname resource.
loader - the classloader to look it.className - the name of the class to look for.
- true if the classexists, false otherwise
classNameToResource
public static String classNameToResource(String className)
Return the resource name of a class name.
className - the name of the class to convert.
- the corresponding resource name.
getClassSource
public static File getClassSource(Class c)
Find the directory or jar file the class has been loaded from.
c - the class whose location is required.
- the file or jar with the class or null if we cannot
determine the location.
getContextClassLoader
public static ClassLoader getContextClassLoader()
JDK1.1 compatible access to set the context class loader.
- the ClassLoader instance being used as the context
classloader on the current thread. Returns null on JDK 1.1
getResourceSource
public static File getResourceSource(ClassLoader c,
String resource) Find the directory or a give resource has been loaded from.
c - the classloader to be consulted for the sourceresource - the resource whose location is required.
- the file with the resource source or null if
we cannot determine the location.
isContextLoaderAvailable
public static boolean isContextLoaderAvailable()
Indicates if the context class loader methods are available
- true if the get and set methods dealing with the context
classloader are available.
setContextClassLoader
public static void setContextClassLoader(ClassLoader loader)
Set the context classloader
loader - the ClassLoader to be used as the context class loader
on the current thread.