com.rapidminer.tools
Class OperatorService

java.lang.Object
  extended by com.rapidminer.tools.OperatorService

public class OperatorService
extends java.lang.Object

This class reads the description of the RapidMiner operators. These descriptions are entries in a XML File like:


<operators>
  <operator
    name="OperatorName"
    class="java.path.OperatorClass"
    description="OperatorDescription"
    deprecation="OperatorDeprecationInfo"
    group="OperatorGroup"
    icon="OperatorIcon"
/>

The values (and the whole tag) for deprecation and icon might be omitted. If no deprecation info was specified, the operator is simply not deprecated. If no icon is specified, RapidMiner just uses the icon of the parent group.

NOTE: This class should be used to create operators and is therefore an operator factory.

Author:
Ingo Mierswa, Simon Fischer

Field Summary
static java.lang.String MAIN_OPERATORS_NAME
           
 
Constructor Summary
OperatorService()
           
 
Method Summary
static
<T extends Operator>
T
createOperator(java.lang.Class<T> clazz)
          Use this method to create an operator from an operator class.
static Operator createOperator(OperatorDescription description)
          Use this method to create an operator of a given description object.
static Operator createOperator(java.lang.String typeName)
          Use this method to create an operator from the given class name (from operator description file operators.xml, not from the Java class name).
static void defineXMLAliasPairs()
          Defines the alias pairs for the XMLSerialization for all IOObject pairs.
static GroupTree getGroups()
          Returns the group hierarchy of all operators.
static java.lang.Class<IOObject> getIOObjectClass(java.lang.String name)
          Returns the class for the short name of an IO object.
static java.util.Set<java.lang.String> getIOObjectsNames()
          Returns a sorted set of all short IO object names.
static java.net.URL getMainOperators()
          Returns the main operator description file (XML).
static OperatorDescription getOperatorDescription(java.lang.String completeName)
          Returns the operator description for a given class name from the operators.xml file, e.g.
static OperatorDescription[] getOperatorDescriptions(java.lang.Class clazz)
          Returns the operator descriptions for the operators which uses the given class.
static java.util.Set<java.lang.String> getOperatorNames()
          Returns a collection of all operator names.
static java.util.Set<OperatorDescription> getOperatorsDelivering(java.lang.Class ioObject)
          Returns a collection of all operator descriptions of operators which return the desired IO object as output.
static java.util.Set<OperatorDescription> getOperatorsRequiring(java.lang.Class ioObject)
          Returns a collection of all operator descriptions which requires the given IO object as input.
static void registerOperator(OperatorDescription description)
          Registers the given operator description.
static void registerOperators(java.lang.String name, java.io.InputStream operatorsXML, java.lang.ClassLoader classLoader, boolean addWekaOperators)
          Registers all operators from a given XML input stream.
static void reloadIcons()
          Reload all icons, e.g. after a look and feel change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAIN_OPERATORS_NAME

public static final java.lang.String MAIN_OPERATORS_NAME
See Also:
Constant Field Values
Constructor Detail

OperatorService

public OperatorService()
Method Detail

getMainOperators

public static java.net.URL getMainOperators()
Returns the main operator description file (XML).


registerOperators

public static void registerOperators(java.lang.String name,
                                     java.io.InputStream operatorsXML,
                                     java.lang.ClassLoader classLoader,
                                     boolean addWekaOperators)
Registers all operators from a given XML input stream.


registerOperator

public static void registerOperator(OperatorDescription description)
                             throws java.lang.Exception
Registers the given operator description. Please note that two different descriptions must not have the same name. Otherwise the second description overwrite the first in the description map.

Throws:
java.lang.Exception

getIOObjectsNames

public static java.util.Set<java.lang.String> getIOObjectsNames()
Returns a sorted set of all short IO object names.


defineXMLAliasPairs

public static void defineXMLAliasPairs()
Defines the alias pairs for the XMLSerialization for all IOObject pairs.


getOperatorsDelivering

public static java.util.Set<OperatorDescription> getOperatorsDelivering(java.lang.Class ioObject)
Returns a collection of all operator descriptions of operators which return the desired IO object as output.


getOperatorsRequiring

public static java.util.Set<OperatorDescription> getOperatorsRequiring(java.lang.Class ioObject)
Returns a collection of all operator descriptions which requires the given IO object as input.


getIOObjectClass

public static java.lang.Class<IOObject> getIOObjectClass(java.lang.String name)
Returns the class for the short name of an IO object.


getOperatorNames

public static java.util.Set<java.lang.String> getOperatorNames()
Returns a collection of all operator names. A name has the structure classname|subclassname.


getGroups

public static GroupTree getGroups()
Returns the group hierarchy of all operators.


reloadIcons

public static void reloadIcons()
Reload all icons, e.g. after a look and feel change.


getOperatorDescriptions

public static OperatorDescription[] getOperatorDescriptions(java.lang.Class clazz)
Returns the operator descriptions for the operators which uses the given class. Performs a linear seach through all operator descriptions.


getOperatorDescription

public static OperatorDescription getOperatorDescription(java.lang.String completeName)
Returns the operator description for a given class name from the operators.xml file, e.g. "Process" for a ProcessRootOperator.


createOperator

public static Operator createOperator(java.lang.String typeName)
                               throws OperatorCreationException
Use this method to create an operator from the given class name (from operator description file operators.xml, not from the Java class name). For most operators, is is recommended to use the method createOperator(Class) which can be checked during compile time. This is, however, not possible for some generic operators like the Weka operators. In that case, you have to use this method with the argument from the operators.xml file, e.g. createOperator("J48") for a J48 decision tree learner.

Throws:
OperatorCreationException

createOperator

public static Operator createOperator(OperatorDescription description)
                               throws OperatorCreationException
Use this method to create an operator of a given description object.

Throws:
OperatorCreationException

createOperator

public static <T extends Operator> T createOperator(java.lang.Class<T> clazz)
                                         throws OperatorCreationException

Use this method to create an operator from an operator class. This is the only method which ensures operator existence checks during compile time (and not during runtime) and the usage of this method is therefore the recommended way for operator creation.

It is, however, not possible to create some generic operators with this method (this mainly applies to the Weka operators). Please use the method createOperator(String) for those generic operators.

If you try to create a generic operator with this method, the OperatorDescription will not be unique for the given class and an OperatorCreationException is thrown.

Please note that is is not necessary to cast the operator to the desired class.

TODO: can we remove the supress warning here?

Throws:
OperatorCreationException


Copyright © 2001-2009 by Rapid-I