Enum Options

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Options>

    public enum Options
    extends java.lang.Enum<Options>
    Aviator Evaluator Configuration options.
    • Enum Constant Detail

      • MATH_CONTEXT

        public static final Options MATH_CONTEXT
        Math context for decimal, default is MathContext.DECIMAL128
        See Also:
        MathContext
      • ALWAYS_PARSE_FLOATING_POINT_NUMBER_INTO_DECIMAL

        public static final Options ALWAYS_PARSE_FLOATING_POINT_NUMBER_INTO_DECIMAL
        When true, always parsing floating-point number into BigDecial, default is false.It replaces #ALWAYS_USE_DOUBLE_AS_DECIMAL option.
      • ALWAYS_PARSE_INTEGRAL_NUMBER_INTO_DECIMAL

        public static final Options ALWAYS_PARSE_INTEGRAL_NUMBER_INTO_DECIMAL
        When true, always parsing integral number into BigDecial, default is false.
        Since:
        4.2.0
      • TRACE_EVAL

        public static final Options TRACE_EVAL
        Whether to trace expression evaluating procedure, default is false.
      • PUT_CAPTURING_GROUPS_INTO_ENV

        public static final Options PUT_CAPTURING_GROUPS_INTO_ENV
        Whether to put capturing groups into passed-in env map when regular-expression pattern matches, default is true.If you don't want the groups, you can turn it off to get better performance in regular-expression pattern matching.
      • CAPTURE_FUNCTION_ARGS

        public static final Options CAPTURE_FUNCTION_ARGS
        Whether to capture the function arguments(at invocation) into env, the argument list will be stored in __args__ variable in env valid for function body. Default is false(disabled).
        Since:
        4.2.0
      • ENABLE_PROPERTY_SYNTAX_SUGAR

        public static final Options ENABLE_PROPERTY_SYNTAX_SUGAR
        Enable property access syntax sugar, use common-beantuils to access property such as "a.b.c" etc. Default value is true, enable this behaviour.
      • NIL_WHEN_PROPERTY_NOT_FOUND

        public static final Options NIL_WHEN_PROPERTY_NOT_FOUND
        When enable property access syntax sugar, returns nil if the property value is not found or throws exception.Default value is false,disabled this behaviour.
      • USE_USER_ENV_AS_TOP_ENV_DIRECTLY

        public static final Options USE_USER_ENV_AS_TOP_ENV_DIRECTLY
        Whether to use user passed-in env as top level environment directly.If true, it may make side effects(such as assignment) to user passed-in env., otherwise aviator will wrap the user passed-in env and does not make any side effects into it. Default is true.
      • MAX_LOOP_COUNT

        public static final Options MAX_LOOP_COUNT
        Max loop count to prevent too much CPU consumption. If it's value is zero or negative, it means no limitation on loop count.Default is zero.
      • FEATURE_SET

        public static final Options FEATURE_SET
        AviatorScript engine feature set, see Feature
        Since:
        5.
      • ALLOWED_CLASS_SET

        public static final Options ALLOWED_CLASS_SET
        Allowed java class set in new statement and class's static method(fields) etc. It's null by default. Null ALLOWED_CLASS_SET and ASSIGNABLE_ALLOWED_CLASS_SET means all classes are allowed (default); Empty ALLOWED_CLASS_SET or ASSIGNABLE_ALLOWED_CLASS_SET means forbidding all classes.
        Since:
        5.2.2
      • ASSIGNABLE_ALLOWED_CLASS_SET

        public static final Options ASSIGNABLE_ALLOWED_CLASS_SET
        Allowed assignable java class set in new statement and class's static method(fields) etc. It's null by default. Null ALLOWED_CLASS_SET and ASSIGNABLE_ALLOWED_CLASS_SET means all classes are allowed (default); Empty ALLOWED_CLASS_SET or ASSIGNABLE_ALLOWED_CLASS_SET means forbidding all classes.
      • EVAL_MODE

        public static final Options EVAL_MODE
        Script engine evaluate mode, default is ASM mode.
      • SERIALIZABLE

        public static final Options SERIALIZABLE
        Whether the compiled expression is serializable. If true, the compiled expression will implement jva.io.Serializable and can be encoded/decoded by java serialization.
      • EVAL_TIMEOUT_MS

        public static final Options EVAL_TIMEOUT_MS
        The expression execution timeout value in milliseconds. If the execution time exceeds this value, it will throw a TimeoutException. A value of zero or less indicates no timeout limitation, the default value is zero (no limitation).

        Note: this limitation is not strict and may hurt performance, it is only checked before:
        • Operator evaluating, such as add, sub etc.
        • Jumping in branches, such as loop and conditional clauses etc.
        • Function invocation
        So if the expression doesn't contains these clauses or trapped into a function invocation, the behavior may be not expected. Try its best, but no promises.
        Since:
        5.4.2
    • Constructor Detail

      • Options

        private Options()
    • Method Detail

      • values

        public static Options[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Options c : Options.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Options valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • intoObject

        public java.lang.Object intoObject​(Options.Value val)
        Cast value union into java object.
        Parameters:
        val -
        Returns:
      • intoValue

        public Options.Value intoValue​(java.lang.Object val)
        Cast java object into value union.
        Parameters:
        val -
        Returns:
      • isValidValue

        public boolean isValidValue​(java.lang.Object val)
      • getDefaultValue

        public java.lang.Object getDefaultValue()
        Returns the default value of option.
        Returns:
      • getDefaultValueObject

        public Options.Value getDefaultValueObject()
        Returns the default value object of option.
        Returns:
      • getDefaultEvalMode

        public static Options.Value getDefaultEvalMode()
      • getSystemEvalMode

        private static Options.Value getSystemEvalMode()