public class ClassLoaderUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ClassLoaderUtil.AggregateIterator<E>
Aggregates Enumeration instances into one iterator and filters out duplicates.
|
| Constructor and Description |
|---|
ClassLoaderUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
belongsToLangPackage(String clazz) |
Method |
getMethod(Class<?> clazz,
String methodName,
Class<?>... typeArgs)
This method returns a method(public, protected or private) which appears
in the selected class or any of its parent (interface or superclass) or
container classes (when the selected class is an inner class) which
matches with the name and whose parameters are compatible with the
selected typeArgs.
|
static Class<?> |
getPrimitiveClass(Class<?> wrapperClazz) |
static Class<?> |
getPrimitiveClass(String name) |
static URL |
getResource(String resourceName,
Class<?> callingClass)
Load a given resource.
|
static InputStream |
getResourceAsStream(String resourceName,
Class<?> callingClass)
This is a convenience method to load a resource as a stream.
|
static Iterator<URL> |
getResources(String resourceName,
Class<?> callingClass,
boolean aggregate)
Load all resources with a given name, potentially aggregating all results
from the searched classloaders.
|
static boolean |
isCompatible(Class<?>[] fromClasses,
Class<?>[] toClasses) |
static boolean |
isCompatible(Class<?> fromClass,
Class<?> toClass) |
static boolean |
isPrimitiveWrapperClass(Class<?> clazz) |
static Class<?> |
loadClass(String className,
Class<?> callingClass)
Load a class with a given name.
|
public static boolean belongsToLangPackage(String clazz)
public static boolean isPrimitiveWrapperClass(Class<?> clazz)
public Method getMethod(Class<?> clazz, String methodName, Class<?>... typeArgs)
clazz - methodName - typeArgs - public static Iterator<URL> getResources(String resourceName, Class<?> callingClass, boolean aggregate) throws IOException
resourceName - The name of the resources to loadcallingClass - The Class object of the calling objectIOExceptionpublic static URL getResource(String resourceName, Class<?> callingClass)
resourceName - The name IllegalStateException("Unable to call ")of the resource to loadcallingClass - The Class object of the calling objectpublic static InputStream getResourceAsStream(String resourceName, Class<?> callingClass)
resourceName - The name of the resource to loadcallingClass - The Class object of the calling objectpublic static Class<?> loadClass(String className, Class<?> callingClass) throws ClassNotFoundException
className - The name of the class to loadcallingClass - The Class object of the calling objectClassNotFoundException - If the class cannot be found anywhere.Copyright © 2014. All rights reserved.