org.drools.base.evaluators
Class EvaluatorRegistry

java.lang.Object
  extended by org.drools.base.evaluators.EvaluatorRegistry
All Implemented Interfaces:
Externalizable, Serializable

public class EvaluatorRegistry
extends Object
implements Externalizable

A registry class for all available evaluators

See Also:
Serialized Form

Constructor Summary
EvaluatorRegistry()
          Default constructor.
EvaluatorRegistry(ClassLoader classloader)
          Creates a new EvaluatorRegistry using the given classloader to load the evaluator definition classes.
 
Method Summary
 void addEvaluatorDefinition(EvaluatorDefinition def)
          Adds an evaluator definition class to the registry.
 void addEvaluatorDefinition(String className)
          Adds an evaluator definition class to the registry using the evaluator class name.
 Evaluator getEvaluator(ValueType type, Operator operator)
          Returns the evaluator instance for the given type and the defined parameterText
 Evaluator getEvaluator(ValueType type, Operator operator, String parameterText)
          Returns the evaluator instance for the given type and the defined parameterText
 Evaluator getEvaluator(ValueType type, String operatorId, boolean isNegated, String parameterText)
          Returns the evaluator instance for the given type and the defined parameterText
 EvaluatorDefinition getEvaluatorDefinition(Operator operator)
          Returns the evaluator definition for the given operator or null if no one was found
 EvaluatorDefinition getEvaluatorDefinition(String evaluatorId)
          Returns the evaluator definition for the given evaluator ID or null if no one was found
 Set<String> keySet()
          Return the set of registered keys.
 void readExternal(ObjectInput in)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EvaluatorRegistry

public EvaluatorRegistry()
Default constructor. The registry will use the context classloader (if available) to load the evaluator definition classes or this class classloader if it is not available.


EvaluatorRegistry

public EvaluatorRegistry(ClassLoader classloader)
Creates a new EvaluatorRegistry using the given classloader to load the evaluator definition classes.

Parameters:
classloader - the classloader to use to load evaluator definition classes. If it is null, try to obtain the context classloader. If it is also null, uses the same classloader that loaded this class.
Method Detail

keySet

public Set<String> keySet()
Return the set of registered keys.

Returns:
a Set of Strings

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

addEvaluatorDefinition

public void addEvaluatorDefinition(String className)
Adds an evaluator definition class to the registry using the evaluator class name. The class will be loaded and the corresponting evaluator ID will be added to the registry. In case there exists an implementation for that ID already, the new implementation will replace the previous one.

Parameters:
className - the name of the class for the implementation definition. The class must implement the EvaluatorDefinition interface.

addEvaluatorDefinition

public void addEvaluatorDefinition(EvaluatorDefinition def)
Adds an evaluator definition class to the registry. In case there exists an implementation for that evaluator ID already, the new implementation will replace the previous one.

Parameters:
def - the evaluator definition to be added.

getEvaluatorDefinition

public EvaluatorDefinition getEvaluatorDefinition(String evaluatorId)
Returns the evaluator definition for the given evaluator ID or null if no one was found

Parameters:
evaluatorId -
Returns:

getEvaluatorDefinition

public EvaluatorDefinition getEvaluatorDefinition(Operator operator)
Returns the evaluator definition for the given operator or null if no one was found

Parameters:
operator - the operator implemented by the evaluator definition
Returns:

getEvaluator

public Evaluator getEvaluator(ValueType type,
                              String operatorId,
                              boolean isNegated,
                              String parameterText)
Returns the evaluator instance for the given type and the defined parameterText

Parameters:
type - the type of the attributes this evaluator will operate on. This is important because the evaluator may do optimizations and type coercion based on the types it is evaluating. It is also possible that this evaluator does not support a given type.
operatorId - the string identifier of the evaluator
isNegated - true if the evaluator instance to be returned is the negated version of the evaluator.
parameterText - some evaluators support parameters and these parameters are defined as a String that is parsed by the evaluator itself.
Returns:
an Evaluator instance capable of evaluating expressions between values of the given type, or null in case the type is not supported.

getEvaluator

public Evaluator getEvaluator(ValueType type,
                              Operator operator,
                              String parameterText)
Returns the evaluator instance for the given type and the defined parameterText

Parameters:
type - the type of the attributes this evaluator will operate on. This is important because the evaluator may do optimizations and type coercion based on the types it is evaluating. It is also possible that this evaluator does not support a given type.
operator - the operator that evaluator implements
parameterText - some evaluators support parameters and these parameters are defined as a String that is parsed by the evaluator itself.
Returns:
an Evaluator instance capable of evaluating expressions between values of the given type, or null in case the type is not supported.

getEvaluator

public Evaluator getEvaluator(ValueType type,
                              Operator operator)
Returns the evaluator instance for the given type and the defined parameterText

Parameters:
type - the type of the attributes this evaluator will operate on. This is important because the evaluator may do optimizations and type coercion based on the types it is evaluating. It is also possible that this evaluator does not support a given type.
operator - the operator that evaluator implements
Returns:
an Evaluator instance capable of evaluating expressions between values of the given type, or null in case the type is not supported.


Copyright © 2001-2013 JBoss Inc.. All Rights Reserved.