Package org.drools.compiler.builder.impl
Class EvaluatorRegistry
java.lang.Object
org.drools.compiler.builder.impl.EvaluatorRegistry
- All Implemented Interfaces:
Externalizable,Serializable
A registry class for all available evaluators
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.EvaluatorRegistry(ClassLoader classloader) Creates a new EvaluatorRegistry using the given classloader to load the evaluator definition classes. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEvaluatorDefinition(String className) Adds an evaluator definition class to the registry using the evaluator class name.voidAdds an evaluator definition class to the registry.getEvaluator(ValueType type, String operatorId, boolean isNegated, String parameterText) Returns the evaluator instance for the given type and the defined parameterTextgetEvaluator(ValueType type, Operator operator) Returns the evaluator instance for the given type and the defined parameterTextgetEvaluator(ValueType type, Operator operator, String parameterText) Returns the evaluator instance for the given type and the defined parameterTextgetEvaluatorDefinition(String evaluatorId) Returns the evaluator definition for the given evaluator ID or null if no one was foundgetEvaluatorDefinition(Operator operator) Returns the evaluator definition for the given operator or null if no one was foundkeySet()Return the set of registered keys.voidvoid
-
Constructor Details
-
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
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 Details
-
keySet
Return the set of registered keys.- Returns:
- a Set of Strings
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
addEvaluatorDefinition
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
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
Returns the evaluator definition for the given evaluator ID or null if no one was found- Parameters:
evaluatorId-- Returns:
-
getEvaluatorDefinition
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
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
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.
-