Class JexlThreadedArithmetic


  • public class JexlThreadedArithmetic
    extends JexlArithmetic
    A derived arithmetic that allows different threads to operate with different strict/lenient/math modes using the same JexlEngine.
    Since:
    2.1
    • Constructor Detail

      • JexlThreadedArithmetic

        public JexlThreadedArithmetic​(boolean lenient)
        Standard ctor.
        Parameters:
        lenient - lenient versus strict evaluation flag
      • JexlThreadedArithmetic

        public JexlThreadedArithmetic​(boolean lenient,
                                      java.math.MathContext bigdContext,
                                      int bigdScale)
        Creates a JexlThreadedArithmetic instance.
        Parameters:
        lenient - whether this arithmetic is lenient or strict
        bigdContext - the math context instance to use for +,-,/,*,% operations on big decimals.
        bigdScale - the scale used for big decimals.
    • Method Detail

      • setLenient

        public static void setLenient​(java.lang.Boolean flag)
        Overrides the default behavior and sets whether this JexlArithmetic instance triggers errors during evaluation when null is used as an operand for the current thread.

        It is advised to protect calls by either calling JexlThreadedArithmetic.setLenient explicitly before evaluation or add a try/finally clause resetting the flag to avoid unexpected reuse of the lenient flag value through thread pools side-effects.

        Parameters:
        flag - true means no JexlException will occur, false allows them, null reverts to default behavior
        See Also:
        JexlEngine.setSilent(boolean), JexlEngine.setDebug(boolean)
      • setMathScale

        public static void setMathScale​(java.lang.Integer scale)
        Sets the math scale.

        The goal and constraints are the same than for setLenient.

        Parameters:
        scale - the scale
      • setMathContext

        public static void setMathContext​(java.math.MathContext mc)
        Sets the math context.

        The goal and constraints are the same than for setLenient.

        Parameters:
        mc - the math context
      • isLenient

        public boolean isLenient()
        Checks whether this JexlArithmetic instance triggers errors during evaluation when null is used as an operand.
        Overrides:
        isLenient in class JexlArithmetic
        Returns:
        true if lenient, false if strict
      • getMathScale

        public int getMathScale()
        Description copied from class: JexlArithmetic
        The BigDecimal scale used for comparison and coercion operations.
        Overrides:
        getMathScale in class JexlArithmetic
        Returns:
        the scale
      • getMathContext

        public java.math.MathContext getMathContext()
        Description copied from class: JexlArithmetic
        The MathContext instance used for +,-,/,*,% operations on big decimals.
        Overrides:
        getMathContext in class JexlArithmetic
        Returns:
        the math context