This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
The following commit(s) were added to refs/heads/master by this push:
new e1301076 Sort members.
e1301076 is described below
commit e1301076d3809440faa8d0b1d60ee03cd37cab17
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Jun 12 02:13:24 2026 +0000
Sort members.
---
.../org/apache/commons/text/StringSubstitutor.java | 40 +++++++++++-----------
.../commons/text/ExtendedMessageFormatTest.java | 10 +++---
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/src/main/java/org/apache/commons/text/StringSubstitutor.java
b/src/main/java/org/apache/commons/text/StringSubstitutor.java
index 2d909080..3263ef07 100644
--- a/src/main/java/org/apache/commons/text/StringSubstitutor.java
+++ b/src/main/java/org/apache/commons/text/StringSubstitutor.java
@@ -731,6 +731,26 @@ public class StringSubstitutor {
return suffixMatcher;
}
+ /**
+ * Checks whether the specified buffer contains a variable suffix after
the given position.
+ *
+ * @param builder the string builder to check, not null.
+ * @param pos the position to start checking from.
+ * @param offset the start offset within the builder, must be valid.
+ * @param bufEnd the end offset within the builder, must be valid.
+ * @param suffixMatcher the suffix matcher to use, not null.
+ * @return true if a suffix is found after the given position.
+ */
+ private boolean hasLaterSuffix(final TextStringBuilder builder, int pos,
final int offset, final int bufEnd, final StringMatcher suffixMatcher) {
+ while (pos < bufEnd) {
+ if (suffixMatcher.isMatch(builder, pos, offset, bufEnd) != 0) {
+ return true;
+ }
+ pos++;
+ }
+ return false;
+ }
+
/**
* Returns a flag whether substitution is disabled in variable values.If
set to <strong>true</strong>, the values of variables
* can contain other variables will not be processed and substituted
original variable is evaluated, e.g.
@@ -1535,26 +1555,6 @@ public class StringSubstitutor {
return new Result(altered, lengthChange);
}
- /**
- * Checks whether the specified buffer contains a variable suffix after
the given position.
- *
- * @param builder the string builder to check, not null.
- * @param pos the position to start checking from.
- * @param offset the start offset within the builder, must be valid.
- * @param bufEnd the end offset within the builder, must be valid.
- * @param suffixMatcher the suffix matcher to use, not null.
- * @return true if a suffix is found after the given position.
- */
- private boolean hasLaterSuffix(final TextStringBuilder builder, int pos,
final int offset, final int bufEnd, final StringMatcher suffixMatcher) {
- while (pos < bufEnd) {
- if (suffixMatcher.isMatch(builder, pos, offset, bufEnd) != 0) {
- return true;
- }
- pos++;
- }
- return false;
- }
-
/**
* Returns a string representation of the object.
*
diff --git
a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
index 530b0ccb..855207ed 100644
--- a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
+++ b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
@@ -231,6 +231,11 @@ class ExtendedMessageFormatTest {
registry.put("upper", UpperCaseFormat.FACTORY);
}
+ @Test
+ void testArgumentIndexTrailingWhitespaceAtEnd() {
+ assertThrowsExactly(IllegalArgumentException.class, () -> new
ExtendedMessageFormat("{0 ", new HashMap<>()));
+ }
+
/**
* Test the built in choice format.
*/
@@ -474,11 +479,6 @@ class ExtendedMessageFormatTest {
assertThrowsExactly(IllegalArgumentException.class, () -> new
ExtendedMessageFormat("a5XdkR;T1{9 ,LzXf?", new HashMap<>()));
}
- @Test
- void testArgumentIndexTrailingWhitespaceAtEnd() {
- assertThrowsExactly(IllegalArgumentException.class, () -> new
ExtendedMessageFormat("{0 ", new HashMap<>()));
- }
-
@Test
void testOverriddenBuiltinFormat() {
final Calendar cal = Calendar.getInstance();