Overview | Package | Class | Tree | Deprecated | Index | Help | Weka's home
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weka.core
Class RTSI

    java.lang.Object
      weka.core.RTSI

    public class RTSI

extends java.lang.Object

This utility class is looking for all the classes implementing or inheriting from a given interface or class.
(RTSI = RunTime Subclass Identification)

Notes

- Source: JavaWorld Tip 113: Identify subclasses at runtime
- JWhich: JavaWorld Tip 105: Mastering the classpath with JWhich
- Modifications by FracPete:
  - it returns Vectors with the classnames (for the sorting see `StringCompare`)
  - doesn't create an instance of class anymore, but rather tests, whether the superclass/interface is somewhere in the class hierarchy of the found class and whether it is abstract or not
  - checks all parts of the classpath for the package and does not take the first one only (i.e. you can have a dir with the default classes and an additional dir with more classes that are not part of the default ones, e.g. developer classes)

Version:
  $Revision: 1.2.2.4 $
Author:
  Daniel Le Berre, FracPete (fracpete at waikato dot ac dot nz)
See Also:
  `RTSI.StringCompare`

Nested Class Summary
`class` | `RTSI.StringCompare` compares two strings with the following order: case insensitive german umlauts (ä , ö etc.) or other non-ASCII letters are treated as special chars special chars < numbers < letters

Field Summary
`static boolean` | `VERBOSE` whether to output some debug information

Constructor Summary
`RTSI()`

Method Summary
`static java.util.Vector` | `find(java.lang.String tosubclassname)` Returns all the classes inheriting or implementing a given class in the currently loaded packages. Note: If a package, containing subclasses, has not been loaded by the time of this method call, these classes won't be found! It's better to define the package name explicitly in which to look for subclasses, like in `find(String,String)`.
`static java.util.Vector` | `find(java.lang.String pckgname, java.lang.Class tosubclass)` Return all the classes inheriting or implementing a given class in a given package.
`static java.util.Vector` | `find(java.lang.String pckname, java.lang.String tosubclassname)` Returns all the classes inheriting or implementing a given class in a given package.
`static boolean` | `hasInterface(java.lang.Class intf, java.lang.Class cls)` Checks whether the given class implements the given interface.
`static boolean` | `isSubclass(java.lang.Class superclass, java.lang.Class otherclass)` Checks whether the "otherclass" is a subclass of the given "superclass".
`static void` | `main(java.lang.String[] args)` for testing only

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

Constructor Detail

### RTSI

    public RTSI()

Method Detail

### find

    public static java.util.Vector find(java.lang.String tosubclassname)

  Returns all the classes inheriting or implementing a given class in the currently loaded packages.
  Note: If a package, containing subclasses, has not been loaded by the time of this method call, these classes won't be found! It's better to define the package name explicitly in which to look for subclasses, like in `find(String,String)`.

  Parameters:
    `tosubclassname` - the name of the class to inherit from
  Returns:
    a Vector with all the classnames
  See Also:
    `find(String,String)`

### find

    public static java.util.Vector find(java.lang.String pckname,
                                        java.lang.String tosubclassname)

  Returns all the classes inheriting or implementing a given class in a given package.

  Parameters:
    `pckgname` - the fully qualified name of the package
    `tosubclass` - the name of the class to inherit from
  Returns:
    a Vector with all the classnames

### 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 against
    `otherclass` - 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.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 class
    `cls` - 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 pckgname,
                                        java.lang.Class tosubclass)

  Return all the classes inheriting or implementing a given class in a given package.

  Parameters:
    `pckgname` - the fully qualified name of the package
    `tosubclass` - the Class object to inherit from
  Returns:
    a Vector with all the classnames

### main

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

  for testing only

Overview | Package | Class | Tree | Deprecated | Index | Help | Weka's home
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD