org.licas.data

## Class EvaluateData

- java.lang.Object
- - org.licas.data.EvaluateData

-     public class EvaluateData
      extends java.lang.Object

  Provides one implementation of an evaluation function. This class can be used to interpret a `DataQueryModel` object and try to make the appropriate evaluation call. The evaluation can be on a single object, or a comparison between two objects. The DataQuery should include the data type and also the method to be invoked. If the invocation is on a single object, then only the dataset is required. If it is a comparison then both datasets and the operator as well are required.
  Author:
    Kieran Greer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected DataQueryModel` | `dataInfo` Parameters for constructing the data evaluator
    `protected org.ai_heuristic.def.EvaluateMathDef` | `mathCompare` For comparisons of simple java types
    `protected org.ai_heuristic.def.FunctionDef` | `mathDistance` For distance measurements between simple java types

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EvaluateData(DataQueryModel theDataInfo)` Create a new instance of EvaluateData.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `abs(java.lang.String valueType, java.lang.Object value1)` Get the absolute value of the value passed in.
    `java.lang.Object` | `add(java.lang.String valueType, java.lang.Object value1, java.lang.Object value2)` Add the two objects together and return.
    `java.lang.Object` | `divide(java.lang.String valueType, java.lang.Object value1, java.lang.Object value2)` Divide the first value by the second and return the result.
    `java.lang.Object` | `evaluate()` Evaluate using the data settings of `dataInfo`.
    `org.ai_heuristic.eval.metric.ReplySet` | `evaluate(org.ai_heuristic.eval.metric.MetricDataset toEvaluate)` Evaluate the data object directly.
    `org.ai_heuristic.def.EvaluateMathDef` | `getMathCompare()` Return the comparison function if one can be created from the `dataInfo`.
    `boolean` | `isCompareFunction()` Return true if the data info relates to a comparison function, not a distance one.
    `boolean` | `mathCompare(java.lang.String valueType, java.lang.Object value1, java.lang.Object value2, java.lang.String operator)` Evaluate the expression.
    `java.lang.Object` | `multiply(java.lang.String valueType, java.lang.Object value1, java.lang.Object value2)` Multiply the first value by the second and return the result.
    `java.lang.Object` | `numEquiv(java.lang.String valueType, int numerical)` Get the equivalent of the integer numerical value for the data type.
    `java.lang.Object` | `subtract(java.lang.String valueType, java.lang.Object value1, java.lang.Object value2)` Subtract the second value from the first and return the result.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### mathDistance

          protected org.ai_heuristic.def.FunctionDef mathDistance

      For distance measurements between simple java types

    - #### mathCompare

          protected org.ai_heuristic.def.EvaluateMathDef mathCompare

      For comparisons of simple java types

    - #### dataInfo

          protected DataQueryModel dataInfo

      Parameters for constructing the data evaluator

  - ### Constructor Detail

    - #### EvaluateData

          public EvaluateData(DataQueryModel theDataInfo)

      Create a new instance of EvaluateData.
      Parameters:
        `theDataInfo` - defines what evaluators are used.

  - ### Method Detail

    - #### isCompareFunction

          public boolean isCompareFunction()

      Return true if the data info relates to a comparison function, not a distance one.
      Returns:
        true if implements `EvaluateMathDef` and not `FunctionMetricDef`.

    - #### evaluate

          public java.lang.Object evaluate()
                                    throws java.lang.Exception

      Evaluate using the data settings of `dataInfo`. This method performs a comparison calculation, where a comparison method compares the dataset with the compareWith dataset in the `ComparisonQueryModel` dataInfo object.
      Returns:
        the evaluation result.
      Throws:
        `java.lang.Exception` - any error.

    - #### evaluate

          public org.ai_heuristic.eval.metric.ReplySet evaluate(org.ai_heuristic.eval.metric.MetricDataset toEvaluate)
                                                         throws java.lang.Exception

      Evaluate the data object directly. Any data values or types must have already have been set in the evaluator and/or data object.
      Parameters:
        `toEvaluate` - the object to evaluate.
      Returns:
        the evaluation result, probably a value, not true or false.
      Throws:
        `java.lang.Exception` - any error.

    - #### mathCompare

          public boolean mathCompare(java.lang.String valueType,
                                     java.lang.Object value1,
                                     java.lang.Object value2,
                                     java.lang.String operator)
                              throws java.lang.Exception

      Evaluate the expression.
      Parameters:
        `valueType` - the type of the value. This is the object type class name.
        `value1` - first value.
        `value2` - second value.
        `operator` - comparison operator - greater than (GT), less than (LT), etc. These are evaluated using a SimpleEvaluate object from the heuristic package.
      Returns:
        true if comparison is true and false otherwise.
      Throws:
        `java.lang.Exception` - any error.

    - #### add

          public java.lang.Object add(java.lang.String valueType,
                                      java.lang.Object value1,
                                      java.lang.Object value2)
                               throws java.lang.Exception

      Add the two objects together and return.
      Parameters:
        `valueType` - the type of the value.
        `value1` - first value.
        `value2` - second value.
      Returns:
        the two values added together. Any error returns `null`.
      Throws:
        `java.lang.Exception` - any error.

    - #### subtract

          public java.lang.Object subtract(java.lang.String valueType,
                                           java.lang.Object value1,
                                           java.lang.Object value2)
                                    throws java.lang.Exception

      Subtract the second value from the first and return the result.
      Parameters:
        `valueType` - the type of the value.
        `value1` - first value.
        `value2` - second value.
      Returns:
        the second value subtracted from the first. Any error returns `null`.
      Throws:
        `java.lang.Exception` - any error.

    - #### multiply

          public java.lang.Object multiply(java.lang.String valueType,
                                           java.lang.Object value1,
                                           java.lang.Object value2)
                                    throws java.lang.Exception

      Multiply the first value by the second and return the result.
      Parameters:
        `valueType` - the type of the value.
        `value1` - first value.
        `value2` - second value.
      Returns:
        the first value multiplied by the second. Any error returns `null`.
      Throws:
        `java.lang.Exception` - any error.

    - #### divide

          public java.lang.Object divide(java.lang.String valueType,
                                         java.lang.Object value1,
                                         java.lang.Object value2)
                                  throws java.lang.Exception

      Divide the first value by the second and return the result.
      Parameters:
        `valueType` - the type of the value.
        `value1` - first value.
        `value2` - second value.
      Returns:
        the first value divided by the second. Any error returns `null`.
      Throws:
        `java.lang.Exception` - any error.

    - #### abs

          public java.lang.Object abs(java.lang.String valueType,
                                      java.lang.Object value1)
                               throws java.lang.Exception

      Get the absolute value of the value passed in.
      Parameters:
        `valueType` - the type of the value.
        `value1` - first value.
      Returns:
        the absolute (positive) value.
      Throws:
        `java.lang.Exception` - any error.

    - #### numEquiv

          public java.lang.Object numEquiv(java.lang.String valueType,
                                           int numerical)
                                    throws java.lang.Exception

      Get the equivalent of the integer numerical value for the data type.
      Parameters:
        `valueType` - the type of the value.
        `numerical` - an integer numerical value.
      Returns:
        the equivalent of the numerical value for the data type.
      Throws:
        `java.lang.Exception` - any error.

    - #### getMathCompare

          public org.ai_heuristic.def.EvaluateMathDef getMathCompare()
                                                              throws java.lang.Exception

      Return the comparison function if one can be created from the `dataInfo`.
      Returns:
        the mathCompare function, or `null` if one cannot be created.
      Throws:
        `java.lang.Exception` - any error.