Class EvaluatorRegistry

    • 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
      • 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.