Class EvaluationValue

  • All Implemented Interfaces:
    java.lang.Comparable<EvaluationValue>

    public class EvaluationValue
    extends java.lang.Object
    implements java.lang.Comparable<EvaluationValue>
    The representation of the final or intermediate evaluation result value. The representation consists of a data type and data value. Depending on the type, the value will be stored in a corresponding object type.
    • Constructor Detail

      • EvaluationValue

        public EvaluationValue​(java.lang.Object value)
        Creates a new evaluation value by taking a good guess on the provided Java class and converting it to one of the supported types.
        Input typeStorage Type
        BigDecimalBigDecimal
        Long, longBigDecimal
        Integer, intBigDecimal
        Short, shortBigDecimal
        Byte, byteBigDecimal
        Double, doubleBigDecimal *
        Float, floatBigDecimal *
        CharSequence , StringString
        Boolean, booleanBoolean
        ASTNodeASTNode
        List<?>List<EvaluationValue> - each entry will be converted
        Map<?,?>Map<String><EvaluationValue> - each entry will be converted.
        * Be careful with conversion problems when using float or double, which are fractional numbers. A (float)0.1 is e.g. converted to 0.10000000149011612
        Parameters:
        value - One of the supported data types.
        Throws:
        java.lang.IllegalArgumentException - if the data type can't be mapped.
      • EvaluationValue

        public EvaluationValue​(double value,
                               java.math.MathContext mathContext)
    • Method Detail

      • numberOfString

        public static EvaluationValue numberOfString​(java.lang.String value,
                                                     java.math.MathContext mathContext)
        Creates a EvaluationValue.DataType.NUMBER value from a String.
        Parameters:
        value - The String value.
        mathContext - The math context to use for creation of the BigDecimal storage.
      • getNumberValue

        public java.math.BigDecimal getNumberValue()
        Gets a BigDecimal representation of the value. If possible and needed, a conversion will be made.
        • Boolean true will return a BigDecimal.ONE, else BigDecimal.ZERO.
        Returns:
        The BigDecimal representation of the value, or BigDecimal.ZERO if conversion is not possible.
      • getStringValue

        public java.lang.String getStringValue()
        Gets a String representation of the value. If possible and needed, a conversion will be made.
        • Number values will be returned as BigDecimal.toPlainString().
        • The Object.toString() will be used in all other cases.
        Returns:
        The String representation of the value.
      • getBooleanValue

        public java.lang.Boolean getBooleanValue()
        Gets a Boolean representation of the value. If possible and needed, a conversion will be made.
        • Any non-zero number value will return true.
        • Any string with the value "true" (case ignored) will return true.
        Returns:
        The Boolean representation of the value.
      • getArrayValue

        public java.util.List<EvaluationValue> getArrayValue()
        Gets a List representation of the value.
        Returns:
        The List representation of the value or an empty list, if no conversion is possible.
      • getStructureValue

        public java.util.Map<java.lang.String,​EvaluationValue> getStructureValue()
        Gets a Map representation of the value.
        Returns:
        The Map representation of the value or an empty list, if no conversion is possible.