aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2018-11-13 23:06:27 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2018-11-13 23:06:27 +0000
commitea8a75596cecfe3479b08847a163912a77382d7b (patch)
tree791e3f0bc5a5c63c0ceafda04113204f54cf10bc /src
parent276ed569105d5e0fda01055c4a449fd5e2b080f7 (diff)
downloadjackcess-ea8a75596cecfe3479b08847a163912a77382d7b.tar.gz
jackcess-ea8a75596cecfe3479b08847a163912a77382d7b.zip
share nchars impl
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1223 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java10
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java8
2 files changed, 8 insertions, 10 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 7a582d6..dcb2348 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java
@@ -551,13 +551,13 @@ public class DefaultFunctions
if(groupDigits) {
fmt.append("#,");
- appendNum(fmt, '#', numGroupDigits - 1);
+ DefaultTextFunctions.nchars(fmt, numGroupDigits - 1, '#');
}
fmt.append(incLeadDigit ? "0" : "#");
if(numDecDigits > 0) {
fmt.append(".");
- appendNum(fmt, '0', numDecDigits);
+ DefaultTextFunctions.nchars(fmt, numDecDigits, '0');
}
if(isPercent) {
@@ -597,10 +597,4 @@ public class DefaultFunctions
throw new IllegalStateException("Duplicate function " + fname);
}
}
-
- private static void appendNum(StringBuilder sb, char c, int num) {
- for(int i = 0; i < num; ++i) {
- sb.append(c);
- }
- }
}
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java
index 5291c3c..f8c4a88 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java
@@ -428,12 +428,16 @@ public class DefaultTextFunctions
private static String nchars(int num, char c) {
StringBuilder sb = new StringBuilder(num);
+ nchars(sb, num, c);
+ return sb.toString();
+ }
+
+ static void nchars(StringBuilder sb, int num, char c) {
for(int i = 0; i < num; ++i) {
sb.append(c);
}
- return sb.toString();
}
-
+
private static String trim(String str, boolean doLeft, boolean doRight) {
int start = 0;
int end = str.length();