Package weka.core
Class ClassDiscovery
- java.lang.Object
-
- weka.core.ClassDiscovery
-
- All Implemented Interfaces:
RevisionHandler
public class ClassDiscovery extends java.lang.Object implements RevisionHandler
This class is used for discovering classes that implement a certain interface or a derived from a certain class.- Version:
- $Revision: 5377 $
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
ClassDiscovery.StringCompare
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClassDiscovery.StringComparecompares two strings.
-
Field Summary
Fields Modifier and Type Field Description static booleanVERBOSEwhether to output some debug information.
-
Constructor Summary
Constructors Constructor Description ClassDiscovery()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidclearCache()clears the cache for class/classnames relation.static java.util.Vectorfind(java.lang.Class cls, java.lang.String pkgname)Checks the given package for classes that inherited from the given class, in case it's a class, or implement this class, in case it's an interface.static java.util.Vectorfind(java.lang.Class cls, java.lang.String[] pkgnames)Checks the given packages for classes that inherited from the given class, in case it's a class, or implement this class, in case it's an interface.static java.util.Vectorfind(java.lang.String classname, java.lang.String pkgname)Checks the given package for classes that inherited from the given class, in case it's a class, or implement this class, in case it's an interface.static java.util.Vectorfind(java.lang.String classname, java.lang.String[] pkgnames)Checks the given packages for classes that inherited from the given class, in case it's a class, or implement this class, in case it's an interface.static java.util.VectorfindPackages()Lists all packages it can find in the classpath.java.lang.StringgetRevision()Returns the revision string.static booleanhasInterface(java.lang.Class intf, java.lang.Class cls)Checks whether the given class implements the given interface.static booleanhasInterface(java.lang.String intf, java.lang.String cls)Checks whether the given class implements the given interface.static booleanisSubclass(java.lang.Class superclass, java.lang.Class otherclass)Checks whether the "otherclass" is a subclass of the given "superclass".static booleanisSubclass(java.lang.String superclass, java.lang.String otherclass)Checks whether the "otherclass" is a subclass of the given "superclass".static voidmain(java.lang.String[] args)Possible calls: weka.core.ClassDiscovery <packages>
Prints all the packages in the current classpath weka.core.ClassDiscovery <classname> <packagename(s)>
Prints the classes it found.
-
-
-
Field Detail
-
VERBOSE
public static final boolean VERBOSE
whether to output some debug information.- See Also:
- Constant Field Values
-
-
Method Detail
-
isSubclass
public static boolean isSubclass(java.lang.String superclass, java.lang.String otherclass)Checks whether the "otherclass" is a subclass of the given "superclass".- Parameters:
superclass- the superclass to check againstotherclass- this class is checked whether it is a subclass of the the superclass- Returns:
- TRUE if "otherclass" is a true subclass
-
isSubclass
public static boolean isSubclass(java.lang.Class superclass, java.lang.Class otherclass)Checks whether the "otherclass" is a subclass of the given "superclass".- Parameters:
superclass- the superclass to check againstotherclass- this class is checked whether it is a subclass of the the superclass- Returns:
- TRUE if "otherclass" is a true subclass
-
hasInterface
public static boolean hasInterface(java.lang.String intf, java.lang.String cls)Checks whether the given class implements the given interface.- Parameters:
intf- the interface to look for in the given classcls- the class to check for the interface- Returns:
- TRUE if the class contains the interface
-
hasInterface
public static boolean hasInterface(java.lang.Class intf, java.lang.Class cls)Checks whether the given class implements the given interface.- Parameters:
intf- the interface to look for in the given classcls- the class to check for the interface- Returns:
- TRUE if the class contains the interface
-
find
public static java.util.Vector find(java.lang.String classname, java.lang.String[] pkgnames)Checks the given packages for classes that inherited from the given class, in case it's a class, or implement this class, in case it's an interface.- Parameters:
classname- the class/interface to look forpkgnames- the packages to search in- Returns:
- a list with all the found classnames
-
find
public static java.util.Vector find(java.lang.String classname, java.lang.String pkgname)Checks the given package for classes that inherited from the given class, in case it's a class, or implement this class, in case it's an interface.- Parameters:
classname- the class/interface to look forpkgname- the package to search in- Returns:
- a list with all the found classnames
-
find
public static java.util.Vector find(java.lang.Class cls, java.lang.String[] pkgnames)Checks the given packages for classes that inherited from the given class, in case it's a class, or implement this class, in case it's an interface.- Parameters:
cls- the class/interface to look forpkgnames- the packages to search in- Returns:
- a list with all the found classnames
-
find
public static java.util.Vector find(java.lang.Class cls, java.lang.String pkgname)Checks the given package for classes that inherited from the given class, in case it's a class, or implement this class, in case it's an interface.- Parameters:
cls- the class/interface to look forpkgname- the package to search in- Returns:
- a list with all the found classnames
-
findPackages
public static java.util.Vector findPackages()
Lists all packages it can find in the classpath.- Returns:
- a list with all the found packages
-
clearCache
public static void clearCache()
clears the cache for class/classnames relation.
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Returns:
- the revision
-
main
public static void main(java.lang.String[] args)
Possible calls:-
weka.core.ClassDiscovery <packages>
Prints all the packages in the current classpath -
weka.core.ClassDiscovery <classname> <packagename(s)>
Prints the classes it found.
- Parameters:
args- the commandline arguments
-
weka.core.ClassDiscovery <packages>
-
-