diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2018-11-08 21:23:48 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2018-11-08 21:23:48 +0000 |
commit | a2a57f1c3ca0efa319270ad3bcac00d269f611dc (patch) | |
tree | 57fcf0bf9fadcfe2cd9f495fda5833a05dc8e379 /src/main/java/com/healthmarketscience/jackcess/impl/expr | |
parent | 47de466737598cfdf8d8ec7bc11f624df3fed283 (diff) | |
download | jackcess-a2a57f1c3ca0efa319270ad3bcac00d269f611dc.tar.gz jackcess-a2a57f1c3ca0efa319270ad3bcac00d269f611dc.zip |
add more numeric config
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1218 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/main/java/com/healthmarketscience/jackcess/impl/expr')
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java index 687edf9..2f71718 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java @@ -27,6 +27,7 @@ import com.healthmarketscience.jackcess.expr.EvalContext; import com.healthmarketscience.jackcess.expr.EvalException; import com.healthmarketscience.jackcess.expr.Function; import com.healthmarketscience.jackcess.expr.FunctionLookup; +import com.healthmarketscience.jackcess.expr.NumericConfig; import com.healthmarketscience.jackcess.expr.Value; import com.healthmarketscience.jackcess.impl.DatabaseImpl; import com.healthmarketscience.jackcess.impl.NumberFormatter; @@ -287,10 +288,16 @@ public class DefaultFunctions return ValueSupport.NULL_VAL; } - int numDecDigits = getOptionalIntParam(ctx, params, 1, 2, -1); - boolean incLeadDigit = getOptionalTriStateBoolean(ctx, params, 2, true); - boolean negParens = getOptionalTriStateBoolean(ctx, params, 3, false); - boolean groupDigits = getOptionalTriStateBoolean(ctx, params, 4, true); + NumericConfig cfg = ctx.getNumericConfig(); + int numDecDigits = getOptionalIntParam( + ctx, params, 1, cfg.getNumDecimalDigits(), -1); + boolean incLeadDigit = getOptionalTriStateBoolean( + ctx, params, 2, cfg.includeLeadingDigit()); + boolean negParens = getOptionalTriStateBoolean( + ctx, params, 3, cfg.useParensForNegatives()); + int numGroupDigits = cfg.getNumGroupingDigits(); + boolean groupDigits = getOptionalTriStateBoolean( + ctx, params, 4, (numGroupDigits > 0)); StringBuilder fmt = new StringBuilder(); @@ -308,8 +315,14 @@ public class DefaultFunctions // Note, DecimalFormat rounding mode uses HALF_EVEN by default DecimalFormat df = new DecimalFormat( - fmt.toString(), ctx.getNumericConfig().getDecimalFormatSymbols()); - df.setGroupingUsed(groupDigits); + fmt.toString(), cfg.getDecimalFormatSymbols()); + if(groupDigits) { + df.setGroupingUsed(true); + df.setGroupingSize(numGroupDigits); + } else { + df.setGroupingUsed(false); + df.setGroupingSize(numGroupDigits); + } return ValueSupport.toValue(df.format(param1.getAsBigDecimal(ctx))); } |