Package org.drools.core.base.evaluators
Class EvaluatorRegistry
- java.lang.Object
-
- org.drools.core.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
Constructors Constructor Description EvaluatorRegistry()
Default constructor.EvaluatorRegistry(ClassLoader classloader)
Creates a new EvaluatorRegistry using the given classloader to load the evaluator definition classes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEvaluatorDefinition(String className)
Adds an evaluator definition class to the registry using the evaluator class name.void
addEvaluatorDefinition(EvaluatorDefinition def)
Adds an evaluator definition class to the registry.Evaluator
getEvaluator(ValueType type, String operatorId, boolean isNegated, String parameterText)
Returns the evaluator instance for the given type and the defined parameterTextEvaluator
getEvaluator(ValueType type, Operator operator)
Returns the evaluator instance for the given type and the defined parameterTextEvaluator
getEvaluator(ValueType type, Operator operator, String parameterText)
Returns the evaluator instance for the given type and the defined parameterTextEvaluatorDefinition
getEvaluatorDefinition(String evaluatorId)
Returns the evaluator definition for the given evaluator ID or null if no one was foundEvaluatorDefinition
getEvaluatorDefinition(Operator operator)
Returns the evaluator definition for the given operator or null if no one was foundSet<String>
keySet()
Return the set of registered keys.void
readExternal(ObjectInput in)
void
writeExternal(ObjectOutput out)
-
-
-
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
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- 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 evaluatorisNegated
- 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 implementsparameterText
- 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.
-
-