Package weka.core
Class ClassCache
- java.lang.Object
-
- weka.core.ClassCache
-
- All Implemented Interfaces:
RevisionHandler
public class ClassCache extends Object implements RevisionHandler
A singleton that stores all classes on the classpath.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClassCache.ClassFileFilterFor filtering classes.static classClassCache.DirectoryFilterFor filtering classes.
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_PACKAGEthe key for the default package.static booleanVERBOSEwhether to output some debug information.
-
Constructor Summary
Constructors Constructor Description ClassCache()Initializes the cache.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(String classname)Adds the classname to the cache.static StringcleanUp(String classname)Fixes the classname, turns "/" and "\" into "." and removes ".class".static StringextractPackage(String classname)Extracts the package name from the (clean) classname.ArrayList<String>find(String matchText)Find all classes that have the supplied matchText String in their suffix.HashSet<String>getClassnames(String pkgname)Returns all the classes for the given package.StringgetRevision()Returns the revision string.static voidmain(String[] args)For testing only.Enumeration<String>packages()Returns all the stored packages.booleanremove(String classname)Removes the classname from the cache.
-
-
-
Field Detail
-
VERBOSE
public static final boolean VERBOSE
whether to output some debug information.- See Also:
- Constant Field Values
-
DEFAULT_PACKAGE
public static final String DEFAULT_PACKAGE
the key for the default package.- See Also:
- Constant Field Values
-
-
Method Detail
-
cleanUp
public static String cleanUp(String classname)
Fixes the classname, turns "/" and "\" into "." and removes ".class".- Parameters:
classname- the classname to process- Returns:
- the processed classname
-
extractPackage
public static String extractPackage(String classname)
Extracts the package name from the (clean) classname.- Parameters:
classname- the classname to extract the package from- Returns:
- the package name
-
add
public boolean add(String classname)
Adds the classname to the cache.- Parameters:
classname- the classname, automatically removes ".class" and turns "/" or "\" into "."- Returns:
- true if adding changed the cache
-
remove
public boolean remove(String classname)
Removes the classname from the cache.- Parameters:
classname- the classname to remove- Returns:
- true if the removal changed the cache
-
packages
public Enumeration<String> packages()
Returns all the stored packages.- Returns:
- the package names
-
getClassnames
public HashSet<String> getClassnames(String pkgname)
Returns all the classes for the given package.- Parameters:
pkgname- the package to get the classes for- Returns:
- the classes (sorted by name)
-
find
public ArrayList<String> find(String matchText)
Find all classes that have the supplied matchText String in their suffix.- Parameters:
matchText- the text to match- Returns:
- an array list of matching fully qualified class names.
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Returns:
- the revision
-
main
public static void main(String[] args)
For testing only.- Parameters:
args- ignored
-
-