This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 2d3e7da96a StringFormatter class
2d3e7da96a is described below
commit 2d3e7da96abe46ce2590b84731f82e8bedc216ce
Author: James Bognar <[email protected]>
AuthorDate: Fri Nov 28 08:07:37 2025 -0500
StringFormatter class
---
.../src/main/java/org/apache/juneau/common/utils/StringFormat.java | 6 ++++++
.../src/main/java/org/apache/juneau/common/utils/Utils.java | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/StringFormat.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/StringFormat.java
index 834ea88678..284e04a08d 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/StringFormat.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/StringFormat.java
@@ -299,6 +299,12 @@ public final class StringFormat {
@Override
void append(StringBuilder sb, Object[] args, Locale locale) {
+ // %n is special - it doesn't consume an argument, just
outputs a line separator
+ if (format == 'n') {
+ sb.append(System.lineSeparator());
+ return;
+ }
+
// String.format() throws
MissingFormatArgumentException when argument is missing
if (args == null || index >= args.length || index < 0) {
throw new
MissingFormatArgumentException(content);
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/Utils.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/Utils.java
index 71eee98710..f07312fb5c 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/Utils.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/Utils.java
@@ -298,7 +298,7 @@ public class Utils {
public static String mf(String pattern, Object...args) {
if (args.length == 0)
return pattern;
- return MessageFormat.format(pattern, args);
+ return StringFormat.format(pattern, args);
}
/**