Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Zimmermann2014-12-04 13:36:20 +0000
committerJudith Gull2014-12-04 14:39:45 +0000
commitd916b2433175fef4a350a848a4bd3feff330fbe7 (patch)
tree0f2f23a734faaf70f4f4102ac2a779e96b3483dc
parent0beb9b5402259d4df3e746c9cba75106c559668c (diff)
downloadorg.eclipse.scout.rt-d916b2433175fef4a350a848a4bd3feff330fbe7.tar.gz
org.eclipse.scout.rt-d916b2433175fef4a350a848a4bd3feff330fbe7.tar.xz
org.eclipse.scout.rt-d916b2433175fef4a350a848a4bd3feff330fbe7.zip
Bug 402298 test StringUtility split method, added javadoc
Change-Id: I2d022497ae109c4aac659f34422595833a28f671 Reviewed-on: https://git.eclipse.org/r/37566 Tested-by: Hudson CI Reviewed-by: Judith Gull <jgu@bsiag.com>
-rw-r--r--org.eclipse.scout.commons.test/src/org/eclipse/scout/commons/StringUtilityTest.java8
-rw-r--r--org.eclipse.scout.commons/src/org/eclipse/scout/commons/StringUtility.java15
2 files changed, 18 insertions, 5 deletions
diff --git a/org.eclipse.scout.commons.test/src/org/eclipse/scout/commons/StringUtilityTest.java b/org.eclipse.scout.commons.test/src/org/eclipse/scout/commons/StringUtilityTest.java
index c0be151eca..68eddb0150 100644
--- a/org.eclipse.scout.commons.test/src/org/eclipse/scout/commons/StringUtilityTest.java
+++ b/org.eclipse.scout.commons.test/src/org/eclipse/scout/commons/StringUtilityTest.java
@@ -10,6 +10,7 @@
******************************************************************************/
package org.eclipse.scout.commons;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@@ -138,6 +139,13 @@ public class StringUtilityTest {
}
@Test
+ public void testSplit() {
+ assertEquals(0, StringUtility.split(null, null).length);
+ assertEquals(0, StringUtility.split("", null).length);
+ assertArrayEquals(new String[]{"boo", "and", "foo"}, StringUtility.split("boo:and:foo", ":"));
+ }
+
+ @Test
public void testMnemonics() {
String s = "Button &Test";
assertEquals('T', StringUtility.getMnemonic(s));
diff --git a/org.eclipse.scout.commons/src/org/eclipse/scout/commons/StringUtility.java b/org.eclipse.scout.commons/src/org/eclipse/scout/commons/StringUtility.java
index 6699cc8d20..3d2fcfeb4d 100644
--- a/org.eclipse.scout.commons/src/org/eclipse/scout/commons/StringUtility.java
+++ b/org.eclipse.scout.commons/src/org/eclipse/scout/commons/StringUtility.java
@@ -553,10 +553,10 @@ public final class StringUtility {
while (startPos < text.length() && (a = getStartTag(text, tagName, startPos)).begin >= 0 && (b = text.indexOf("</" + tagName + ">", a.end)) > 0) {
text =
text.substring(0, a.begin) +
- start +
- text.substring(a.end, b) +
- end +
- text.substring(b + tagName.length() + 3);
+ start +
+ text.substring(a.end, b) +
+ end +
+ text.substring(b + tagName.length() + 3);
//next
startPos = a.begin + start.length();
}
@@ -1168,6 +1168,11 @@ public final class StringUtility {
}
}
+ /**
+ * Splits the string around matches of the regex.
+ * Returns an empty array if the provided string is null or has length null.
+ * Otherwise, the method returns the result of {@link java.lang.String#split}.
+ */
public static String[] split(String s, String regex) {
if (s == null || s.length() == 0) {
return new String[0];
@@ -1190,7 +1195,7 @@ public final class StringUtility {
"(?<=[^A-Z])(?=[A-Z])",
"(?<=[A-Za-z])(?=[^A-Za-z])"
),
- " "
+ " "
);
}

Back to the top