weka.core

## Class ClassCache

- java.lang.Object
- - weka.core.ClassCache

- All Implemented Interfaces:
    RevisionHandler

      public class ClassCache
      extends java.lang.Object
      implements RevisionHandler

  A singleton that stores all classes on the classpath.
  Version:
    $Revision: 14791 $
  Author:
    fracpete (fracpete at waikato dot ac dot nz)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ClassCache.ClassFileFilter` For filtering classes.
    `static class` | `ClassCache.DirectoryFilter` For filtering classes.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DEFAULT_PACKAGE` the key for the default package.
    `static boolean` | `VERBOSE` whether to output some debug information.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClassCache()` Initializes the cache.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(java.lang.String classname)` Adds the classname to the cache.
    `static java.lang.String` | `cleanUp(java.lang.String classname)` Fixes the classname, turns "/" and "\" into "." and removes ".class".
    `static java.lang.String` | `extractPackage(java.lang.String classname)` Extracts the package name from the (clean) classname.
    `java.util.ArrayList<java.lang.String>` | `find(java.lang.String matchText)` Find all classes that have the supplied matchText String in their suffix.
    `java.util.HashSet<java.lang.String>` | `getClassnames(java.lang.String pkgname)` Returns all the classes for the given package.
    `java.lang.String` | `getRevision()` Returns the revision string.
    `static void` | `main(java.lang.String[] args)` For testing only.
    `java.util.Enumeration<java.lang.String>` | `packages()` Returns all the stored packages.
    `boolean` | `remove(java.lang.String classname)` Removes the classname from the cache.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### VERBOSE

          public static final boolean VERBOSE

      whether to output some debug information.
      See Also:
        Constant Field Values

    - #### DEFAULT_PACKAGE

          public static final java.lang.String DEFAULT_PACKAGE

      the key for the default package.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ClassCache

          public ClassCache()

      Initializes the cache.

  - ### Method Detail

    - #### cleanUp

          public static java.lang.String cleanUp(java.lang.String classname)

      Fixes the classname, turns "/" and "\" into "." and removes ".class".
      Parameters:
        `classname` - the classname to process
      Returns:
        the processed classname

    - #### extractPackage

          public static java.lang.String extractPackage(java.lang.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(java.lang.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(java.lang.String classname)

      Removes the classname from the cache.
      Parameters:
        `classname` - the classname to remove
      Returns:
        true if the removal changed the cache

    - #### packages

          public java.util.Enumeration<java.lang.String> packages()

      Returns all the stored packages.
      Returns:
        the package names

    - #### getClassnames

          public java.util.HashSet<java.lang.String> getClassnames(java.lang.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 java.util.ArrayList<java.lang.String> find(java.lang.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 java.lang.String getRevision()

      Returns the revision string.
      Specified by:
        `getRevision` in interface `RevisionHandler`
      Returns:
        the revision

    - #### main

          public static void main(java.lang.String[] args)

      For testing only.
      Parameters:
        `args` - ignored