public class ClassPathUtils extends Object
| Constructor and Description |
|---|
ClassPathUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
doLog(Object... args)
Write to log if log is enabled.
|
static Set<Class<?>> |
filterClasses(Collection<Class<?>> classes,
ClassPathFilter filter)
Return the set of classes from the collection that pass the filter.
|
static Set<String> |
filterClassNames(Collection<String> classNames,
ClassPathFilter filter)
Return the set of classes from the collection that pass the filter.
|
static Set<String> |
findClasses(String directory,
String packageName)
Recursive method used to find all classes in a given directory and
subdirs.
|
static Set<String> |
findClasses(String directory,
String packageName,
ClassPathFilter filter)
Find the classes in a directory and sub directory.
|
static Set<String> |
findResources(String directory,
String packageName)
Recursive method used to find all classes in a given directory and
subdirs.
|
static Set<String> |
findResources(String directory,
String packageName,
ClassPathFilter filter)
Find the classes in a directory and sub directory.
|
static Set<Class<?>> |
getAllInterfaces(Class<?> clazz)
Get all the interfaces for the class.
|
static Set<Class<?>> |
getAllInterfaces(Class<?> clazz,
ClassPathFilter filter)
Get all the interfaces for the class that meet the filter.
|
static void |
getAllInterfaces(Set<Class<?>> set,
Class<?> c)
Get all the interfaces that the class implements.
|
static Collection<Class<?>> |
getClasses(ClassLoader classLoader,
String packageName)
Find all classes accessible from the class loader which belong to the
given package and sub packages.
|
static Collection<Class<?>> |
getClasses(ClassLoader classLoader,
String packageName,
ClassPathFilter filter)
Find all classes accessible from the class loader which belong to the
given package and sub packages.
|
static Collection<Class<?>> |
getClasses(String packageName)
Find all classes accessible from the context class loader which belong to
the given package and sub packages.
|
static Collection<Class<?>> |
getClasses(String packageName,
ClassPathFilter filter)
Get a collection of classes in the package name that meet the filter.
|
static ClassLoader |
getClassLoader()
Get the classloader.
|
static String[] |
getClassPathElements()
Get the array of class path elements.
|
static Collection<URL> |
getResources(ClassLoader classLoader,
String packageName)
Find all classes accessible from the class loader which belong to the
given package and sub packages.
|
static Collection<URL> |
getResources(ClassLoader classLoader,
String packageName,
ClassPathFilter filter)
Find all classes accessible from the class loader which belong to the
given package and sub packages.
|
static Collection<URL> |
getResources(String packageName)
Find all classes accessible from the context class loader which belong to
the given package and sub packages.
|
static Collection<URL> |
getResources(String packageName,
ClassPathFilter filter)
Get a collection of classes in the package name that meet the filter.
|
public static void doLog(Object... args)
args - public static ClassLoader getClassLoader()
public static Set<String> findClasses(String directory, String packageName) throws IOException
directory - The base directorypackageName - The package name for classes found inside the base directoryIOException - on error.public static Set<String> findClasses(String directory, String packageName, ClassPathFilter filter) throws IOException
directory - The directory or jar file to search.packageName - The list of packages to look for.filter - The filter to apply to results.IOException - on error.public static Collection<Class<?>> getClasses(String packageName)
packageName - The base package or class name.public static Collection<Class<?>> getClasses(String packageName, ClassPathFilter filter)
packageName - The package name to locate.filter - the ClassFilter to filter the results with.public static Collection<Class<?>> getClasses(ClassLoader classLoader, String packageName)
classLoader - The class loader to load the classes from.packageName - The base package or class namepublic static Collection<Class<?>> getClasses(ClassLoader classLoader, String packageName, ClassPathFilter filter)
classLoader - The class loader to load the classes from.packageName - The package name to locate the classes in.filter - The filter for the classes.public static Set<Class<?>> filterClasses(Collection<Class<?>> classes, ClassPathFilter filter)
classes - The collection of classes to filter.filter - The filter to use.public static Set<String> filterClassNames(Collection<String> classNames, ClassPathFilter filter)
classNames - the collection of class names.filter - The filter to apply.public static String[] getClassPathElements()
public static Set<Class<?>> getAllInterfaces(Class<?> clazz)
clazz - The class to find interfaces for.public static Set<Class<?>> getAllInterfaces(Class<?> clazz, ClassPathFilter filter)
clazz - The class to find interfaces for.filter - The filter to apply.public static void getAllInterfaces(Set<Class<?>> set, Class<?> c)
set - The set off classes to add the interface classes to.c - The class to check.public static Set<String> findResources(String directory, String packageName) throws IOException
directory - The base directorypackageName - The package name for classes found inside the base directoryIOException - on error.public static Set<String> findResources(String directory, String packageName, ClassPathFilter filter) throws IOException
directory - The directory or jar file to search.packageName - The list of packages to look for.filter - The filter to apply to results.IOException - on error.public static Collection<URL> getResources(String packageName)
packageName - The base package or class name.public static Collection<URL> getResources(String packageName, ClassPathFilter filter)
packageName - The package name to locate.filter - the ClassFilter to filter the results with.public static Collection<URL> getResources(ClassLoader classLoader, String packageName)
classLoader - The class loader to load the classes from.packageName - The base package or class namepublic static Collection<URL> getResources(ClassLoader classLoader, String packageName, ClassPathFilter filter)
classLoader - The class loader to load the classes from.packageName - The package name to locate the classes in.filter - The filter for the classes.Copyright © 2013-2017 XENEI.com. All Rights Reserved.