Top Description Inners Fields Constructors Methods
org.apache.commons.jexl2

public Class JexlThreadedArithmetic

extends JexlArithmetic
Class Inheritance
Imports
java.math.MathContext

A derived arithmetic that allows different threads to operate with different strict/lenient/math modes using the same JexlEngine.
Since
2.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
JexlThreadedArithmetic.Features

Holds the threaded version of some arithmetic features.

Field Summary

Modifier and TypeField and Description
pack-priv static final ThreadLocal<JexlThreadedArithmetic.Features>
FEATURES

Whether this JexlArithmetic instance behaves in strict or lenient mode for this thread.

Inherited from org.apache.commons.jexl2.JexlArithmetic:
BIGD_DOUBLE_MAX_VALUEBIGD_DOUBLE_MIN_VALUEBIGD_SCALEBIGI_LONG_MAX_VALUEBIGI_LONG_MIN_VALUEmathContextmathScale

Constructor Summary

AccessConstructor and Description
public
JexlThreadedArithmetic(boolean
lenient versus strict evaluation flag
lenient
)

Standard ctor.

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

Creates a JexlThreadedArithmetic instance.

Method Summary

Modifier and TypeMethod and Description
public MathContext
getMathContext()

Overrides org.apache.commons.jexl2.JexlArithmetic.getMathContext.

The MathContext instance used for +,-,/,*,% operations on big decimals.
public int
getMathScale()

Overrides org.apache.commons.jexl2.JexlArithmetic.getMathScale.

The BigDecimal scale used for comparison and coercion operations.
public boolean
isLenient()

Overrides org.apache.commons.jexl2.JexlArithmetic.isLenient.

Checks whether this JexlArithmetic instance triggers errors during evaluation when null is used as an operand.
public static void
setLenient(Boolean
true means no JexlException will occur, false allows them, null reverts to default behavior
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.

public static void
setMathContext(MathContext
the math context
mc
)

Sets the math context.

public static void
setMathScale(Integer
the scale
scale
)

Sets the math scale.

Inherited from org.apache.commons.jexl2.JexlArithmetic:
addbitwiseAndbitwiseComplementbitwiseOrbitwiseXorcomparecontrolNullNullOperandscontrolNullOperanddivideequalsgreaterThangreaterThanOrEqualisFloatingPointisFloatingPointNumberisFloatingPointTypeisNumberablelessThanlessThanOrEqualmatchesmodmultiplynarrownarrowAcceptnarrowArgumentsnarrowArrayTypenarrowBigDecimalnarrowBigIntegernarrowNumbernegateroundBigDecimalsetLenientsubtracttoBigDecimaltoBigIntegertoBooleantoDoubletoIntegertoLongtoString

Field Detail

FEATURESback to summary
pack-priv static final ThreadLocal<JexlThreadedArithmetic.Features> FEATURES

Whether this JexlArithmetic instance behaves in strict or lenient mode for this thread.

Constructor Detail

JexlThreadedArithmeticback to summary
public JexlThreadedArithmetic(boolean lenient)

Standard ctor.

Parameters
lenient:boolean

lenient versus strict evaluation flag

JexlThreadedArithmeticback to summary
public JexlThreadedArithmetic(boolean lenient, MathContext bigdContext, int bigdScale)

Creates a JexlThreadedArithmetic instance.

Parameters
lenient:boolean

whether this arithmetic is lenient or strict

bigdContext:MathContext

the math context instance to use for +,-,/,*,% operations on big decimals.

bigdScale:int

the scale used for big decimals.

Method Detail

getMathContextback to summary
public MathContext getMathContext()

Overrides org.apache.commons.jexl2.JexlArithmetic.getMathContext.

Doc from org.apache.commons.jexl2.JexlArithmetic.getMathContext.

The MathContext instance used for +,-,/,*,% operations on big decimals.

Returns:MathContext

the math context

Annotations
@Override
getMathScaleback to summary
public int getMathScale()

Overrides org.apache.commons.jexl2.JexlArithmetic.getMathScale.

Doc from org.apache.commons.jexl2.JexlArithmetic.getMathScale.

The BigDecimal scale used for comparison and coercion operations.

Returns:int

the scale

Annotations
@Override
isLenientback to summary
public boolean isLenient()

Overrides org.apache.commons.jexl2.JexlArithmetic.isLenient.

Doc from org.apache.commons.jexl2.JexlArithmetic.isLenient.

Checks whether this JexlArithmetic instance triggers errors during evaluation when null is used as an operand.

Returns:boolean

true if lenient, false if strict

Annotations
@Override
setLenientback to summary
public static void setLenient(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:Boolean

true means no JexlException will occur, false allows them, null reverts to default behavior

See Also
JexlEngine#setSilent, JexlEngine#setDebug
setMathContextback to summary
public static void setMathContext(MathContext mc)

Sets the math context.

The goal and constraints are the same than for setLenient.

Parameters
mc:MathContext

the math context

setMathScaleback to summary
public static void setMathScale(Integer scale)

Sets the math scale.

The goal and constraints are the same than for setLenient.

Parameters
scale:Integer

the scale

org.apache.commons.jexl2 back to summary

pack-priv Class JexlThreadedArithmetic.Features

extends Object
Class Inheritance

Holds the threaded version of some arithmetic features.

Field Summary

Modifier and TypeField and Description
private Boolean
lenient

Whether this JexlArithmetic instance behaves in strict or lenient mode.

private MathContext
mathContext

The big decimal math context.

private Integer
mathScale

The big decimal scale.

Constructor Summary

AccessConstructor and Description
pack-priv
Features()

Default ctor.

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lenientback to summary
private Boolean lenient

Whether this JexlArithmetic instance behaves in strict or lenient mode.

mathContextback to summary
private MathContext mathContext

The big decimal math context.

mathScaleback to summary
private Integer mathScale

The big decimal scale.

Constructor Detail

Featuresback to summary
pack-priv Features()

Default ctor.