Top Description Fields Constructors Methods
org.apache.tools.ant.util

public Class LoaderUtils

extends Object
Class Inheritance
Imports
java.io.File, org.apache.tools.ant.BuildException, org.apache.tools.ant.launch.Locator

ClassLoader utility methods

Field Summary

Modifier and TypeField and Description
private static final FileUtils
FILE_UTILS

Utilities used for file operations

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if the class exists, false otherwise
classExists
(ClassLoader
the classloader to look it.
loader
,
String
the name of the class to look for.
className
)

Check if a classloader has a classname resource.

public static String

Returns:

the corresponding resource name.
classNameToResource
(String
the name of the class to convert.
className
)

Return the resource name of a class name.

public static File

Returns:

the file or jar with the class or null if we cannot determine the location.
getClassSource
(Class<?>
the class whose location is required.
c
)

Find the directory or jar file the class has been loaded from.

public static ClassLoader

Returns:

the ClassLoader instance being used as the context classloader on the current thread. Returns null on JDK 1.1
getContextClassLoader
()

JDK1.1 compatible access to set the context class loader.

public static File

Returns:

the file with the resource source or null if we cannot determine the location.
getResourceSource
(ClassLoader
the classloader to be consulted for the source
c
,
String
the resource whose location is required.
resource
)

Find the directory or a give resource has been loaded from.

public static boolean

Returns:

true if the get and set methods dealing with the context classloader are available.
isContextLoaderAvailable
()

Indicates if the context class loader methods are available

private static File

Returns:

the normalized source location.
normalizeSource
(File
the source location to be normalized.
source
)

Normalize a source location

public static void
setContextClassLoader(ClassLoader
the ClassLoader to be used as the context class loader on the current thread.
loader
)

Set the context classloader

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FILE_UTILSback to summary
private static final FileUtils FILE_UTILS

Utilities used for file operations

Constructor Detail

LoaderUtilsback to summary
public LoaderUtils()

Method Detail

classExistsback to summary
public static boolean classExists(ClassLoader loader, String className)

Check if a classloader has a classname resource.

Parameters
loader:ClassLoader

the classloader to look it.

className:String

the name of the class to look for.

Returns:boolean

true if the class exists, false otherwise

Since
Ant 1.7.0.
classNameToResourceback to summary
public static String classNameToResource(String className)

Return the resource name of a class name.

Parameters
className:String

the name of the class to convert.

Returns:String

the corresponding resource name.

Since
Ant 1.7.0.
getClassSourceback to summary
public static File getClassSource(Class<?> c)

Find the directory or jar file the class has been loaded from.

Parameters
c:Class<?>

the class whose location is required.

Returns:File

the file or jar with the class or null if we cannot determine the location.

Since
Ant 1.6
getContextClassLoaderback to summary
public static ClassLoader getContextClassLoader()

JDK1.1 compatible access to set the context class loader.

Returns:ClassLoader

the ClassLoader instance being used as the context classloader on the current thread. Returns null on JDK 1.1

getResourceSourceback to summary
public static File getResourceSource(ClassLoader c, String resource)

Find the directory or a give resource has been loaded from.

Parameters
c:ClassLoader

the classloader to be consulted for the source

resource:String

the resource whose location is required.

Returns:File

the file with the resource source or null if we cannot determine the location.

Since
Ant 1.6
isContextLoaderAvailableback to summary
public static boolean isContextLoaderAvailable()

Indicates if the context class loader methods are available

Returns:boolean

true if the get and set methods dealing with the context classloader are available.

normalizeSourceback to summary
private static File normalizeSource(File source)

Normalize a source location

Parameters
source:File

the source location to be normalized.

Returns:File

the normalized source location.

setContextClassLoaderback to summary
public static void setContextClassLoader(ClassLoader loader)

Set the context classloader

Parameters
loader:ClassLoader

the ClassLoader to be used as the context class loader on the current thread.