|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.craftforge.reflection.utils.PackageUtils
public class PackageUtils
Provides utilities for package actions.
| Constructor Summary | |
|---|---|
PackageUtils()
|
|
| Method Summary | |
|---|---|
static List<Class<?>> |
findClasses(String packageName)
Finds all classes accessible from the class loader and belonging to the given package and its sub-packages. |
static List<Class<?>> |
findClassesInDir(File directory,
String packageName)
Recursive method used to find all classes in a given directory and sub directories. |
static List<Class<?>> |
findClassesInJar(JarFile jarFile,
String packagePath)
Finds all classes in a the package path of the given jar file. |
static String |
nameToPath(String packageName)
Converts a package name to a package path. |
static String |
pathToName(String packagePath)
Converts a package path to a package name. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PackageUtils()
| Method Detail |
|---|
public static List<Class<?>> findClasses(String packageName)
Finds all classes accessible from the class loader and belonging to the given package and its sub-packages. Uses classes from the file system if the given package can be obtained as a system resource by the class loader.
Only if no such resource is available, the package will be loaded from a jar file resource if available.
Note: This behaviour is a consequence of the class loader behaviour and may differ in Java versions other then 1.6.
packageName - The package
public static List<Class<?>> findClassesInDir(File directory,
String packageName)
throws ClassNotFoundException
directory - The base directorypackageName - The package name for classes found inside the base directory
ClassNotFoundException - if class loading fails
public static List<Class<?>> findClassesInJar(JarFile jarFile,
String packagePath)
throws ClassNotFoundException,
IOException
jarFile - The jar file.packagePath - The package path
ClassNotFoundException - if class loading fails
IOException - if the jar file cannot be readpublic static String nameToPath(String packageName)
Converts a package name to a package path.
example: net.craftforge.essential -> net/craftforge/example
packageName - The package name
public static String pathToName(String packagePath)
Converts a package path to a package name.
example: net/craftforge/essential -> net.craftforge.example
packagePath - The package path
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||