From a2a57f1c3ca0efa319270ad3bcac00d269f611dc Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Thu, 8 Nov 2018 21:23:48 +0000 Subject: add more numeric config git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1218 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../jackcess/impl/expr/DefaultFunctions.java | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/healthmarketscience/jackcess/impl/expr') 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))); } -- cgit v1.2.3