toxTree.core
Class Introspection

java.lang.Object
  extended by toxTree.core.Introspection

public class Introspection
extends java.lang.Object

A singleton class with static method to provide some sort of introspection :) Used in decision tree editor to provide a list of available decision trees, available rules, available categories.
This is done by searching for classes implementing IDecisionMethod, IDecisionRule, and IDecisionCategory in all .jar files in a user defined directory.

Author:
Nina Jeliazkova nina@acad.bg Modified 2005-10-18

Field Summary
protected static java.lang.String[] defaultLocation
           
protected static ToxTreeClassLoader loader
           
protected static TTLogger logger
           
static java.lang.String TOXTREE_HOME
           
 
Constructor Summary
protected Introspection()
           
 
Method Summary
static void addDirectory(java.lang.String dirName)
           
static void configureURLLoader(java.lang.ClassLoader classLoader)
          Adds URLS of jars in default directories to the class loader.
static void configureURLLoader(java.io.File directory)
          Adds URLS of jars in specified directory to the class loader.
static void configureURLLoader(java.io.File[] jars)
          Adds URLS of jars specified in File[] to the class loader.
static java.lang.Object createObject(java.lang.String className)
          Creates object given the class name
static java.io.File[] enumerateJars(java.io.File directory)
           
static ToxTreePackageEntries getAvailableCategoryTypes(java.lang.ClassLoader classLoader)
          Returns a list with available categories
static ToxTreePackageEntries getAvailableRuleTypes(java.lang.ClassLoader classLoader)
          Returns a list with available rule names.
static ToxTreePackageEntries getAvailableTreeTypes(java.lang.ClassLoader classLoader)
          Returns a list with available decision trees.
static ToxTreePackageEntries getAvailableTypes(java.lang.ClassLoader classLoader, java.lang.String interfacename)
          This method is the core of ToxTreeApp extension mechanism.
static java.lang.String[] getDefaultDirectories()
           
static java.lang.ClassLoader getLoader()
           
static java.lang.String getToxTreeRoot()
           
static ToxTreePackageEntries implementInterface(java.lang.ClassLoader classLoader, java.io.File directory, java.lang.String interfaceName)
          Finds classes implementing an interface in all .jar files in a user defined directory.
static java.lang.Class implementsInterface(java.lang.Class clazz, java.lang.String interfaceName)
          Verifies if a class implements an interface
static java.lang.Class implementsInterface(java.lang.String className, java.lang.String interfaceName)
          Verifies if a class implements an interface
static void listBaseTypes(java.lang.Class cls, java.lang.String prefix)
          this is just a test for the concept of introspection
static java.lang.Object loadCreateObject(java.lang.String className)
           
static IDecisionMethodsList loadForest(java.io.InputStream stream)
           
static IDecisionMethodsList loadForestXML(java.io.InputStream stream)
           
static IDecisionMethod loadRules(java.io.InputStream stream, java.lang.String newTitle)
          Loads a decision tree from an InputStream Uses Java serialization mechanism
static IDecisionMethod loadRulesXML(java.io.InputStream stream, java.lang.String newTitle)
           
static void saveRulesXML(IDecisionMethod method, java.io.OutputStream out)
           
static void setLoader(java.lang.ClassLoader classLoader)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOXTREE_HOME

public static final java.lang.String TOXTREE_HOME
See Also:
Constant Field Values

defaultLocation

protected static java.lang.String[] defaultLocation

logger

protected static TTLogger logger

loader

protected static ToxTreeClassLoader loader
Constructor Detail

Introspection

protected Introspection()
Method Detail

addDirectory

public static void addDirectory(java.lang.String dirName)

getDefaultDirectories

public static java.lang.String[] getDefaultDirectories()

listBaseTypes

public static void listBaseTypes(java.lang.Class cls,
                                 java.lang.String prefix)
this is just a test for the concept of introspection


implementsInterface

public static java.lang.Class implementsInterface(java.lang.String className,
                                                  java.lang.String interfaceName)
                                           throws IntrospectionException
Verifies if a class implements an interface

Parameters:
className - - the name of the class to be verified
interfaceName - - the name of the interface to be searched for
Returns:
Class
Throws:
IntrospectionException

implementsInterface

public static java.lang.Class implementsInterface(java.lang.Class clazz,
                                                  java.lang.String interfaceName)
Verifies if a class implements an interface

