TextUtil { @Pure public static String[] split(char leftSeparator, char rightSeparator, String str) { final SplitSeparatorToArrayAlgorithm algo = new SplitSeparatorToArrayAlgorithm(); splitSeparatorAlgorithm(leftSeparator, rightSeparator, str, algo); return algo.toArray(); } private  TextUtil(); @Pure static boolean equalsIgnoreCase(String firstText, String secondText, boolean isNullEmptyEquivalence); @Pure @SuppressWarnings("checkstyle:magicnumber") static String encodeBase26(int number); @Pure @SuppressWarnings("checkstyle:npathcomplexity") static Map<String, Integer> getHtmlToJavaTranslationTable(); @Pure @SuppressWarnings("checkstyle:npathcomplexity") static Map<Character, String> getJavaToHTMLTranslationTable(); @Pure @SuppressWarnings("checkstyle:magicnumber") static String parseHTML(String html); @Pure static String toHTML(String text); @Pure static String cutString(String text, int column); @Pure static String[] cutStringAsArray(String text, int column); static void cutStringAsArray(String text, CutStringCritera critera, List<String> output); @Pure static char getMnemonicChar(String text); @Pure static String removeMnemonicChar(String text); @Pure @SuppressWarnings("checkstyle:npathcomplexity") static Map<Character, String> getAccentTranslationTable(); @Pure static String removeAccents(String text); @Pure static String removeAccents(String text, Map<Character, String> map); @Pure @Inline(value = "textUtil.split('{', '}', $1)", imported = {TextUtil.class}) static String[] splitBrackets(String str); @Pure static String[] split(char leftSeparator, char rightSeparator, String str); @Pure @Inline(value = "textUtil.splitAsList('{', '}', $1)", imported = {TextUtil.class}) static List<String> splitBracketsAsList(String str); @Pure static List<String> splitAsList(char leftSeparator, char rightSeparator, String str); @Pure @Inline(value = "textUtil.splitAsUUIDs('{', '}', $1)", imported = {TextUtil.class}) static List<UUID> splitBracketsAsUUIDs(String str); @Pure static List<UUID> splitAsUUIDs(char leftSeparator, char rightSeparator, String str); @Pure @Inline(value = "TextUtil.join('{', '}', $1)", imported = {TextUtil.class}) static String mergeBrackets(@SuppressWarnings("unchecked") T... strs); @Pure @Inline(value = "TextUtil.join('{', '}', $1)", imported = {TextUtil.class}) static String mergeBrackets(Iterable<?> strs); @Pure static String join(char leftSeparator, char rightSeparator, @SuppressWarnings("unchecked") T... strs); @Pure static String join(char leftSeparator, char rightSeparator, Iterable<?> strs); @Pure @Inline(value = "TextUtil.join($1, null, null, Arrays.asList($2))", imported = {TextUtil.class, Arrays.class}) static String join(String joinText, @SuppressWarnings("unchecked") T... elements); @Pure @Inline(value = "TextUtil.join($1, null, null, $2)", imported = {TextUtil.class}) static String join(String joinText, boolean... elements); @Pure @Inline(value = "TextUtil.join($1, null, null, $2)", imported = {TextUtil.class}) static String join(String joinText, byte... elements); @Pure @Inline(value = "TextUtil.join($1, null, null, $2)", imported = {TextUtil.class}) static String join(String joinText, char... elements); @Pure @Inline(value = "TextUtil.join($1, null, null, $2)", imported = {TextUtil.class}) static String join(String joinText, short... elements); @Pure @Inline(value = "TextUtil.join($1, null, null, $2)", imported = {TextUtil.class}) static String join(String joinText, int... elements); @Pure @Inline(value = "TextUtil.join($1, null, null, $2)", imported = {TextUtil.class}) static String join(String joinText, long... elements); @Pure @Inline(value = "TextUtil.join($1, null, null, $2)", imported = {TextUtil.class}) static String join(String joinText, float... elements); @Pure @Inline(value = "TextUtil.join($1, null, null, $2)", imported = {TextUtil.class}) static String join(String joinText, double... elements); @Pure @Inline(value = "TextUtil.join($1, null, null, $2)", imported = {TextUtil.class}) static String join(String joinText, Iterable<?> elements); @Pure @Inline(value = "TextUtil.join($1, $2, $3, Arrays.asList($4))", imported = {TextUtil.class, Arrays.class}) static String join(String joinText, String prefix, String postfix, @SuppressWarnings("unchecked") T... elements); @Pure static String join(String joinText, String prefix, String postfix, Iterable<?> elements); @Pure static String join(String joinText, String prefix, String postfix, boolean... elements); @Pure static String join(String joinText, String prefix, String postfix, byte... elements); @Pure static String join(String joinText, String prefix, String postfix, char... elements); @Pure static String join(String joinText, String prefix, String postfix, short... elements); @Pure static String join(String joinText, String prefix, String postfix, int... elements); @Pure static String join(String joinText, String prefix, String postfix, long... elements); @Pure static String join(String joinText, String prefix, String postfix, float... elements); @Pure static String join(String joinText, String prefix, String postfix, double... elements); @Pure @Inline(value = "TextUtil.removeAccents($1, $3).equals(TextUtil.removeAccents($2, $3))", imported = {TextUtil.class}) static boolean equalsIgnoreAccents(String s1, String s2, Map<Character, String> map); @Pure @Inline(value = "TextUtil.removeAccents($1, $3).equalsIgnoreCase(TextUtil.removeAccents($2, $3))", imported = {TextUtil.class}) static boolean equalsIgnoreCaseAccents(String s1, String s2, Map<Character, String> map); @Pure static String toLowerCaseWithoutAccent(String text); @Pure static String toLowerCaseWithoutAccent(String text, Map<Character, String> map); @Pure static String toUpperCaseWithoutAccent(String text); @Pure static String toUpperCaseWithoutAccent(String text, Map<Character, String> map); @Pure @SuppressWarnings({"checkstyle:magicnumber", "checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"}) static String formatTime(double amount, TimeUnit unit); @Pure @Inline(value = "$3.formatHex($1, $2)", imported = {StringEscaper.class}) static String formatHex(int amount, int digits); @Pure static String formatDouble(double amount, int decimalCount); @Pure static String formatFloat(float amount, int decimalCount); static int getLevenshteinDistance(String firstString, String secondString); @Pure static String toJavaString(String text); @Pure static String toJsonString(String text);  }
@Test public void splitCharCharStr() throws Exception { String[] tab; tab = TextUtil.split('(',']',"(a](b](c](d]"); assertArrayEquals(new String[]{ "a", "b", "c", "d", }, tab); tab = TextUtil.split('(',']',"start (a]bbb (b eee](c](d]zzz end"); assertArrayEquals(new String[]{ "start", "a", "bbb", "b eee", "c", "d", "zzz end", }, tab); tab = TextUtil.split('(',']',"start (a]bbb (b (eee]](c](d]zzz end"); assertArrayEquals(new String[]{ "start", "a", "bbb", "b (eee]", "c", "d", "zzz end", }, tab); tab = TextUtil.split('(',']',"start (a]bbb (b (e(e(e]f]]](c](d]zzz end"); assertArrayEquals(new String[]{ "start", "a", "bbb", "b (e(e(e]f]]", "c", "d", "zzz end", }, tab); tab = TextUtil.split('(',']',"start (a]bbb (b (e(e(e]f]]](](d]zzz end"); assertArrayEquals(new String[]{ "start", "a", "bbb", "b (e(e(e]f]]", "", "d", "zzz end", }, tab); }