Package weka.core

Class ClassDiscovery

  • All Implemented Interfaces:
    RevisionHandler

    public class ClassDiscovery
    extends Object
    implements RevisionHandler
    This class is used for discovering classes that implement a certain interface or a derived from a certain class.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    ClassDiscovery.StringCompare
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean VERBOSE
      whether 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 void clearCache()
      clears the cache for class/classnames queries.
      static void clearClassCache()
      Calls clearCache() and resets the cache of classes on the classpath (i.e.
      static Vector<String> find​(Class<?> cls, 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 Vector<String> find​(Class<?> cls, 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 ArrayList<String> find​(String matchText)
      Find all classes that have the supplied matchText String in their suffix.
      static Vector<String> find​(String classname, 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 Vector<String> find​(String classname, 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 Vector<String> findPackages()
      Lists all packages it can find in the classpath.
      String getRevision()
      Returns the revision string.
      static void main​(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
    • Constructor Detail

      • ClassDiscovery

        public ClassDiscovery()
    • Method Detail

      • find

        public static Vector<String> find​(String classname,
                                          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 for
        pkgnames - the packages to search in
        Returns:
        a list with all the found classnames
      • find

        public static Vector<String> find​(String classname,
                                          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 for
        pkgname - the package to search in
        Returns:
        a list with all the found classnames
      • find

        public static Vector<String> find​(Class<?> cls,
                                          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 for
        pkgnames - the packages to search in
        Returns:
        a list with all the found classnames
      • find

        public static 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.
      • find

        public static Vector<String> find​(Class<?> cls,
                                          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 for
        pkgname - the package to search in
        Returns:
        a list with all the found classnames
      • findPackages

        public static Vector<String> 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 queries.
      • clearClassCache

        public static void clearClassCache()
        Calls clearCache() and resets the cache of classes on the classpath (i.e. forces a rescan of the classpath).
      • main

        public static void main​(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