Parameters:
clazz - - the class to be verified
interfaceName - - the name of the interface to be searched for
Returns:
Class

enumerateJars

public static java.io.File[] enumerateJars(java.io.File directory)
                                    throws IntrospectionException
Throws:
IntrospectionException

configureURLLoader

public static void configureURLLoader(java.lang.ClassLoader classLoader)
Adds URLS of jars in default directories to the class loader. Calls configureURLLoader(File directory) for each of defaultLocation directories.

Parameters:
classLoader -

configureURLLoader

public static void configureURLLoader(java.io.File directory)
                               throws IntrospectionException
Adds URLS of jars in specified directory to the class loader.

Parameters:
directory -
Throws:
IntrospectionException

configureURLLoader

public static void configureURLLoader(java.io.File[] jars)
                               throws IntrospectionException
Adds URLS of jars specified in File[] to the class loader.

Parameters:
jars -
Throws:
IntrospectionException

implementInterface

public static ToxTreePackageEntries implementInterface(java.lang.ClassLoader classLoader,
                                                       java.io.File directory,
                                                       java.lang.String interfaceName)
                                                throws IntrospectionException
Finds classes implementing an interface in all .jar files in a user defined directory.

Parameters:
directory - - the directory with jar files to be searched for
interfaceName - - the name of the interface to be searched for
Returns:
ToxTreePackageEntries of String , each item is a class name
Throws:
IntrospectionException

getAvailableRuleTypes

public static ToxTreePackageEntries getAvailableRuleTypes(java.lang.ClassLoader classLoader)
Returns a list with available rule names. Uses getAvailableTypes(ClassLoader, String)

Returns:
an ArrayList of class names that implement IDecisionRule

getAvailableTreeTypes

public static ToxTreePackageEntries getAvailableTreeTypes(java.lang.ClassLoader classLoader)
Returns a list with available decision trees. Uses getAvailableTypes(ClassLoader, String)

Returns:
an ArrayList of class names that implement IDecisionMethod

getAvailableTypes

public static ToxTreePackageEntries getAvailableTypes(java.lang.ClassLoader classLoader,
                                                      java.lang.String interfacename)
This method is the core of ToxTreeApp extension mechanism. Looks for classes that implement interface given by interfacename parameter. Returns a list with class names. Jar files within the following directories are analyzed:

Parameters:
classLoader -
interfacename - the
Returns:
a list with available class names , implementing the interfaceArrayList

getAvailableCategoryTypes

public static ToxTreePackageEntries getAvailableCategoryTypes(java.lang.ClassLoader classLoader)
Returns a list with available categories

Returns:
an ArrayList of class names that implement IDecisionCategory

createObject

public static java.lang.Object createObject(java.lang.String className)
Creates object given the class name

Parameters:
className -
Returns:
Object

loadCreateObject

public static java.lang.Object loadCreateObject(java.lang.String className)
                                         throws java.lang.InstantiationException,
                                                java.lang.IllegalAccessException,
                                                java.lang.ClassNotFoundException
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException

getLoader

public static java.lang.ClassLoader getLoader()

setLoader

public static void setLoader(java.lang.ClassLoader classLoader)

loadRules

public static IDecisionMethod loadRules(java.io.InputStream stream,
                                        java.lang.String newTitle)
                                 throws IntrospectionException
Loads a decision tree from an InputStream Uses Java serialization mechanism

Parameters:
stream -
newTitle -
Returns:
a decision tree IDecisionMethod
Throws:
IntrospectionException

loadForest

public static IDecisionMethodsList loadForest(java.io.InputStream stream)
                                       throws IntrospectionException
Throws:
IntrospectionException

saveRulesXML

public static void saveRulesXML(IDecisionMethod method,
                                java.io.OutputStream out)
                         throws IntrospectionException
Throws:
IntrospectionException

loadRulesXML

public static IDecisionMethod loadRulesXML(java.io.InputStream stream,
                                           java.lang.String newTitle)
                                    throws IntrospectionException
Throws:
IntrospectionException

loadForestXML

public static IDecisionMethodsList loadForestXML(java.io.InputStream stream)
                                          throws IntrospectionException
Throws:
IntrospectionException

getToxTreeRoot

public static java.lang.String getToxTreeRoot()


Copyright © 2004-2012 Ideaconsult Ltd.. All Rights Reserved.