Class Evaluator

    • Constructor Summary

      Constructors 
      Constructor Description
      Evaluator​(Schema schema)
      Create.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String eval​(java.util.Map<java.lang.String,​java.lang.String> values, java.lang.String formula, java.lang.String type)
      Evaluate formula with supplied variables and values.
      boolean evalBoolean​(java.util.Map<java.lang.String,​java.lang.String> values, java.lang.String formula)
      Evaluate boolean formula with supplied variables and values.
      double evalDouble​(java.util.Map<java.lang.String,​java.lang.String> values, java.lang.String formula)
      Evaluate double formula with supplied variables and values.
      void forceVariables​(java.lang.String variables)
      Add variables to the list of used variables.
      boolean hasVariable​(java.lang.String var)
      Shows whether a variable exists.
      static double qdistance0​(double v1, double v2, double v3, double v4)  
      void setEvaluatorFunctions​(java.lang.String javaEF, java.lang.String bshEF)
      Set Java and BeanShell Evaluator Functions.
      void setVariable​(java.lang.String name)
      Declare variable.
      void setVariable​(java.lang.String name, double value)
      TBD
      void setVariable​(java.lang.String name, double[] values)
      TBD
      void setVariable​(java.lang.String name, java.lang.String value)
      Set variable.
      void setVariable​(java.lang.String name, java.lang.String[] values)
      Set array variable.
      void setVariables​(java.lang.String formula)
      Add variables to the list of used variables.
      java.lang.String[] variables()
      Give the array of used variables.
      protected java.lang.String varName​(java.lang.String fullName)
      Give variable name from the database name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setEvaluatorFunctions

        public void setEvaluatorFunctions​(java.lang.String javaEF,
                                          java.lang.String bshEF)
                                   throws LomikelException
        Set Java and BeanShell Evaluator Functions.
        Parameters:
        javaEF - The Java Evaluatior Functions class name. May be null.
        bshEF - The BeanShell Evaluatior Functions script name. May be null.
        Throws:
        CommonpException - If can't be set.
        LomikelException
      • evalBoolean

        public boolean evalBoolean​(java.util.Map<java.lang.String,​java.lang.String> values,
                                   java.lang.String formula)
                            throws LomikelException
        Evaluate boolean formula with supplied variables and values.
        Parameters:
        values - The names and values of variables.
        formula - The formula to be evaluated. It should use supplied variables, which will be filled with supplied values.
        Throws:
        LomikelException - If formula cannot be evaluated with supplied variables.
      • qdistance0

        public static double qdistance0​(double v1,
                                        double v2,
                                        double v3,
                                        double v4)
      • evalDouble

        public double evalDouble​(java.util.Map<java.lang.String,​java.lang.String> values,
                                 java.lang.String formula)
                          throws LomikelException
        Evaluate double formula with supplied variables and values.
        Parameters:
        values - The names and values of variables.
        formula - The formula to be evaluated. It should use supplied variables, which will be filled with supplied values.
        Throws:
        LomikelException - If formula cannot be evaluated with supplied variables.
      • eval

        public java.lang.String eval​(java.util.Map<java.lang.String,​java.lang.String> values,
                                     java.lang.String formula,
                                     java.lang.String type)
                              throws LomikelException
        Evaluate formula with supplied variables and values.
        Parameters:
        values - The names and values of variables.
        formula - The formula to be evaluated. It should use supplied variables, which will be filled with supplied values.
        type - The formula result type.
        Throws:
        LomikelException - If formula cannot be evaluated with supplied variables.
      • setVariable

        public void setVariable​(java.lang.String name)
        Declare variable. Set to 0.
        Parameters:
        name - The name of variables.
      • setVariable

        public void setVariable​(java.lang.String name,
                                java.lang.String value)
        Set variable.
        Parameters:
        name - The name of variables.
        value - The value of variables. Undefined types are considered double, unknown types are taken as string.
      • setVariable

        public void setVariable​(java.lang.String name,
                                double value)
        TBD
      • setVariable

        public void setVariable​(java.lang.String name,
                                java.lang.String[] values)
        Set array variable.
        Parameters:
        name - The name of variables.
        values - The values of variables. Undefined types are considered double, unknown types are taken as string.
      • setVariable

        public void setVariable​(java.lang.String name,
                                double[] values)
        TBD
      • variables

        public java.lang.String[] variables()
        Give the array of used variables.
        Returns:
        The array of used variables.
      • hasVariable

        public boolean hasVariable​(java.lang.String var)
        Shows whether a variable exists.
        Parameters:
        var - The name of a variable.
        Returns:
        Whether that variable exists.
      • setVariables

        public void setVariables​(java.lang.String formula)
        Add variables to the list of used variables. Only add variables available in Schema.
        Parameters:
        formula - The formula to be used for list of used variables.
      • forceVariables

        public void forceVariables​(java.lang.String variables)
        Add variables to the list of used variables. Add variables even if they are not available in Schema.
        Parameters:
        formula - The formula to be used for list of used variables.
      • varName

        protected java.lang.String varName​(java.lang.String fullName)
        Give variable name from the database name.
        Parameters:
        fullName - The fill name of the database column.
        Returns:
        The schema variable name.