[
https://issues.apache.org/jira/browse/JEXL-203?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15370511#comment-15370511
]
Henri Biestro edited comment on JEXL-203 at 7/11/16 11:52 AM:
--------------------------------------------------------------
Override the options(...) method in your JexlArithmetic derived class is the
current way of dealing with this. Not ideal but allows to solve your issue
about arithmetic creation.
{code} public JexlArithmetic options(JexlEngine.Options options) {
boolean ostrict = options.isStrictArithmetic() == null
? isStrict()
: options.isStrictArithmetic();
MathContext bigdContext = options.getArithmeticMathContext();
if (bigdContext == null) {
bigdContext = getMathContext();
}
int bigdScale = options.getArithmeticMathScale();
if (bigdScale == Integer.MIN_VALUE) {
bigdScale = getMathScale();
}
if ((ostrict != isStrict())
|| bigdScale != getMathScale()
|| bigdContext != getMathContext()) {
return new MyJexlArithmetic(ostrict, bigdContext, bigdScale);
} else {
return this;
}
}
{code}
was (Author: henrib):
Override the options(...) method in your JexlArithmetic derived class is the
current way of dealing with this.
{code} public JexlArithmetic options(JexlEngine.Options options) {
boolean ostrict = options.isStrictArithmetic() == null
? isStrict()
: options.isStrictArithmetic();
MathContext bigdContext = options.getArithmeticMathContext();
if (bigdContext == null) {
bigdContext = getMathContext();
}
int bigdScale = options.getArithmeticMathScale();
if (bigdScale == Integer.MIN_VALUE) {
bigdScale = getMathScale();
}
if ((ostrict != isStrict())
|| bigdScale != getMathScale()
|| bigdContext != getMathContext()) {
return new MyJexlArithmetic(ostrict, bigdContext, bigdScale);
} else {
return this;
}
}
{code}
> JexlArithmetic.options() diverts Interpreter to use default implementation of
> JexlArithmetic instead of custom one
> ------------------------------------------------------------------------------------------------------------------
>
> Key: JEXL-203
> URL: https://issues.apache.org/jira/browse/JEXL-203
> Project: Commons JEXL
> Issue Type: Bug
> Reporter: Dmitri Blinov
> Assignee: Henri Biestro
> Fix For: 3.0.1
>
>
> If JexlContext implements JexlEngine.Options and it provides values for
> strictness, scale and MathContext that are different from what was specified
> during creation of JexlArithmetics, then instance of wrong JexlArithmetic
> class is created instead of custom class previously used. Apparently the
> JexlArithmetic.options() method could then be overloaded in custom class, but
> I don't like the idea of copying all that code from version to version, so
> may be more robust solution could be found to this.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)