com.anthonyeden.lib.util
Class ClassUtilities

java.lang.Object
  extended bycom.anthonyeden.lib.util.ClassUtilities

public class ClassUtilities
extends java.lang.Object

Useful class management utilities.

Author:
Anthony Eden

Method Summary
protected static void addClassesAndInterfaces(java.lang.Class c, java.util.List classes)
          Add all super classes and interfaces of the given class to the given List.
static java.util.List getAllClassesAndInterfaces(java.lang.Class startClass)
          Find all super classes and implemented interfaces for the given class.
static java.net.URL getResource(java.lang.String name)
          Load the specified resource.
static java.net.URL getResource(java.lang.String name, java.lang.Class requestor)
          Load the specified resource.
static java.net.URL getResource(java.lang.String name, java.lang.Object requestor)
          Load the specified resource.
static java.io.InputStream getResourceAsStream(java.lang.String name)
          Load the specified resource stream.
static java.io.InputStream getResourceAsStream(java.lang.String name, java.lang.Class requestor)
          Load the specified resource stream.
static java.io.InputStream getResourceAsStream(java.lang.String name, java.lang.Object requestor)
          Load the specified resource stream.
static java.lang.Class loadClass(java.lang.String className)
          Load the specified class name.
static java.lang.Class loadClass(java.lang.String className, java.lang.Class requestor)
          Load the specified class name.
static java.lang.Class loadClass(java.lang.String className, java.lang.Object requestor)
          Load the specified class name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadClass

public static java.lang.Class loadClass(java.lang.String className)
                                 throws java.lang.ClassNotFoundException
Load the specified class name. This method will first attempt to load the class using the context class loader. If that fails due to a ClassNotFoundException or a SecurityException then the ClassUtilities class loader is used.

Parameters:
className - The class name
Returns:
The Class
Throws:
java.lang.ClassNotFoundException

loadClass

public static java.lang.Class loadClass(java.lang.String className,
                                        java.lang.Object requestor)
                                 throws java.lang.ClassNotFoundException
Load the specified class name. This method will first attempt to load the class using the context class loader. If that fails due to a ClassNotFoundException or a SecurityException then the requestor's class loader is used. If the requestor object is null then the ClassUtilities class loader is used.

Parameters:
className - The class name
requestor - The object requesting the class or null
Returns:
The Class
Throws:
java.lang.ClassNotFoundException

loadClass

public static java.lang.Class loadClass(java.lang.String className,
                                        java.lang.Class requestor)
                                 throws java.lang.ClassNotFoundException
Load the specified class name. This method will first attempt to load the class using the context class loader. If that fails due to a ClassNotFoundException or a SecurityException then the requestor's class loader is used. If the requestor object is null then the ClassUtilities class loader is used.

Parameters:
className - The class name
requestor - The class of the object requesting the class or null
Returns:
The Class
Throws:
java.lang.ClassNotFoundException

getResource

public static java.net.URL getResource(java.lang.String name)
Load the specified resource. This method will first attempt to load the class using the context class loader. If that fails due to a ClassNotFoundException or a SecurityException then the ClassUtilities class loader is used.

Parameters:
name - The resource name
Returns:
The resource URL or null

getResource

public static java.net.URL getResource(java.lang.String name,
                                       java.lang.Object requestor)
Load the specified resource. This method will first attempt to load the class using the context class loader. If that fails due to a ClassNotFoundException or a SecurityException then the requestor's class loader is used. If the requestor object is null then the ClassUtilities class loader is used.

Parameters:
name - The resource name
requestor - The object requesting the resource or null
Returns:
The resource URL or null

getResource

public static java.net.URL getResource(java.lang.String name,
                                       java.lang.Class requestor)
Load the specified resource. This method will first attempt to load the class using the context class loader. If that fails due to a ClassNotFoundException or a SecurityException then the requestor's class loader is used. If the requestor object is null then the ClassUtilities class loader is used.

Parameters:
name - The resource name
requestor - The class of the object requesting the resource or null
Returns:
The resource URL or null

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String name)
Load the specified resource stream. This method will first attempt to load the class using the context class loader. If that fails due to a ClassNotFoundException or a SecurityException then ClassUtilities class loader is used.

Parameters:
name - The resource name
Returns:
The resource stream or null

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String name,
                                                      java.lang.Object requestor)
Load the specified resource stream. This method will first attempt to load the class using the context class loader. If that fails due to a ClassNotFoundException or a SecurityException then the requestor's class loader is used. If the requestor object is null then the ClassUtilities class loader is used.

Parameters:
name - The class name
requestor - The object requesting the resource or null
Returns:
The resource stream or null

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String name,
                                                      java.lang.Class requestor)
Load the specified resource stream. This method will first attempt to load the class using the context class loader. If that fails due to a ClassNotFoundException or a SecurityException then the requestor's class loader is used. If the requestor object is null then the ClassUtilities class loader is used.

Parameters:
name - The class name
requestor - The class of the object requesting the resource or null
Returns:
The resource stream or null

getAllClassesAndInterfaces

public static java.util.List getAllClassesAndInterfaces(java.lang.Class startClass)
Find all super classes and implemented interfaces for the given class.

Parameters:
startClass - The class
Returns:
A List of Class objects

addClassesAndInterfaces

protected static void addClassesAndInterfaces(java.lang.Class c,
                                              java.util.List classes)
Add all super classes and interfaces of the given class to the given List.

Parameters:
c - The Class
classes - An List of Classes


Copyright (c) 2000-2003 Anthony Eden. All Rights Reserved.