com.rapidminer.tools
Class OperatorService

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

public class OperatorService
extends java.lang.Object

This class maintains all registered operators in the current context. There exists a listener concept that will alert all listeners, if new operators are added or removed. It provides convenience methods for creating new Operators. See the description of the createOperator(Class) method. Please mind that Operators that are built from an OperationFactory cannot be constructed with this method. Please use createOperator(String) method instead, that can be passed the Operator's key.

This class also reads the xml definitions of the RapidMiner Core and Extension operators. These descriptions are entries in a XML file like OperatorsCore.xml.

Author:
Ingo Mierswa, Simon Fischer, Sebastian Land

Nested Class Summary
static interface OperatorService.OperatorServiceListener
          The interface for all Listener to the OperatorService.
 
Field Summary
static java.lang.String RAPID_MINER_CORE_NAMESPACE
           
static java.lang.String RAPID_MINER_CORE_PREFIX
           
 
Constructor Summary
OperatorService()
           
 
Method Summary
static void addOperatorCreationHook(OperatorCreationHook operatorCreationHook)
          This method adds an OperatorCreationHook that will be informed whenever an Operator instance is created.
static void addOperatorServiceListener(OperatorService.OperatorServiceListener listener)
          This method can be used to add an listener to the OperatorService that is informed whenever the set of available operators changes.
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 GroupTree getGroups()
          Returns the group hierarchy of all operators.
static java.lang.Class<? extends 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 OperatorDescription getOperatorDescription(java.lang.String key)
          Returns the operator description for a given key 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> getOperatorKeys()
          Returns a collection of all operator keys.
static java.util.Set<java.lang.String> getOperatorNames()
          Deprecated. 
static java.lang.String getReplacementForDeprecatedClass(java.lang.String deprecatedKey)
          Returns a replacement if the given operator class is deprecated, and null otherwise.
static void init()
           
static void invokeCreationHooks(Operator operator)
          This method must be called by each OperatorDescription.createOperatorInstance() call.
static void registerIOObjects(java.util.Collection<java.lang.Class<? extends IOObject>> objects)
          Checks if the given classes are already registered and adds them if not.
static void registerOperator(OperatorDescription description)
          Deprecated. 
static void registerOperator(OperatorDescription description, OperatorDocBundle bundle)
          Registers the given operator description.
static void registerOperators(java.lang.String name, java.io.InputStream operatorsXML, java.lang.ClassLoader classLoader)
          Registers all operators from a given XML input stream.
static void registerOperators(java.lang.String name, java.io.InputStream operatorsXML, java.lang.ClassLoader classLoader, Plugin provider)
           
static void registerOperators(java.net.URL operatorsXML, java.lang.ClassLoader classLoader, Plugin plugin)
           
static void setAdditionalOperatorDescriptors(java.lang.String... files)
          Specifies a list of files to be loaded as operator descriptors.
static void unregisterOperator(OperatorDescription description)
          This method can be used to dynamically remove Operators from the number of defined operators.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RAPID_MINER_CORE_PREFIX

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

RAPID_MINER_CORE_NAMESPACE

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

OperatorService

public OperatorService()
Method Detail

init

public static void init()

registerOperators

public static void registerOperators(java.net.URL operatorsXML,
                                     java.lang.ClassLoader classLoader,
                                     Plugin plugin)

registerOperators

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


registerOperators

public static void registerOperators(java.lang.String name,
                                     java.io.InputStream operatorsXML,
                                     java.lang.ClassLoader classLoader,
                                     Plugin provider)

registerOperator

@Deprecated
public static void registerOperator(OperatorDescription description)
                             throws OperatorCreationException
Deprecated. 

This method does the same as #registerOperator(OperatorDescription, OperatorDocBundle)), but without an OperatorDocBundle groups will not have a name or icon. This method remains for compatibility of older extensions.

Throws:
OperatorCreationException

registerOperator

public static void registerOperator(OperatorDescription description,
                                    OperatorDocBundle bundle)
                             throws OperatorCreationException
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. If there's no icon defined for the given OperatorDescription, the group icon will be set here.

Parameters:
bundle - might be null. If existing will be used for GroupCreation / Icon settings
Throws:
OperatorCreationException

unregisterOperator

public static void unregisterOperator(OperatorDescription description)
This method can be used to dynamically remove Operators from the number of defined operators.


registerIOObjects

public static void registerIOObjects(java.util.Collection<java.lang.Class<? extends IOObject>> objects)
Checks if the given classes are already registered and adds them if not.


getIOObjectsNames

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


getIOObjectClass

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


getOperatorNames

@Deprecated
public static java.util.Set<java.lang.String> getOperatorNames()
Deprecated. 

Returns a collection of all operator keys. Use getOperatorKeys() instead.


getOperatorKeys

public static java.util.Set<java.lang.String> getOperatorKeys()
Returns a collection of all operator keys.


getGroups

public static GroupTree getGroups()
Returns the group hierarchy of all operators. This will automatically reflect changes on the registered Operators. You might register as listener to OperatorService in order to receive registration or unregistration eventsevents


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 key)
Returns the operator description for a given key from the operators.xml file, e.g. "read_csv" for the Read CSV operator.


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 suppress warning here?

Throws:
OperatorCreationException

getReplacementForDeprecatedClass

public static java.lang.String getReplacementForDeprecatedClass(java.lang.String deprecatedKey)
Returns a replacement if the given operator class is deprecated, and null otherwise. The deprecated Key is the key with that this operator was used in RapidMiner 4.x


setAdditionalOperatorDescriptors

public static void setAdditionalOperatorDescriptors(java.lang.String... files)
Specifies a list of files to be loaded as operator descriptors.


addOperatorCreationHook

public static void addOperatorCreationHook(OperatorCreationHook operatorCreationHook)
This method adds an OperatorCreationHook that will be informed whenever an Operator instance is created.


invokeCreationHooks

public static void invokeCreationHooks(Operator operator)
This method must be called by each OperatorDescription.createOperatorInstance() call. It is used for example for statistics purpose.


addOperatorServiceListener

public static void addOperatorServiceListener(OperatorService.OperatorServiceListener listener)
This method can be used to add an listener to the OperatorService that is informed whenever the set of available operators changes. Internally WeakReferences are used so that there's no need to deregister listeners.



Copyright © 2001-2009 by Rapid-I