Class EvaluatorRegistry

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable

    public class EvaluatorRegistry
    extends java.lang.Object
    implements java.io.Externalizable
    A registry class for all available evaluators
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      EvaluatorRegistry()
      Default constructor.
      EvaluatorRegistry​(java.lang.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​(java.lang.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.
      org.drools.base.rule.accessor.Evaluator getEvaluator​(org.drools.base.base.ValueType type, java.lang.String operatorId, boolean isNegated, java.lang.String parameterText)
      Returns the evaluator instance for the given type and the defined parameterText
      org.drools.base.rule.accessor.Evaluator getEvaluator​(org.drools.base.base.ValueType type, org.drools.drl.parser.impl.Operator operator)
      Returns the evaluator instance for the given type and the defined parameterText
      org.drools.base.rule.accessor.Evaluator getEvaluator​(org.drools.base.base.ValueType type, org.drools.drl.parser.impl.Operator operator, java.lang.String parameterText)
      Returns the evaluator instance for the given type and the defined parameterText
      EvaluatorDefinition getEvaluatorDefinition​(java.lang.String evaluatorId)
      Returns the evaluator definition for the given evaluator ID or null if no one was found
      EvaluatorDefinition getEvaluatorDefinition​(org.drools.drl.parser.impl.Operator operator)
      Returns the evaluator definition for the given operator or null if no one was found
      java.util.Set<java.lang.String> keySet()
      Return the set of registered keys.
      void readExternal​(java.io.ObjectInput in)  
      void writeExternal​(java.io.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​(java.lang.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 java.util.Set<java.lang.String> keySet()
        Return the set of registered keys.
        Returns:
        a Set of Strings
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • addEvaluatorDefinition

        public void addEvaluatorDefinition​(java.lang.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​(java.lang.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​(org.drools.drl.parser.impl.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 org.drools.base.rule.accessor.Evaluator getEvaluator​(org.drools.base.base.ValueType type,
                                                                    java.lang.String operatorId,
                                                                    boolean isNegated,
                                                                    java.lang.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 org.drools.base.rule.accessor.Evaluator getEvaluator​(org.drools.base.base.ValueType type,
                                                                    org.drools.drl.parser.impl.Operator operator,
                                                                    java.lang.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 org.drools.base.rule.accessor.Evaluator getEvaluator​(org.drools.base.base.ValueType type,
                                                                    org.drools.drl.parser.impl.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.