You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/06/28 11:56:08 UTC
(commons-lang) branch master updated (37a2be804 -> 6cb563d12)
This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
from 37a2be804 Handle supplementary code points in splitByCharacterType (#1734)
new 98bc7e5e6 Handle supplementary code points in StringUtils.splitByCharacterType() (#1734).
new 7b11dcf56 Handle supplementary code points in StringUtils.splitByCharacterType() (#1734).
new 6cb563d12 Handle supplementary code points in StringUtils.splitByCharacterType()
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/changes/changes.xml | 1 +
.../java/org/apache/commons/lang3/StringUtils.java | 16 +++--
.../org/apache/commons/lang3/StringUtilsTest.java | 76 ++++++----------------
3 files changed, 30 insertions(+), 63 deletions(-)
(commons-lang) 02/03: Handle supplementary code points in StringUtils.splitByCharacterType() (#1734).
Posted by gg...@apache.org.
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-lang.git
commit 7b11dcf5624351a56a913f2afd6e1673efab2d31
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 28 11:53:13 2026 +0000
Handle supplementary code points in StringUtils.splitByCharacterType()
(#1734).
Javadoc
---
src/main/java/org/apache/commons/lang3/StringUtils.java | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
index c8ef44dbd..5764c8b86 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -7215,7 +7215,7 @@ public static String[] split(final String str, final String separatorChars, fina
}
/**
- * Splits a String by Character type as returned by {@code java.lang.Character.getType(char)}. Groups of contiguous characters of the same type are returned
+ * Splits a String by Character type as returned by {@link Character#getType(int)}. Groups of contiguous characters of the same type are returned
* as complete tokens.
*
* <pre>
@@ -7232,6 +7232,7 @@ public static String[] split(final String str, final String separatorChars, fina
*
* @param str the String to split, may be {@code null}.
* @return an array of parsed Strings, {@code null} if null String input.
+ * @see Character#getType(int)
* @since 2.4
*/
public static String[] splitByCharacterType(final String str) {
@@ -7240,9 +7241,9 @@ public static String[] splitByCharacterType(final String str) {
/**
* Splits a String by Character type as returned by {@code java.lang.Character.getType(char)}. Groups of contiguous characters of the same type are returned
- * as complete tokens, with the following exception: if {@code camelCase} is {@code true}, the character of type {@code Character.UPPERCASE_LETTER}, if any,
- * immediately preceding a token of type {@code Character.LOWERCASE_LETTER} will belong to the following token rather than to the preceding, if any,
- * {@code Character.UPPERCASE_LETTER} token.
+ * as complete tokens, with the following exception: if {@code camelCase} is {@code true}, the character of type {@link Character#UPPERCASE_LETTER}, if any,
+ * immediately preceding a token of type {@link Character#LOWERCASE_LETTER} will belong to the following token rather than to the preceding, if any,
+ * {@link Character#UPPERCASE_LETTER} token.
*
* @param str the String to split, may be {@code null}.
* @param camelCase whether to use so-called "camel-case" for letter types.
@@ -7286,9 +7287,9 @@ private static String[] splitByCharacterType(final String str, final boolean cam
}
/**
- * Splits a String by Character type as returned by {@code java.lang.Character.getType(char)}. Groups of contiguous characters of the same type are returned
- * as complete tokens, with the following exception: the character of type {@code Character.UPPERCASE_LETTER}, if any, immediately preceding a token of type
- * {@code Character.LOWERCASE_LETTER} will belong to the following token rather than to the preceding, if any, {@code Character.UPPERCASE_LETTER} token.
+ * Splits a String by Character type as returned by {@link Character#getType(int)}. Groups of contiguous characters of the same type are returned
+ * as complete tokens, with the following exception: the character of type {@link Character#UPPERCASE_LETTER}, if any, immediately preceding a token of type
+ * {@link Character#LOWERCASE_LETTER} will belong to the following token rather than to the preceding, if any, {@link Character#UPPERCASE_LETTER} token.
*
* <pre>
* StringUtils.splitByCharacterTypeCamelCase(null) = null
@@ -7304,6 +7305,7 @@ private static String[] splitByCharacterType(final String str, final boolean cam
*
* @param str the String to split, may be {@code null}.
* @return an array of parsed Strings, {@code null} if null String input.
+ * @see Character#getType(int)
* @since 2.4
*/
public static String[] splitByCharacterTypeCamelCase(final String str) {
(commons-lang) 03/03: Handle supplementary code points in StringUtils.splitByCharacterType()
Posted by gg...@apache.org.
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-lang.git
commit 6cb563d122680d6bf82f8cebdc9fde20f0128bca
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 28 11:56:02 2026 +0000
Handle supplementary code points in StringUtils.splitByCharacterType()
- Fix JUnit API usage
- Reduce vertical whitespace
---
.../org/apache/commons/lang3/StringUtilsTest.java | 76 ++++++----------------
1 file changed, 20 insertions(+), 56 deletions(-)
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
index e90b276fb..c9090c513 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
@@ -2334,76 +2334,40 @@ void testSplit_StringString_StringStringInt() {
void testSplitByCharacterType() {
assertNull(StringUtils.splitByCharacterType(null));
assertEquals(0, StringUtils.splitByCharacterType("").length);
-
- assertTrue(Objects.deepEquals(new String[]{"ab", " ", "de", " ",
- "fg"}, StringUtils.splitByCharacterType("ab de fg")));
-
- assertTrue(Objects.deepEquals(new String[]{"ab", " ", "de", " ",
- "fg"}, StringUtils.splitByCharacterType("ab de fg")));
-
- assertTrue(Objects.deepEquals(new String[]{"ab", ":", "cd", ":",
- "ef"}, StringUtils.splitByCharacterType("ab:cd:ef")));
-
- assertTrue(Objects.deepEquals(new String[]{"number", "5"},
- StringUtils.splitByCharacterType("number5")));
-
- assertTrue(Objects.deepEquals(new String[]{"foo", "B", "ar"},
- StringUtils.splitByCharacterType("fooBar")));
-
- assertTrue(Objects.deepEquals(new String[]{"foo", "200", "B", "ar"},
- StringUtils.splitByCharacterType("foo200Bar")));
-
- assertTrue(Objects.deepEquals(new String[]{"ASFR", "ules"},
- StringUtils.splitByCharacterType("ASFRules")));
-
+ assertArrayEquals(new String[] { "ab", " ", "de", " ", "fg" }, StringUtils.splitByCharacterType("ab de fg"));
+ assertArrayEquals(new String[] { "ab", " ", "de", " ", "fg" }, StringUtils.splitByCharacterType("ab de fg"));
+ assertArrayEquals(new String[] { "ab", ":", "cd", ":", "ef" }, StringUtils.splitByCharacterType("ab:cd:ef"));
+ assertArrayEquals(new String[] { "number", "5" }, StringUtils.splitByCharacterType("number5"));
+ assertArrayEquals(new String[] { "foo", "B", "ar" }, StringUtils.splitByCharacterType("fooBar"));
+ assertArrayEquals(new String[] { "foo", "200", "B", "ar" }, StringUtils.splitByCharacterType("foo200Bar"));
+ assertArrayEquals(new String[] { "ASFR", "ules" }, StringUtils.splitByCharacterType("ASFRules"));
// Supplementary code points are classified by their own type, not split apart as surrogates.
// U+1D400 MATHEMATICAL BOLD CAPITAL A is an upper-case letter, like ASCII 'A'.
final String boldA = new String(Character.toChars(0x1D400));
// U+1D7D3 MATHEMATICAL BOLD DIGIT FIVE is a decimal digit, like ASCII '5'.
final String boldFive = new String(Character.toChars(0x1D7D3));
- assertTrue(Objects.deepEquals(new String[]{"A" + boldA},
- StringUtils.splitByCharacterType("A" + boldA)));
- assertTrue(Objects.deepEquals(new String[]{"5" + boldFive},
- StringUtils.splitByCharacterType("5" + boldFive)));
- assertTrue(Objects.deepEquals(new String[]{boldA, "5" + boldFive, "z"},
- StringUtils.splitByCharacterType(boldA + "5" + boldFive + "z")));
+ assertArrayEquals(new String[] { "A" + boldA }, StringUtils.splitByCharacterType("A" + boldA));
+ assertArrayEquals(new String[] { "5" + boldFive }, StringUtils.splitByCharacterType("5" + boldFive));
+ assertArrayEquals(new String[] { boldA, "5" + boldFive, "z" }, StringUtils.splitByCharacterType(boldA + "5" + boldFive + "z"));
}
@Test
void testSplitByCharacterTypeCamelCase() {
assertNull(StringUtils.splitByCharacterTypeCamelCase(null));
assertEquals(0, StringUtils.splitByCharacterTypeCamelCase("").length);
-
- assertTrue(Objects.deepEquals(new String[]{"ab", " ", "de", " ",
- "fg"}, StringUtils.splitByCharacterTypeCamelCase("ab de fg")));
-
- assertTrue(Objects.deepEquals(new String[]{"ab", " ", "de", " ",
- "fg"}, StringUtils.splitByCharacterTypeCamelCase("ab de fg")));
-
- assertTrue(Objects.deepEquals(new String[]{"ab", ":", "cd", ":",
- "ef"}, StringUtils.splitByCharacterTypeCamelCase("ab:cd:ef")));
-
- assertTrue(Objects.deepEquals(new String[]{"number", "5"},
- StringUtils.splitByCharacterTypeCamelCase("number5")));
-
- assertTrue(Objects.deepEquals(new String[]{"foo", "Bar"},
- StringUtils.splitByCharacterTypeCamelCase("fooBar")));
-
- assertTrue(Objects.deepEquals(new String[]{"foo", "200", "Bar"},
- StringUtils.splitByCharacterTypeCamelCase("foo200Bar")));
-
- assertTrue(Objects.deepEquals(new String[]{"ASF", "Rules"},
- StringUtils.splitByCharacterTypeCamelCase("ASFRules")));
-
+ assertArrayEquals(new String[] { "ab", " ", "de", " ", "fg" }, StringUtils.splitByCharacterTypeCamelCase("ab de fg"));
+ assertArrayEquals(new String[] { "ab", " ", "de", " ", "fg" }, StringUtils.splitByCharacterTypeCamelCase("ab de fg"));
+ assertArrayEquals(new String[] { "ab", ":", "cd", ":", "ef" }, StringUtils.splitByCharacterTypeCamelCase("ab:cd:ef"));
+ assertArrayEquals(new String[] { "number", "5" }, StringUtils.splitByCharacterTypeCamelCase("number5"));
+ assertArrayEquals(new String[] { "foo", "Bar" }, StringUtils.splitByCharacterTypeCamelCase("fooBar"));
+ assertArrayEquals(new String[] { "foo", "200", "Bar" }, StringUtils.splitByCharacterTypeCamelCase("foo200Bar"));
+ assertArrayEquals(new String[] { "ASF", "Rules" }, StringUtils.splitByCharacterTypeCamelCase("ASFRules"));
// A supplementary upper-case letter immediately before a lower-case run joins the following token,
// exactly as a BMP upper-case letter does. U+1D400 MATHEMATICAL BOLD CAPITAL A is an upper-case letter.
final String boldA = new String(Character.toChars(0x1D400));
- assertTrue(Objects.deepEquals(new String[]{boldA + "bc"},
- StringUtils.splitByCharacterTypeCamelCase(boldA + "bc")));
- assertTrue(Objects.deepEquals(new String[]{"AB", boldA + "cd"},
- StringUtils.splitByCharacterTypeCamelCase("AB" + boldA + "cd")));
- assertTrue(Objects.deepEquals(new String[]{"foo", boldA + "bar"},
- StringUtils.splitByCharacterTypeCamelCase("foo" + boldA + "bar")));
+ assertArrayEquals(new String[] { boldA + "bc" }, StringUtils.splitByCharacterTypeCamelCase(boldA + "bc"));
+ assertArrayEquals(new String[] { "AB", boldA + "cd" }, StringUtils.splitByCharacterTypeCamelCase("AB" + boldA + "cd"));
+ assertArrayEquals(new String[] { "foo", boldA + "bar" }, StringUtils.splitByCharacterTypeCamelCase("foo" + boldA + "bar"));
}
@Test
(commons-lang) 01/03: Handle supplementary code points in StringUtils.splitByCharacterType() (#1734).
Posted by gg...@apache.org.
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-lang.git
commit 98bc7e5e6ca00958005b7eb741377e1f834a33bd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 28 11:49:07 2026 +0000
Handle supplementary code points in StringUtils.splitByCharacterType()
(#1734).
---
src/changes/changes.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2b53d5487..4be35f47b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -212,6 +212,7 @@ java.lang.NullPointerException: Cannot invoke
<action type="fix" dev="ggregory" due-to="alhudz, Gary Gregory">Fix StringUtils.getDigits dropping supplementary digits (#1729).</action>
<action type="fix" dev="ggregory" due-to="alhudz, Gary Gregory">Keep StrBuilder.reverse from splitting surrogate pairs (#1730).</action>
<action type="fix" dev="ggregory" due-to="alhudz, Gary Gregory">Fix NumberUtils min/max varargs dropping the sign of zero (#1733).</action>
+ <action type="fix" dev="ggregory" due-to="alhudz, Gary Gregory">Handle supplementary code points in StringUtils.splitByCharacterType() (#1734).</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">Add JavaVersion.JAVA_27.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add SystemUtils.IS_JAVA_27.</action>