public final class ClassUtils
extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
INNER_CLASS_SEPARATOR
The inner class separator String:
"$". |
static char |
INNER_CLASS_SEPARATOR_CHAR
The inner class separator character:
'$' == 36. |
static String |
PACKAGE_SEPARATOR
The package separator String:
".". |
static char |
PACKAGE_SEPARATOR_CHAR
The package separator character:
'.' == 46. |
| Constructor and Description |
|---|
ClassUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addFolderToClassPath(String folder,
String pattern)
Adds the all files in the folder, including sub folder which match the pattern to the class path.
|
static void |
addToClassPath(File file)
Adds file to the class path.
|
static void |
addToClassPath(String fileName)
Adds file name to to the class path.
|
static void |
addToClassPath(String name,
String delimiter)
Adds multiple files the to class path.
|
static void |
addToClassPath(URL url)
Adds url to the class path.
|
static boolean |
classExists(String className)
Checks if class with given name exists
|
static String |
className2Web(String className)
Converts class name to the form which can be used by the Wings framework
as a component name.
|
static Object |
clone(Object obj)
Deep clones object.
|
static List<Class<?>> |
getClasses(String packageName,
Class<?> classCastTo,
boolean recursively)
Gets the list of the classes in the package.
|
static List<Class<?>> |
getClasses(String libPath,
String pluginPath,
String packageName,
Class<?> classCastTo,
Map<String,String> addedJars)
Gets the list of classes in the package first, then adds classes in the
plugin path and finally adds classes in the lib path.
|
static List<Class<?>> |
getClassesInPackage(String jarFileName,
String packageName,
Class<?> classCastTo,
Map<String,String> addedJars)
Gets the list of the classes in the package.
|
static List<Class<?>> |
getClassesInPackageInFolder(String folderName,
String packageName,
Class<?> classCastTo,
Map<String,String> addedJars)
Gets the list of the classes in the package located in the jar files in
the folder.
|
static List<Class<?>> |
getClassesInPackageInFolder(String folderName,
String fileName,
String packageName,
Class<?> classCastTo,
Map<String,String> addedJars)
Gets the list of the classes in the package located in the jar files in
the folder.
|
static List<Class<?>> |
getClassesInPackageInFolder(String folderName,
String fileName,
String packageName,
Class<?> classCastTo,
Map<String,String> addedJars,
String ext)
Gets the list of the classes in the package located in the jar files in
the folder.
|
static List<String> |
getFilesInPackage(String pattren,
Class<?> clazz)
Gets the files in the package using given pattern.
|
static String |
getShortClassName(String className)
Gets the class name minus the package name from a String.
|
public static final char PACKAGE_SEPARATOR_CHAR
The package separator character: '.' == 46.
public static final String PACKAGE_SEPARATOR
The package separator String: ".".
public static final char INNER_CLASS_SEPARATOR_CHAR
The inner class separator character: '$' == 36.
public static final String INNER_CLASS_SEPARATOR
The inner class separator String: "$".
public static void addFolderToClassPath(String folder,
String pattern)
folder - the folderpattern - the patternpublic static void addToClassPath(File file)
throws Exception
file - the file to addException - if anything goes wrongpublic static void addToClassPath(String fileName)
throws Exception
fileName - the file name to addException - if anything goes wrongpublic static void addToClassPath(String name,
String delimiter)
throws Exception
name - the string where individual file names divided by delimiterdelimiter - the delimiter between file namesException - if anything goes wrongpublic static void addToClassPath(URL url)
throws Exception
url - the url to addException - if anything goes wrongpublic static boolean classExists(String className)
throws ClassNotFoundException
className - the class nameClassNotFoundExceptionpublic static String className2Web(String className)
className - the name of the classpublic static Object clone(Object obj)
throws Exception
obj - the object to cloneException - if anything goes wrongpublic static List<Class<?>> getClasses(String packageName,
Class<?> classCastTo,
boolean recursively)
getClasses("com.toolsverse.pkg", ClassA.class, true) -->
returns the list of the classes which can be cast to ClassA in the
package com.toolsverse.pkg and sub packagespackageName - the name of the packageclassCastTo - the class to check against.recursively - if true include classes in sub packagespublic static List<Class<?>> getClasses(String libPath,
String pluginPath,
String packageName,
Class<?> classCastTo,
Map<String,String> addedJars)
libPath - the path to the core jars. It is possible to use file name
wildcardspluginPath - the path to the plugin jars. It is possible to use file name
wildcardspackageName - the name of the packageclassCastTo - the class to check against.addedJars - the jar files already added to the class pathpublic static List<Class<?>> getClassesInPackage(String jarFileName,
String packageName,
Class<?> classCastTo,
Map<String,String> addedJars)
jarFileName - the name of the jar filepackageName - the name of the packageclassCastTo - the class to check against.addedJars - the jar files already added to the class pathpublic static List<Class<?>> getClassesInPackageInFolder(String folderName,
String packageName,
Class<?> classCastTo,
Map<String,String> addedJars)
folderName - the name of the folder with jar filespackageName - the name of the packageclassCastTo - the class to check against.addedJars - the jar files already added to the class pathpublic static List<Class<?>> getClassesInPackageInFolder(String folderName,
String fileName,
String packageName,
Class<?> classCastTo,
Map<String,String> addedJars)
folderName - the name of the folder with jar filesfileName - the name of the jar file. Wildcards are allowed. If equals to
null *.jar will be used.packageName - the name of the packageclassCastTo - the class to check against.addedJars - the jar files already added to the class pathpublic static List<Class<?>> getClassesInPackageInFolder(String folderName,
String fileName,
String packageName,
Class<?> classCastTo,
Map<String,String> addedJars,
String ext)
folderName - the name of the folder with jar filesfileName - the name of the jar file. Wildcards are allowed. If equals to
null *.jar will be used.packageName - the name of the packageclassCastTo - the class to check against.addedJars - the jar files already added to the class pathext - the extension of the control filepublic static List<String> getFilesInPackage(String pattren,
Class<?> clazz)
throws Exception
pattren - the patternclazz - any class which lives in the the folderException - the exceptionpublic static String getShortClassName(String className)
Gets the class name minus the package name from a String.
The string passed in is assumed to be a class name - it is not checked.
Note that this method differs from Class.getSimpleName() in that this will
return "Map.Entry" whilst the java.lang.Class variant will simply
return "Entry".
className - the className to get the short name forCopyright © 2010-2020 Toolsverse. All Rights Reserved.