对于字符串常用使用处理可以参考org.apache.commons.lang.StringUtils(commons-lang.jar), 如对字符的判空、字符替换、去空格及判断相等等,具体使用代码如下
1.继承apache的StringUtils
public class StringUtils extends org.apache.commons.lang.StringUtils { }
2.自定义的实用的常用处理
import java.util.ArrayList;@b@import java.util.Collection;@b@import java.util.Collections;@b@import java.util.Enumeration;@b@import java.util.List;@b@import java.util.Locale;@b@import java.util.Set;@b@import java.util.StringTokenizer;@b@import java.util.TreeSet;@b@@b@public class StringUtils {@b@ private static final String FOLDER_SEPARATOR = "/";@b@ private static final String WINDOWS_FOLDER_SEPARATOR = "\\";@b@ private static final String TOP_PATH = "..";@b@ private static final String CURRENT_PATH = ".";@b@ private static final char EXTENSION_SEPARATOR = 46;@b@@b@ public static boolean hasLength(CharSequence str)@b@ {@b@ return ((str != null) && (str.length() > 0));@b@ }@b@@b@ public static boolean hasLength(String str)@b@ {@b@ return hasLength(str);@b@ }@b@@b@ public static boolean hasText(CharSequence str)@b@ {@b@ if (!(hasLength(str)))@b@ return false;@b@@b@ int strLen = str.length();@b@ for (int i = 0; i < strLen; ++i)@b@ if (!(Character.isWhitespace(str.charAt(i))))@b@ return true;@b@@b@@b@ return false;@b@ }@b@@b@ public static boolean hasText(String str)@b@ {@b@ if (str == null) return false;@b@ return hasText(str);@b@ }@b@@b@ public static boolean containsWhitespace(CharSequence str)@b@ {@b@ if (!(hasLength(str)))@b@ return false;@b@@b@ int strLen = str.length();@b@ for (int i = 0; i < strLen; ++i)@b@ if (Character.isWhitespace(str.charAt(i)))@b@ return true;@b@@b@@b@ return false;@b@ }@b@@b@ public static boolean containsWhitespace(String str)@b@ {@b@ return containsWhitespace(str);@b@ }@b@@b@ public static String trimWhitespace(String str)@b@ {@b@ if (!(hasLength(str)))@b@ return str;@b@@b@ StringBuffer buf = new StringBuffer(str);@b@ do {@b@ buf.deleteCharAt(0);@b@@b@ if (buf.length() <= 0) break; }@b@ while (Character.isWhitespace(buf.charAt(0)));@b@@b@ while ((buf.length() > 0) && (Character.isWhitespace(buf.charAt(buf.length() - 1))))@b@ buf.deleteCharAt(buf.length() - 1);@b@@b@ return buf.toString();@b@ }@b@@b@ public static String trimAllWhitespace(String str)@b@ {@b@ if (!(hasLength(str)))@b@ return str;@b@@b@ StringBuffer buf = new StringBuffer(str);@b@ int index = 0;@b@ while (buf.length() > index)@b@ if (Character.isWhitespace(buf.charAt(index))) {@b@ buf.deleteCharAt(index);@b@ }@b@ else@b@ ++index;@b@@b@@b@ return buf.toString();@b@ }@b@@b@ public static String trimLeadingWhitespace(String str)@b@ {@b@ if (!(hasLength(str)))@b@ return str;@b@@b@ StringBuffer buf = new StringBuffer(str);@b@ while ((buf.length() > 0) && (Character.isWhitespace(buf.charAt(0))))@b@ buf.deleteCharAt(0);@b@@b@ return buf.toString();@b@ }@b@@b@ public static String trimTrailingWhitespace(String str)@b@ {@b@ if (!(hasLength(str)))@b@ return str;@b@@b@ StringBuffer buf = new StringBuffer(str);@b@ while ((buf.length() > 0) && (Character.isWhitespace(buf.charAt(buf.length() - 1))))@b@ buf.deleteCharAt(buf.length() - 1);@b@@b@ return buf.toString();@b@ }@b@@b@ public static String trimLeadingCharacter(String str, char leadingCharacter)@b@ {@b@ if (!(hasLength(str)))@b@ return str;@b@@b@ StringBuffer buf = new StringBuffer(str);@b@ while ((buf.length() > 0) && (buf.charAt(0) == leadingCharacter))@b@ buf.deleteCharAt(0);@b@@b@ return buf.toString();@b@ }@b@@b@ public static String trimTrailingCharacter(String str, char trailingCharacter)@b@ {@b@ if (!(hasLength(str)))@b@ return str;@b@@b@ StringBuffer buf = new StringBuffer(str);@b@ while ((buf.length() > 0) && (buf.charAt(buf.length() - 1) == trailingCharacter))@b@ buf.deleteCharAt(buf.length() - 1);@b@@b@ return buf.toString();@b@ }@b@@b@ public static boolean startsWithIgnoreCase(String str, String prefix)@b@ {@b@ if ((str == null) || (prefix == null))@b@ return false;@b@@b@ if (str.startsWith(prefix))@b@ return true;@b@@b@ if (str.length() < prefix.length())@b@ return false;@b@@b@ String lcStr = str.substring(0, prefix.length()).toLowerCase();@b@ String lcPrefix = prefix.toLowerCase();@b@ return lcStr.equals(lcPrefix);@b@ }@b@@b@ public static boolean endsWithIgnoreCase(String str, String suffix)@b@ {@b@ if ((str == null) || (suffix == null))@b@ return false;@b@@b@ if (str.endsWith(suffix))@b@ return true;@b@@b@ if (str.length() < suffix.length()) {@b@ return false;@b@ }@b@@b@ String lcStr = str.substring(str.length() - suffix.length()).toLowerCase();@b@ String lcSuffix = suffix.toLowerCase();@b@ return lcStr.equals(lcSuffix);@b@ }@b@@b@ public static boolean substringMatch(CharSequence str, int index, CharSequence substring)@b@ {@b@ for (int j = 0; j < substring.length(); ++j) {@b@ int i = index + j;@b@ if ((i >= str.length()) || (str.charAt(i) != substring.charAt(j)))@b@ return false;@b@ }@b@@b@ return true;@b@ }@b@@b@ public static int countOccurrencesOf(String str, String sub)@b@ {@b@ if ((str == null) || (sub == null) || (str.length() == 0) || (sub.length() == 0))@b@ return 0;@b@@b@ int count = 0; int pos = 0; int idx = 0;@b@ while ((idx = str.indexOf(sub, pos)) != -1) {@b@ ++count;@b@ pos = idx + sub.length();@b@ }@b@ return count;@b@ }@b@@b@ public static String replace(String inString, String oldPattern, String newPattern)@b@ {@b@ if (inString == null)@b@ return null;@b@@b@ if ((oldPattern == null) || (newPattern == null)) {@b@ return inString;@b@ }@b@@b@ StringBuffer sbuf = new StringBuffer();@b@@b@ int pos = 0;@b@ int index = inString.indexOf(oldPattern);@b@@b@ int patLen = oldPattern.length();@b@ while (index >= 0) {@b@ sbuf.append(inString.substring(pos, index));@b@ sbuf.append(newPattern);@b@ pos = index + patLen;@b@ index = inString.indexOf(oldPattern, pos);@b@ }@b@ sbuf.append(inString.substring(pos));@b@@b@ return sbuf.toString();@b@ }@b@@b@ public static String delete(String inString, String pattern)@b@ {@b@ return replace(inString, pattern, "");@b@ }@b@@b@ public static String deleteAny(String inString, String charsToDelete)@b@ {@b@ if ((!(hasLength(inString))) || (!(hasLength(charsToDelete))))@b@ return inString;@b@@b@ StringBuffer out = new StringBuffer();@b@ for (int i = 0; i < inString.length(); ++i) {@b@ char c = inString.charAt(i);@b@ if (charsToDelete.indexOf(c) == -1)@b@ out.append(c);@b@ }@b@@b@ return out.toString();@b@ }@b@@b@ public static String quote(String str)@b@ {@b@ return ((str != null) ? "'" + str + "'" : null);@b@ }@b@@b@ public static Object quoteIfString(Object obj)@b@ {@b@ return ((obj instanceof String) ? quote((String)obj) : obj);@b@ }@b@@b@ public static String unqualify(String qualifiedName)@b@ {@b@ return unqualify(qualifiedName, '.');@b@ }@b@@b@ public static String unqualify(String qualifiedName, char separator)@b@ {@b@ return qualifiedName.substring(qualifiedName.lastIndexOf(separator) + 1);@b@ }@b@@b@ public static String capitalize(String str)@b@ {@b@ return changeFirstCharacterCase(str, true);@b@ }@b@@b@ public static String uncapitalize(String str)@b@ {@b@ return changeFirstCharacterCase(str, false);@b@ }@b@@b@ private static String changeFirstCharacterCase(String str, boolean capitalize) {@b@ if ((str == null) || (str.length() == 0))@b@ return str;@b@@b@ StringBuffer buf = new StringBuffer(str.length());@b@ if (capitalize) {@b@ buf.append(Character.toUpperCase(str.charAt(0)));@b@ }@b@ else@b@ buf.append(Character.toLowerCase(str.charAt(0)));@b@@b@ buf.append(str.substring(1));@b@ return buf.toString();@b@ }@b@@b@ public static String getFilename(String path)@b@ {@b@ if (path == null)@b@ return null;@b@@b@ int separatorIndex = path.lastIndexOf("/");@b@ return ((separatorIndex != -1) ? path.substring(separatorIndex + 1) : path);@b@ }@b@@b@ public static String getFilenameExtension(String path)@b@ {@b@ if (path == null)@b@ return null;@b@@b@ int sepIndex = path.lastIndexOf(46);@b@ return ((sepIndex != -1) ? path.substring(sepIndex + 1) : null);@b@ }@b@@b@ public static String stripFilenameExtension(String path)@b@ {@b@ if (path == null)@b@ return null;@b@@b@ int sepIndex = path.lastIndexOf(46);@b@ return ((sepIndex != -1) ? path.substring(0, sepIndex) : path);@b@ }@b@@b@ public static String applyRelativePath(String path, String relativePath)@b@ {@b@ int separatorIndex = path.lastIndexOf("/");@b@ if (separatorIndex != -1) {@b@ String newPath = path.substring(0, separatorIndex);@b@ if (!(relativePath.startsWith("/")))@b@ newPath = newPath + "/";@b@@b@ return newPath + relativePath;@b@ }@b@@b@ return relativePath;@b@ }@b@ @b@ @b@@b@ public static Locale parseLocaleString(String localeString)@b@ {@b@ String[] parts = tokenizeToStringArray(localeString, "_ ", false, false);@b@ String language = (parts.length > 0) ? parts[0] : "";@b@ String country = (parts.length > 1) ? parts[1] : "";@b@ String variant = "";@b@ if (parts.length >= 2)@b@ {@b@ int endIndexOfCountryCode = localeString.indexOf(country) + country.length();@b@@b@ variant = trimLeadingWhitespace(localeString.substring(endIndexOfCountryCode));@b@ if (variant.startsWith("_"))@b@ variant = trimLeadingCharacter(variant, '_');@b@ }@b@@b@ return ((language.length() > 0) ? new Locale(language, country, variant) : null);@b@ }@b@ @b@@b@ public static String[] toStringArray(Collection collection)@b@ {@b@ if (collection == null)@b@ return null;@b@@b@ return ((String[])collection.toArray(new String[collection.size()]));@b@ }@b@@b@ public static String[] toStringArray(Enumeration enumeration)@b@ {@b@ if (enumeration == null)@b@ return null;@b@@b@ List list = Collections.list(enumeration);@b@ return ((String[])list.toArray(new String[list.size()]));@b@ }@b@ @b@@b@ public static String[] split(String toSplit, String delimiter)@b@ {@b@ if ((!(hasLength(toSplit))) || (!(hasLength(delimiter))))@b@ return null;@b@@b@ int offset = toSplit.indexOf(delimiter);@b@ if (offset < 0)@b@ return null;@b@@b@ String beforeDelimiter = toSplit.substring(0, offset);@b@ String afterDelimiter = toSplit.substring(offset + delimiter.length());@b@ return new String[] { beforeDelimiter, afterDelimiter };@b@ }@b@@b@ @b@@b@ public static String[] tokenizeToStringArray(String str, String delimiters)@b@ {@b@ return tokenizeToStringArray(str, delimiters, true, true);@b@ }@b@@b@ public static String[] tokenizeToStringArray(String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ StringTokenizer st = new StringTokenizer(str, delimiters);@b@ List tokens = new ArrayList();@b@ while (st.hasMoreTokens()) {@b@ String token = st.nextToken();@b@ if (trimTokens)@b@ token = token.trim();@b@@b@ if ((!(ignoreEmptyTokens)) || (token.length() > 0))@b@ tokens.add(token);@b@ }@b@@b@ return toStringArray(tokens);@b@ }@b@@b@ public static String[] delimitedListToStringArray(String str, String delimiter)@b@ {@b@ return delimitedListToStringArray(str, delimiter, null);@b@ }@b@@b@ public static String[] delimitedListToStringArray(String str, String delimiter, String charsToDelete)@b@ {@b@ if (str == null)@b@ return new String[0];@b@@b@ if (delimiter == null)@b@ return new String[] { str };@b@@b@ List result = new ArrayList();@b@ if ("".equals(delimiter)) {@b@ for (int i = 0; i < str.length(); ++i)@b@ result.add(deleteAny(str.substring(i, i + 1), charsToDelete));@b@ }@b@ else@b@ {@b@ int pos = 0;@b@ int delPos = 0;@b@ while ((delPos = str.indexOf(delimiter, pos)) != -1) {@b@ result.add(deleteAny(str.substring(pos, delPos), charsToDelete));@b@ pos = delPos + delimiter.length();@b@ }@b@ if ((str.length() > 0) && (pos <= str.length()))@b@ {@b@ result.add(deleteAny(str.substring(pos), charsToDelete));@b@ }@b@ }@b@ return toStringArray(result);@b@ }@b@@b@ public static String[] commaDelimitedListToStringArray(String str)@b@ {@b@ return delimitedListToStringArray(str, ",");@b@ }@b@@b@ public static Set commaDelimitedListToSet(String str)@b@ {@b@ Set set = new TreeSet();@b@ String[] tokens = commaDelimitedListToStringArray(str);@b@ for (int i = 0; i < tokens.length; ++i)@b@ set.add(tokens[i]);@b@@b@ return set;@b@ }@b@@b@ @b@ public static String trim(String str)@b@ {@b@ return ((str != null) ? str.trim() : null);@b@ }@b@@b@ public static boolean isEmpty(String str)@b@ {@b@ return (!(hasText(str)));@b@ }@b@ @b@ @b@ @b@}
3.org.apache.commons.lang3.StringUtils
package org.apache.commons.lang3;@b@@b@import java.io.UnsupportedEncodingException;@b@import java.nio.charset.Charset;@b@import java.text.Normalizer;@b@import java.text.Normalizer.Form;@b@import java.util.ArrayList;@b@import java.util.Arrays;@b@import java.util.Iterator;@b@import java.util.List;@b@import java.util.Locale;@b@import java.util.regex.Matcher;@b@import java.util.regex.Pattern;@b@@b@public class StringUtils@b@{@b@ public static final String SPACE = " ";@b@ public static final String EMPTY = "";@b@ public static final String LF = "\n";@b@ public static final String CR = "\r";@b@ public static final int INDEX_NOT_FOUND = -1;@b@ private static final int PAD_LIMIT = 8192;@b@ private static final Pattern WHITESPACE_PATTERN = Pattern.compile("(?: |\\u00A0|\\s|[\\s&&[^ ]])\\s*");@b@@b@ public static boolean isEmpty(CharSequence cs)@b@ {@b@ return ((cs == null) || (cs.length() == 0));@b@ }@b@@b@ public static boolean isNotEmpty(CharSequence cs)@b@ {@b@ return (!(isEmpty(cs)));@b@ }@b@@b@ public static boolean isAnyEmpty(CharSequence[] css)@b@ {@b@ if (ArrayUtils.isEmpty(css))@b@ return true;@b@@b@ CharSequence[] arr$ = css; int len$ = arr$.length; for (int i$ = 0; i$ < len$; ++i$) { CharSequence cs = arr$[i$];@b@ if (isEmpty(cs))@b@ return true;@b@ }@b@@b@ return false;@b@ }@b@@b@ public static boolean isNoneEmpty(CharSequence[] css)@b@ {@b@ return (!(isAnyEmpty(css)));@b@ }@b@@b@ public static boolean isBlank(CharSequence cs)@b@ {@b@ int strLen;@b@ if (cs != null) if ((strLen = cs.length()) != 0) break label17;@b@ return true;@b@@b@ for (int i = 0; i < strLen; ++i)@b@ if (!(Character.isWhitespace(cs.charAt(i))))@b@ label17: return false;@b@@b@@b@ return true;@b@ }@b@@b@ public static boolean isNotBlank(CharSequence cs)@b@ {@b@ return (!(isBlank(cs)));@b@ }@b@@b@ public static boolean isAnyBlank(CharSequence[] css)@b@ {@b@ if (ArrayUtils.isEmpty(css))@b@ return true;@b@@b@ CharSequence[] arr$ = css; int len$ = arr$.length; for (int i$ = 0; i$ < len$; ++i$) { CharSequence cs = arr$[i$];@b@ if (isBlank(cs))@b@ return true;@b@ }@b@@b@ return false;@b@ }@b@@b@ public static boolean isNoneBlank(CharSequence[] css)@b@ {@b@ return (!(isAnyBlank(css)));@b@ }@b@@b@ public static String trim(String str)@b@ {@b@ return ((str == null) ? null : str.trim());@b@ }@b@@b@ public static String trimToNull(String str)@b@ {@b@ String ts = trim(str);@b@ return ((isEmpty(ts)) ? null : ts);@b@ }@b@@b@ public static String trimToEmpty(String str)@b@ {@b@ return ((str == null) ? "" : str.trim());@b@ }@b@@b@ public static String strip(String str)@b@ {@b@ return strip(str, null);@b@ }@b@@b@ public static String stripToNull(String str)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ str = strip(str, null);@b@ return ((str.isEmpty()) ? null : str);@b@ }@b@@b@ public static String stripToEmpty(String str)@b@ {@b@ return ((str == null) ? "" : strip(str, null));@b@ }@b@@b@ public static String strip(String str, String stripChars)@b@ {@b@ if (isEmpty(str))@b@ return str;@b@@b@ str = stripStart(str, stripChars);@b@ return stripEnd(str, stripChars);@b@ }@b@@b@ public static String stripStart(String str, String stripChars)@b@ {@b@ int strLen;@b@ if (str != null) if ((strLen = str.length()) != 0) break label15;@b@ return str;@b@@b@ label15: int start = 0;@b@ if (stripChars == null) while (true) {@b@ if ((start == strLen) || (!(Character.isWhitespace(str.charAt(start))))) break label76;@b@ ++start;@b@ }@b@ if (stripChars.isEmpty())@b@ return str;@b@@b@ while ((start != strLen) && (stripChars.indexOf(str.charAt(start)) != -1)) {@b@ ++start;@b@ }@b@@b@ label76: return str.substring(start);@b@ }@b@@b@ public static String stripEnd(String str, String stripChars)@b@ {@b@ int end;@b@ if (str != null) if ((end = str.length()) != 0) break label15;@b@ return str;@b@@b@ if (stripChars == null) while (true) {@b@ label15: if ((end == 0) || (!(Character.isWhitespace(str.charAt(end - 1))))) break label76;@b@ --end;@b@ }@b@ if (stripChars.isEmpty())@b@ return str;@b@@b@ while ((end != 0) && (stripChars.indexOf(str.charAt(end - 1)) != -1)) {@b@ --end;@b@ }@b@@b@ label76: return str.substring(0, end);@b@ }@b@@b@ public static String[] stripAll(String[] strs)@b@ {@b@ return stripAll(strs, null);@b@ }@b@@b@ public static String[] stripAll(String[] strs, String stripChars)@b@ {@b@ int strsLen;@b@ if (strs != null) if ((strsLen = strs.length) != 0) break label13;@b@ return strs;@b@@b@ label13: String[] newArr = new String[strsLen];@b@ for (int i = 0; i < strsLen; ++i)@b@ newArr[i] = strip(strs[i], stripChars);@b@@b@ return newArr;@b@ }@b@@b@ public static String stripAccents(String input)@b@ {@b@ if (input == null)@b@ return null;@b@@b@ Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");@b@ String decomposed = Normalizer.normalize(input, Normalizer.Form.NFD);@b@@b@ return pattern.matcher(decomposed).replaceAll("");@b@ }@b@@b@ public static boolean equals(CharSequence cs1, CharSequence cs2)@b@ {@b@ if (cs1 == cs2)@b@ return true;@b@@b@ if ((cs1 == null) || (cs2 == null))@b@ return false;@b@@b@ if ((cs1 instanceof String) && (cs2 instanceof String))@b@ return cs1.equals(cs2);@b@@b@ return CharSequenceUtils.regionMatches(cs1, false, 0, cs2, 0, Math.max(cs1.length(), cs2.length()));@b@ }@b@@b@ public static boolean equalsIgnoreCase(CharSequence str1, CharSequence str2)@b@ {@b@ if ((str1 == null) || (str2 == null))@b@ return (str1 == str2);@b@ if (str1 == str2)@b@ return true;@b@ if (str1.length() != str2.length())@b@ return false;@b@@b@ return CharSequenceUtils.regionMatches(str1, true, 0, str2, 0, str1.length());@b@ }@b@@b@ public static int indexOf(CharSequence seq, int searchChar)@b@ {@b@ if (isEmpty(seq))@b@ return -1;@b@@b@ return CharSequenceUtils.indexOf(seq, searchChar, 0);@b@ }@b@@b@ public static int indexOf(CharSequence seq, int searchChar, int startPos)@b@ {@b@ if (isEmpty(seq))@b@ return -1;@b@@b@ return CharSequenceUtils.indexOf(seq, searchChar, startPos);@b@ }@b@@b@ public static int indexOf(CharSequence seq, CharSequence searchSeq)@b@ {@b@ if ((seq == null) || (searchSeq == null))@b@ return -1;@b@@b@ return CharSequenceUtils.indexOf(seq, searchSeq, 0);@b@ }@b@@b@ public static int indexOf(CharSequence seq, CharSequence searchSeq, int startPos)@b@ {@b@ if ((seq == null) || (searchSeq == null))@b@ return -1;@b@@b@ return CharSequenceUtils.indexOf(seq, searchSeq, startPos);@b@ }@b@@b@ public static int ordinalIndexOf(CharSequence str, CharSequence searchStr, int ordinal)@b@ {@b@ return ordinalIndexOf(str, searchStr, ordinal, false);@b@ }@b@@b@ private static int ordinalIndexOf(CharSequence str, CharSequence searchStr, int ordinal, boolean lastIndex)@b@ {@b@ if ((str == null) || (searchStr == null) || (ordinal <= 0))@b@ return -1;@b@@b@ if (searchStr.length() == 0)@b@ return ((lastIndex) ? str.length() : 0);@b@@b@ int found = 0;@b@ int index = (lastIndex) ? str.length() : -1;@b@ do {@b@ if (lastIndex)@b@ index = CharSequenceUtils.lastIndexOf(str, searchStr, index - 1);@b@ else@b@ index = CharSequenceUtils.indexOf(str, searchStr, index + 1);@b@@b@ if (index < 0)@b@ return index;@b@@b@ ++found; }@b@ while (found < ordinal);@b@ return index;@b@ }@b@@b@ public static int indexOfIgnoreCase(CharSequence str, CharSequence searchStr)@b@ {@b@ return indexOfIgnoreCase(str, searchStr, 0);@b@ }@b@@b@ public static int indexOfIgnoreCase(CharSequence str, CharSequence searchStr, int startPos)@b@ {@b@ if ((str == null) || (searchStr == null))@b@ return -1;@b@@b@ if (startPos < 0)@b@ startPos = 0;@b@@b@ int endLimit = str.length() - searchStr.length() + 1;@b@ if (startPos > endLimit)@b@ return -1;@b@@b@ if (searchStr.length() == 0)@b@ return startPos;@b@@b@ for (int i = startPos; i < endLimit; ++i)@b@ if (CharSequenceUtils.regionMatches(str, true, i, searchStr, 0, searchStr.length()))@b@ return i;@b@@b@@b@ return -1;@b@ }@b@@b@ public static int lastIndexOf(CharSequence seq, int searchChar)@b@ {@b@ if (isEmpty(seq))@b@ return -1;@b@@b@ return CharSequenceUtils.lastIndexOf(seq, searchChar, seq.length());@b@ }@b@@b@ public static int lastIndexOf(CharSequence seq, int searchChar, int startPos)@b@ {@b@ if (isEmpty(seq))@b@ return -1;@b@@b@ return CharSequenceUtils.lastIndexOf(seq, searchChar, startPos);@b@ }@b@@b@ public static int lastIndexOf(CharSequence seq, CharSequence searchSeq)@b@ {@b@ if ((seq == null) || (searchSeq == null))@b@ return -1;@b@@b@ return CharSequenceUtils.lastIndexOf(seq, searchSeq, seq.length());@b@ }@b@@b@ public static int lastOrdinalIndexOf(CharSequence str, CharSequence searchStr, int ordinal)@b@ {@b@ return ordinalIndexOf(str, searchStr, ordinal, true);@b@ }@b@@b@ public static int lastIndexOf(CharSequence seq, CharSequence searchSeq, int startPos)@b@ {@b@ if ((seq == null) || (searchSeq == null))@b@ return -1;@b@@b@ return CharSequenceUtils.lastIndexOf(seq, searchSeq, startPos);@b@ }@b@@b@ public static int lastIndexOfIgnoreCase(CharSequence str, CharSequence searchStr)@b@ {@b@ if ((str == null) || (searchStr == null))@b@ return -1;@b@@b@ return lastIndexOfIgnoreCase(str, searchStr, str.length());@b@ }@b@@b@ public static int lastIndexOfIgnoreCase(CharSequence str, CharSequence searchStr, int startPos)@b@ {@b@ if ((str == null) || (searchStr == null))@b@ return -1;@b@@b@ if (startPos > str.length() - searchStr.length())@b@ startPos = str.length() - searchStr.length();@b@@b@ if (startPos < 0)@b@ return -1;@b@@b@ if (searchStr.length() == 0) {@b@ return startPos;@b@ }@b@@b@ for (int i = startPos; i >= 0; --i)@b@ if (CharSequenceUtils.regionMatches(str, true, i, searchStr, 0, searchStr.length()))@b@ return i;@b@@b@@b@ return -1;@b@ }@b@@b@ public static boolean contains(CharSequence seq, int searchChar)@b@ {@b@ if (isEmpty(seq))@b@ return false;@b@@b@ return (CharSequenceUtils.indexOf(seq, searchChar, 0) >= 0);@b@ }@b@@b@ public static boolean contains(CharSequence seq, CharSequence searchSeq)@b@ {@b@ if ((seq == null) || (searchSeq == null))@b@ return false;@b@@b@ return (CharSequenceUtils.indexOf(seq, searchSeq, 0) >= 0);@b@ }@b@@b@ public static boolean containsIgnoreCase(CharSequence str, CharSequence searchStr)@b@ {@b@ if ((str == null) || (searchStr == null))@b@ return false;@b@@b@ int len = searchStr.length();@b@ int max = str.length() - len;@b@ for (int i = 0; i <= max; ++i)@b@ if (CharSequenceUtils.regionMatches(str, true, i, searchStr, 0, len))@b@ return true;@b@@b@@b@ return false;@b@ }@b@@b@ public static boolean containsWhitespace(CharSequence seq)@b@ {@b@ if (isEmpty(seq))@b@ return false;@b@@b@ int strLen = seq.length();@b@ for (int i = 0; i < strLen; ++i)@b@ if (Character.isWhitespace(seq.charAt(i)))@b@ return true;@b@@b@@b@ return false;@b@ }@b@@b@ public static int indexOfAny(CharSequence cs, char[] searchChars)@b@ {@b@ if ((isEmpty(cs)) || (ArrayUtils.isEmpty(searchChars)))@b@ return -1;@b@@b@ int csLen = cs.length();@b@ int csLast = csLen - 1;@b@ int searchLen = searchChars.length;@b@ int searchLast = searchLen - 1;@b@ for (int i = 0; i < csLen; ++i) {@b@ char ch = cs.charAt(i);@b@ for (int j = 0; j < searchLen; ++j)@b@ if (searchChars[j] == ch) {@b@ if ((i < csLast) && (j < searchLast) && (Character.isHighSurrogate(ch)))@b@ {@b@ if (searchChars[(j + 1)] != cs.charAt(i + 1)) break label121;@b@ return i;@b@ }@b@@b@ return i;@b@ }@b@@b@ }@b@@b@ label121: return -1;@b@ }@b@@b@ public static int indexOfAny(CharSequence cs, String searchChars)@b@ {@b@ if ((isEmpty(cs)) || (isEmpty(searchChars)))@b@ return -1;@b@@b@ return indexOfAny(cs, searchChars.toCharArray());@b@ }@b@@b@ public static boolean containsAny(CharSequence cs, char[] searchChars)@b@ {@b@ if ((isEmpty(cs)) || (ArrayUtils.isEmpty(searchChars)))@b@ return false;@b@@b@ int csLength = cs.length();@b@ int searchLength = searchChars.length;@b@ int csLast = csLength - 1;@b@ int searchLast = searchLength - 1;@b@ for (int i = 0; i < csLength; ++i) {@b@ char ch = cs.charAt(i);@b@ for (int j = 0; j < searchLength; ++j)@b@ if (searchChars[j] == ch) {@b@ if (Character.isHighSurrogate(ch)) {@b@ if (j == searchLast)@b@ {@b@ return true;@b@ }@b@ if ((i >= csLast) || (searchChars[(j + 1)] != cs.charAt(i + 1))) break label120;@b@ return true;@b@ }@b@@b@ return true;@b@ }@b@@b@ }@b@@b@ label120: return false;@b@ }@b@@b@ public static boolean containsAny(CharSequence cs, CharSequence searchChars)@b@ {@b@ if (searchChars == null)@b@ return false;@b@@b@ return containsAny(cs, CharSequenceUtils.toCharArray(searchChars));@b@ }@b@@b@ public static int indexOfAnyBut(CharSequence cs, char[] searchChars)@b@ {@b@ if ((isEmpty(cs)) || (ArrayUtils.isEmpty(searchChars)))@b@ return -1;@b@@b@ int csLen = cs.length();@b@ int csLast = csLen - 1;@b@ int searchLen = searchChars.length;@b@ int searchLast = searchLen - 1;@b@@b@ for (int i = 0; i < csLen; ++i) {@b@ char ch = cs.charAt(i);@b@ for (int j = 0; j < searchLen; ++j) {@b@ if (searchChars[j] == ch) {@b@ if ((i >= csLast) || (j >= searchLast) || (!(Character.isHighSurrogate(ch)))) break label127;@b@ if (searchChars[(j + 1)] == cs.charAt(i + 1)) {@b@ break label127:@b@ }@b@@b@ }@b@@b@ }@b@@b@ return i;@b@ }@b@ label127: return -1;@b@ }@b@@b@ public static int indexOfAnyBut(CharSequence seq, CharSequence searchChars)@b@ {@b@ if ((isEmpty(seq)) || (isEmpty(searchChars)))@b@ return -1;@b@@b@ int strLen = seq.length();@b@ for (int i = 0; i < strLen; ++i) {@b@ char ch = seq.charAt(i);@b@ boolean chFound = CharSequenceUtils.indexOf(searchChars, ch, 0) >= 0;@b@ if ((i + 1 < strLen) && (Character.isHighSurrogate(ch))) {@b@ char ch2 = seq.charAt(i + 1);@b@ if ((chFound) && (CharSequenceUtils.indexOf(searchChars, ch2, 0) < 0))@b@ return i;@b@@b@ }@b@ else if (!(chFound)) {@b@ return i;@b@ }@b@ }@b@@b@ return -1;@b@ }@b@@b@ public static boolean containsOnly(CharSequence cs, char[] valid)@b@ {@b@ if ((valid == null) || (cs == null))@b@ return false;@b@@b@ if (cs.length() == 0)@b@ return true;@b@@b@ if (valid.length == 0)@b@ return false;@b@@b@ return (indexOfAnyBut(cs, valid) == -1);@b@ }@b@@b@ public static boolean containsOnly(CharSequence cs, String validChars)@b@ {@b@ if ((cs == null) || (validChars == null))@b@ return false;@b@@b@ return containsOnly(cs, validChars.toCharArray());@b@ }@b@@b@ public static boolean containsNone(CharSequence cs, char[] searchChars)@b@ {@b@ if ((cs == null) || (searchChars == null))@b@ return true;@b@@b@ int csLen = cs.length();@b@ int csLast = csLen - 1;@b@ int searchLen = searchChars.length;@b@ int searchLast = searchLen - 1;@b@ for (int i = 0; i < csLen; ++i) {@b@ char ch = cs.charAt(i);@b@ for (int j = 0; j < searchLen; ++j)@b@ if (searchChars[j] == ch) {@b@ if (Character.isHighSurrogate(ch)) {@b@ if (j == searchLast)@b@ {@b@ return false;@b@ }@b@ if ((i >= csLast) || (searchChars[(j + 1)] != cs.charAt(i + 1))) break label115;@b@ return false;@b@ }@b@@b@ return false;@b@ }@b@@b@ }@b@@b@ label115: return true;@b@ }@b@@b@ public static boolean containsNone(CharSequence cs, String invalidChars)@b@ {@b@ if ((cs == null) || (invalidChars == null))@b@ return true;@b@@b@ return containsNone(cs, invalidChars.toCharArray());@b@ }@b@@b@ public static int indexOfAny(CharSequence str, CharSequence[] searchStrs)@b@ {@b@ if ((str == null) || (searchStrs == null))@b@ return -1;@b@@b@ int sz = searchStrs.length;@b@@b@ int ret = 2147483647;@b@@b@ int tmp = 0;@b@ for (int i = 0; i < sz; ++i) {@b@ CharSequence search = searchStrs[i];@b@ if (search == null)@b@ break label69:@b@@b@ tmp = CharSequenceUtils.indexOf(str, search, 0);@b@ if (tmp == -1) {@b@ break label69:@b@ }@b@@b@ if (tmp < ret)@b@ ret = tmp;@b@@b@ }@b@@b@ label69: return ((ret == 2147483647) ? -1 : ret);@b@ }@b@@b@ public static int lastIndexOfAny(CharSequence str, CharSequence[] searchStrs)@b@ {@b@ if ((str == null) || (searchStrs == null))@b@ return -1;@b@@b@ int sz = searchStrs.length;@b@ int ret = -1;@b@ int tmp = 0;@b@ for (int i = 0; i < sz; ++i) {@b@ CharSequence search = searchStrs[i];@b@ if (search == null)@b@ break label64:@b@@b@ tmp = CharSequenceUtils.lastIndexOf(str, search, str.length());@b@ if (tmp > ret)@b@ ret = tmp;@b@ }@b@@b@ label64: return ret;@b@ }@b@@b@ public static String substring(String str, int start)@b@ {@b@ if (str == null) {@b@ return null;@b@ }@b@@b@ if (start < 0) {@b@ start = str.length() + start;@b@ }@b@@b@ if (start < 0)@b@ start = 0;@b@@b@ if (start > str.length()) {@b@ return "";@b@ }@b@@b@ return str.substring(start);@b@ }@b@@b@ public static String substring(String str, int start, int end)@b@ {@b@ if (str == null) {@b@ return null;@b@ }@b@@b@ if (end < 0)@b@ end = str.length() + end;@b@@b@ if (start < 0) {@b@ start = str.length() + start;@b@ }@b@@b@ if (end > str.length()) {@b@ end = str.length();@b@ }@b@@b@ if (start > end) {@b@ return "";@b@ }@b@@b@ if (start < 0)@b@ start = 0;@b@@b@ if (end < 0) {@b@ end = 0;@b@ }@b@@b@ return str.substring(start, end);@b@ }@b@@b@ public static String left(String str, int len)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ if (len < 0)@b@ return "";@b@@b@ if (str.length() <= len)@b@ return str;@b@@b@ return str.substring(0, len);@b@ }@b@@b@ public static String right(String str, int len)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ if (len < 0)@b@ return "";@b@@b@ if (str.length() <= len)@b@ return str;@b@@b@ return str.substring(str.length() - len);@b@ }@b@@b@ public static String mid(String str, int pos, int len)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ if ((len < 0) || (pos > str.length()))@b@ return "";@b@@b@ if (pos < 0)@b@ pos = 0;@b@@b@ if (str.length() <= pos + len)@b@ return str.substring(pos);@b@@b@ return str.substring(pos, pos + len);@b@ }@b@@b@ public static String substringBefore(String str, String separator)@b@ {@b@ if ((isEmpty(str)) || (separator == null))@b@ return str;@b@@b@ if (separator.isEmpty())@b@ return "";@b@@b@ int pos = str.indexOf(separator);@b@ if (pos == -1)@b@ return str;@b@@b@ return str.substring(0, pos);@b@ }@b@@b@ public static String substringAfter(String str, String separator)@b@ {@b@ if (isEmpty(str))@b@ return str;@b@@b@ if (separator == null)@b@ return "";@b@@b@ int pos = str.indexOf(separator);@b@ if (pos == -1)@b@ return "";@b@@b@ return str.substring(pos + separator.length());@b@ }@b@@b@ public static String substringBeforeLast(String str, String separator)@b@ {@b@ if ((isEmpty(str)) || (isEmpty(separator)))@b@ return str;@b@@b@ int pos = str.lastIndexOf(separator);@b@ if (pos == -1)@b@ return str;@b@@b@ return str.substring(0, pos);@b@ }@b@@b@ public static String substringAfterLast(String str, String separator)@b@ {@b@ if (isEmpty(str))@b@ return str;@b@@b@ if (isEmpty(separator))@b@ return "";@b@@b@ int pos = str.lastIndexOf(separator);@b@ if ((pos == -1) || (pos == str.length() - separator.length()))@b@ return "";@b@@b@ return str.substring(pos + separator.length());@b@ }@b@@b@ public static String substringBetween(String str, String tag)@b@ {@b@ return substringBetween(str, tag, tag);@b@ }@b@@b@ public static String substringBetween(String str, String open, String close)@b@ {@b@ if ((str == null) || (open == null) || (close == null))@b@ return null;@b@@b@ int start = str.indexOf(open);@b@ if (start != -1) {@b@ int end = str.indexOf(close, start + open.length());@b@ if (end != -1)@b@ return str.substring(start + open.length(), end);@b@ }@b@@b@ return null;@b@ }@b@@b@ public static String[] substringsBetween(String str, String open, String close)@b@ {@b@ if ((str == null) || (isEmpty(open)) || (isEmpty(close)))@b@ return null;@b@@b@ int strLen = str.length();@b@ if (strLen == 0)@b@ return ArrayUtils.EMPTY_STRING_ARRAY;@b@@b@ int closeLen = close.length();@b@ int openLen = open.length();@b@ List list = new ArrayList();@b@ int pos = 0;@b@ while (pos < strLen - closeLen) {@b@ int start = str.indexOf(open, pos);@b@ if (start < 0)@b@ break;@b@@b@ start += openLen;@b@ int end = str.indexOf(close, start);@b@ if (end < 0)@b@ break;@b@@b@ list.add(str.substring(start, end));@b@ pos = end + closeLen;@b@ }@b@ if (list.isEmpty())@b@ return null;@b@@b@ return ((String[])list.toArray(new String[list.size()]));@b@ }@b@@b@ public static String[] split(String str)@b@ {@b@ return split(str, null, -1);@b@ }@b@@b@ public static String[] split(String str, char separatorChar)@b@ {@b@ return splitWorker(str, separatorChar, false);@b@ }@b@@b@ public static String[] split(String str, String separatorChars)@b@ {@b@ return splitWorker(str, separatorChars, -1, false);@b@ }@b@@b@ public static String[] split(String str, String separatorChars, int max)@b@ {@b@ return splitWorker(str, separatorChars, max, false);@b@ }@b@@b@ public static String[] splitByWholeSeparator(String str, String separator)@b@ {@b@ return splitByWholeSeparatorWorker(str, separator, -1, false);@b@ }@b@@b@ public static String[] splitByWholeSeparator(String str, String separator, int max)@b@ {@b@ return splitByWholeSeparatorWorker(str, separator, max, false);@b@ }@b@@b@ public static String[] splitByWholeSeparatorPreserveAllTokens(String str, String separator)@b@ {@b@ return splitByWholeSeparatorWorker(str, separator, -1, true);@b@ }@b@@b@ public static String[] splitByWholeSeparatorPreserveAllTokens(String str, String separator, int max)@b@ {@b@ return splitByWholeSeparatorWorker(str, separator, max, true);@b@ }@b@@b@ private static String[] splitByWholeSeparatorWorker(String str, String separator, int max, boolean preserveAllTokens)@b@ {@b@ if (str == null) {@b@ return null;@b@ }@b@@b@ int len = str.length();@b@@b@ if (len == 0) {@b@ return ArrayUtils.EMPTY_STRING_ARRAY;@b@ }@b@@b@ if ((separator == null) || ("".equals(separator)))@b@ {@b@ return splitWorker(str, null, max, preserveAllTokens);@b@ }@b@@b@ int separatorLength = separator.length();@b@@b@ ArrayList substrings = new ArrayList();@b@ int numberOfSubstrings = 0;@b@ int beg = 0;@b@ int end = 0;@b@ while (true) { while (true) { while (true) { while (true) { if (end >= len) break label216;@b@ end = str.indexOf(separator, beg);@b@@b@ if (end <= -1) break label197;@b@ if (end <= beg) break label147;@b@ ++numberOfSubstrings;@b@@b@ if (numberOfSubstrings != max) break;@b@ end = len;@b@ substrings.add(str.substring(beg));@b@ }@b@@b@ substrings.add(str.substring(beg, end));@b@@b@ beg = end + separatorLength;@b@ }@b@@b@ if (preserveAllTokens) {@b@ label147: ++numberOfSubstrings;@b@ if (numberOfSubstrings == max) {@b@ end = len;@b@ substrings.add(str.substring(beg));@b@ } else {@b@ substrings.add("");@b@ }@b@ }@b@ beg = end + separatorLength;@b@ }@b@@b@ label197: substrings.add(str.substring(beg));@b@ end = len;@b@ }@b@@b@ label216: return ((String[])substrings.toArray(new String[substrings.size()]));@b@ }@b@@b@ public static String[] splitPreserveAllTokens(String str)@b@ {@b@ return splitWorker(str, null, -1, true);@b@ }@b@@b@ public static String[] splitPreserveAllTokens(String str, char separatorChar)@b@ {@b@ return splitWorker(str, separatorChar, true);@b@ }@b@@b@ private static String[] splitWorker(String str, char separatorChar, boolean preserveAllTokens)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ int len = str.length();@b@ if (len == 0)@b@ return ArrayUtils.EMPTY_STRING_ARRAY;@b@@b@ List list = new ArrayList();@b@ int i = 0; int start = 0;@b@ boolean match = false;@b@ boolean lastMatch = false;@b@ while (true) { while (true) { if (i >= len) break label109;@b@ if (str.charAt(i) != separatorChar) break;@b@ if ((match) || (preserveAllTokens)) {@b@ list.add(str.substring(start, i));@b@ match = false;@b@ lastMatch = true;@b@ }@b@ start = ++i;@b@ }@b@@b@ lastMatch = false;@b@ match = true;@b@ ++i;@b@ }@b@ if ((match) || ((preserveAllTokens) && (lastMatch)))@b@ label109: list.add(str.substring(start, i));@b@@b@ return ((String[])list.toArray(new String[list.size()]));@b@ }@b@@b@ public static String[] splitPreserveAllTokens(String str, String separatorChars)@b@ {@b@ return splitWorker(str, separatorChars, -1, true);@b@ }@b@@b@ public static String[] splitPreserveAllTokens(String str, String separatorChars, int max)@b@ {@b@ return splitWorker(str, separatorChars, max, true);@b@ }@b@@b@ private static String[] splitWorker(String str, String separatorChars, int max, boolean preserveAllTokens)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ int len = str.length();@b@ if (len == 0)@b@ return ArrayUtils.EMPTY_STRING_ARRAY;@b@@b@ List list = new ArrayList();@b@ int sizePlus1 = 1;@b@ int i = 0; int start = 0;@b@ boolean match = false;@b@ boolean lastMatch = false;@b@ if (separatorChars == null) while (true) {@b@ while (true) {@b@ if (i >= len) break label331;@b@ if (!(Character.isWhitespace(str.charAt(i)))) break;@b@ if ((match) || (preserveAllTokens)) {@b@ lastMatch = true;@b@ if (sizePlus1++ == max) {@b@ i = len;@b@ lastMatch = false;@b@ }@b@ list.add(str.substring(start, i));@b@ match = false;@b@ }@b@ start = ++i;@b@ }@b@@b@ lastMatch = false;@b@ match = true;@b@ ++i;@b@ }@b@ if (separatorChars.length() == 1)@b@ {@b@ char sep = separatorChars.charAt(0);@b@ while (true) { while (true) { if (i >= len) break label239;@b@ if (str.charAt(i) != sep) break;@b@ if ((match) || (preserveAllTokens)) {@b@ lastMatch = true;@b@ if (sizePlus1++ == max) {@b@ i = len;@b@ lastMatch = false;@b@ }@b@ list.add(str.substring(start, i));@b@ match = false;@b@ }@b@ start = ++i;@b@ }@b@@b@ lastMatch = false;@b@ match = true;@b@ label239: ++i; }@b@ } else {@b@ while (true) {@b@ while (true) {@b@ if (i >= len) break label331;@b@ if (separatorChars.indexOf(str.charAt(i)) < 0) break;@b@ if ((match) || (preserveAllTokens)) {@b@ lastMatch = true;@b@ if (sizePlus1++ == max) {@b@ i = len;@b@ lastMatch = false;@b@ }@b@ list.add(str.substring(start, i));@b@ match = false;@b@ }@b@ start = ++i;@b@ }@b@@b@ lastMatch = false;@b@ match = true;@b@ ++i;@b@ }@b@ }@b@ if ((match) || ((preserveAllTokens) && (lastMatch)))@b@ label331: list.add(str.substring(start, i));@b@@b@ return ((String[])list.toArray(new String[list.size()]));@b@ }@b@@b@ public static String[] splitByCharacterType(String str)@b@ {@b@ return splitByCharacterType(str, false);@b@ }@b@@b@ public static String[] splitByCharacterTypeCamelCase(String str)@b@ {@b@ return splitByCharacterType(str, true);@b@ }@b@@b@ private static String[] splitByCharacterType(String str, boolean camelCase)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ if (str.isEmpty())@b@ return ArrayUtils.EMPTY_STRING_ARRAY;@b@@b@ char[] c = str.toCharArray();@b@ List list = new ArrayList();@b@ int tokenStart = 0;@b@ int currentType = Character.getType(c[tokenStart]);@b@ for (int pos = tokenStart + 1; pos < c.length; ++pos) {@b@ int type = Character.getType(c[pos]);@b@ if (type == currentType)@b@ break label162:@b@@b@ if ((camelCase) && (type == 2) && (currentType == 1)) {@b@ int newTokenStart = pos - 1;@b@ if (newTokenStart != tokenStart) {@b@ list.add(new String(c, tokenStart, newTokenStart - tokenStart));@b@ tokenStart = newTokenStart;@b@ }@b@ } else {@b@ list.add(new String(c, tokenStart, pos - tokenStart));@b@ tokenStart = pos;@b@ }@b@ currentType = type;@b@ }@b@ label162: list.add(new String(c, tokenStart, c.length - tokenStart));@b@ return ((String[])list.toArray(new String[list.size()]));@b@ }@b@@b@ public static <T> String join(T[] elements)@b@ {@b@ return join(elements, null);@b@ }@b@@b@ public static String join(Object[] array, char separator)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ return join(array, separator, 0, array.length);@b@ }@b@@b@ public static String join(long[] array, char separator)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ return join(array, separator, 0, array.length);@b@ }@b@@b@ public static String join(int[] array, char separator)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ return join(array, separator, 0, array.length);@b@ }@b@@b@ public static String join(short[] array, char separator)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ return join(array, separator, 0, array.length);@b@ }@b@@b@ public static String join(byte[] array, char separator)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ return join(array, separator, 0, array.length);@b@ }@b@@b@ public static String join(char[] array, char separator)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ return join(array, separator, 0, array.length);@b@ }@b@@b@ public static String join(float[] array, char separator)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ return join(array, separator, 0, array.length);@b@ }@b@@b@ public static String join(double[] array, char separator)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ return join(array, separator, 0, array.length);@b@ }@b@@b@ public static String join(Object[] array, char separator, int startIndex, int endIndex)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ int noOfItems = endIndex - startIndex;@b@ if (noOfItems <= 0)@b@ return "";@b@@b@ StringBuilder buf = new StringBuilder(noOfItems * 16);@b@ for (int i = startIndex; i < endIndex; ++i) {@b@ if (i > startIndex)@b@ buf.append(separator);@b@@b@ if (array[i] != null)@b@ buf.append(array[i]);@b@ }@b@@b@ return buf.toString();@b@ }@b@@b@ public static String join(long[] array, char separator, int startIndex, int endIndex)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ int noOfItems = endIndex - startIndex;@b@ if (noOfItems <= 0)@b@ return "";@b@@b@ StringBuilder buf = new StringBuilder(noOfItems * 16);@b@ for (int i = startIndex; i < endIndex; ++i) {@b@ if (i > startIndex)@b@ buf.append(separator);@b@@b@ buf.append(array[i]);@b@ }@b@ return buf.toString();@b@ }@b@@b@ public static String join(int[] array, char separator, int startIndex, int endIndex)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ int noOfItems = endIndex - startIndex;@b@ if (noOfItems <= 0)@b@ return "";@b@@b@ StringBuilder buf = new StringBuilder(noOfItems * 16);@b@ for (int i = startIndex; i < endIndex; ++i) {@b@ if (i > startIndex)@b@ buf.append(separator);@b@@b@ buf.append(array[i]);@b@ }@b@ return buf.toString();@b@ }@b@@b@ public static String join(byte[] array, char separator, int startIndex, int endIndex)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ int noOfItems = endIndex - startIndex;@b@ if (noOfItems <= 0)@b@ return "";@b@@b@ StringBuilder buf = new StringBuilder(noOfItems * 16);@b@ for (int i = startIndex; i < endIndex; ++i) {@b@ if (i > startIndex)@b@ buf.append(separator);@b@@b@ buf.append(array[i]);@b@ }@b@ return buf.toString();@b@ }@b@@b@ public static String join(short[] array, char separator, int startIndex, int endIndex)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ int noOfItems = endIndex - startIndex;@b@ if (noOfItems <= 0)@b@ return "";@b@@b@ StringBuilder buf = new StringBuilder(noOfItems * 16);@b@ for (int i = startIndex; i < endIndex; ++i) {@b@ if (i > startIndex)@b@ buf.append(separator);@b@@b@ buf.append(array[i]);@b@ }@b@ return buf.toString();@b@ }@b@@b@ public static String join(char[] array, char separator, int startIndex, int endIndex)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ int noOfItems = endIndex - startIndex;@b@ if (noOfItems <= 0)@b@ return "";@b@@b@ StringBuilder buf = new StringBuilder(noOfItems * 16);@b@ for (int i = startIndex; i < endIndex; ++i) {@b@ if (i > startIndex)@b@ buf.append(separator);@b@@b@ buf.append(array[i]);@b@ }@b@ return buf.toString();@b@ }@b@@b@ public static String join(double[] array, char separator, int startIndex, int endIndex)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ int noOfItems = endIndex - startIndex;@b@ if (noOfItems <= 0)@b@ return "";@b@@b@ StringBuilder buf = new StringBuilder(noOfItems * 16);@b@ for (int i = startIndex; i < endIndex; ++i) {@b@ if (i > startIndex)@b@ buf.append(separator);@b@@b@ buf.append(array[i]);@b@ }@b@ return buf.toString();@b@ }@b@@b@ public static String join(float[] array, char separator, int startIndex, int endIndex)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ int noOfItems = endIndex - startIndex;@b@ if (noOfItems <= 0)@b@ return "";@b@@b@ StringBuilder buf = new StringBuilder(noOfItems * 16);@b@ for (int i = startIndex; i < endIndex; ++i) {@b@ if (i > startIndex)@b@ buf.append(separator);@b@@b@ buf.append(array[i]);@b@ }@b@ return buf.toString();@b@ }@b@@b@ public static String join(Object[] array, String separator)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ return join(array, separator, 0, array.length);@b@ }@b@@b@ public static String join(Object[] array, String separator, int startIndex, int endIndex)@b@ {@b@ if (array == null)@b@ return null;@b@@b@ if (separator == null) {@b@ separator = "";@b@ }@b@@b@ int noOfItems = endIndex - startIndex;@b@ if (noOfItems <= 0) {@b@ return "";@b@ }@b@@b@ StringBuilder buf = new StringBuilder(noOfItems * 16);@b@@b@ for (int i = startIndex; i < endIndex; ++i) {@b@ if (i > startIndex)@b@ buf.append(separator);@b@@b@ if (array[i] != null)@b@ buf.append(array[i]);@b@ }@b@@b@ return buf.toString();@b@ }@b@@b@ public static String join(Iterator<?> iterator, char separator)@b@ {@b@ if (iterator == null)@b@ return null;@b@@b@ if (!(iterator.hasNext()))@b@ return "";@b@@b@ Object first = iterator.next();@b@ if (!(iterator.hasNext())) {@b@ return ObjectUtils.toString(first);@b@ }@b@@b@ StringBuilder buf = new StringBuilder(256);@b@ if (first != null) {@b@ buf.append(first);@b@ }@b@@b@ while (iterator.hasNext()) {@b@ buf.append(separator);@b@ Object obj = iterator.next();@b@ if (obj != null)@b@ buf.append(obj);@b@@b@ }@b@@b@ return buf.toString();@b@ }@b@@b@ public static String join(Iterator<?> iterator, String separator)@b@ {@b@ if (iterator == null)@b@ return null;@b@@b@ if (!(iterator.hasNext()))@b@ return "";@b@@b@ Object first = iterator.next();@b@ if (!(iterator.hasNext())) {@b@ return ObjectUtils.toString(first);@b@ }@b@@b@ StringBuilder buf = new StringBuilder(256);@b@ if (first != null) {@b@ buf.append(first);@b@ }@b@@b@ while (iterator.hasNext()) {@b@ if (separator != null)@b@ buf.append(separator);@b@@b@ Object obj = iterator.next();@b@ if (obj != null)@b@ buf.append(obj);@b@ }@b@@b@ return buf.toString();@b@ }@b@@b@ public static String join(Iterable<?> iterable, char separator)@b@ {@b@ if (iterable == null)@b@ return null;@b@@b@ return join(iterable.iterator(), separator);@b@ }@b@@b@ public static String join(Iterable<?> iterable, String separator)@b@ {@b@ if (iterable == null)@b@ return null;@b@@b@ return join(iterable.iterator(), separator);@b@ }@b@@b@ public static String deleteWhitespace(String str)@b@ {@b@ if (isEmpty(str))@b@ return str;@b@@b@ int sz = str.length();@b@ char[] chs = new char[sz];@b@ int count = 0;@b@ for (int i = 0; i < sz; ++i)@b@ if (!(Character.isWhitespace(str.charAt(i))))@b@ chs[(count++)] = str.charAt(i);@b@@b@@b@ if (count == sz)@b@ return str;@b@@b@ return new String(chs, 0, count);@b@ }@b@@b@ public static String removeStart(String str, String remove)@b@ {@b@ if ((isEmpty(str)) || (isEmpty(remove)))@b@ return str;@b@@b@ if (str.startsWith(remove))@b@ return str.substring(remove.length());@b@@b@ return str;@b@ }@b@@b@ public static String removeStartIgnoreCase(String str, String remove)@b@ {@b@ if ((isEmpty(str)) || (isEmpty(remove)))@b@ return str;@b@@b@ if (startsWithIgnoreCase(str, remove))@b@ return str.substring(remove.length());@b@@b@ return str;@b@ }@b@@b@ public static String removeEnd(String str, String remove)@b@ {@b@ if ((isEmpty(str)) || (isEmpty(remove)))@b@ return str;@b@@b@ if (str.endsWith(remove))@b@ return str.substring(0, str.length() - remove.length());@b@@b@ return str;@b@ }@b@@b@ public static String removeEndIgnoreCase(String str, String remove)@b@ {@b@ if ((isEmpty(str)) || (isEmpty(remove)))@b@ return str;@b@@b@ if (endsWithIgnoreCase(str, remove))@b@ return str.substring(0, str.length() - remove.length());@b@@b@ return str;@b@ }@b@@b@ public static String remove(String str, String remove)@b@ {@b@ if ((isEmpty(str)) || (isEmpty(remove)))@b@ return str;@b@@b@ return replace(str, remove, "", -1);@b@ }@b@@b@ public static String remove(String str, char remove)@b@ {@b@ if ((isEmpty(str)) || (str.indexOf(remove) == -1))@b@ return str;@b@@b@ char[] chars = str.toCharArray();@b@ int pos = 0;@b@ for (int i = 0; i < chars.length; ++i)@b@ if (chars[i] != remove)@b@ chars[(pos++)] = chars[i];@b@@b@@b@ return new String(chars, 0, pos);@b@ }@b@@b@ public static String replaceOnce(String text, String searchString, String replacement)@b@ {@b@ return replace(text, searchString, replacement, 1);@b@ }@b@@b@ public static String replacePattern(String source, String regex, String replacement)@b@ {@b@ return Pattern.compile(regex, 32).matcher(source).replaceAll(replacement);@b@ }@b@@b@ public static String removePattern(String source, String regex)@b@ {@b@ return replacePattern(source, regex, "");@b@ }@b@@b@ public static String replace(String text, String searchString, String replacement)@b@ {@b@ return replace(text, searchString, replacement, -1);@b@ }@b@@b@ public static String replace(String text, String searchString, String replacement, int max)@b@ {@b@ if ((isEmpty(text)) || (isEmpty(searchString)) || (replacement == null) || (max == 0))@b@ return text;@b@@b@ int start = 0;@b@ int end = text.indexOf(searchString, start);@b@ if (end == -1)@b@ return text;@b@@b@ int replLength = searchString.length();@b@ int increase = replacement.length() - replLength;@b@ increase = (increase < 0) ? 0 : increase;@b@ increase *= ((max > 64) ? 64 : (max < 0) ? 16 : max);@b@ StringBuilder buf = new StringBuilder(text.length() + increase);@b@ while (end != -1) {@b@ buf.append(text.substring(start, end)).append(replacement);@b@ start = end + replLength;@b@ if (--max == 0)@b@ break;@b@@b@ end = text.indexOf(searchString, start);@b@ }@b@ buf.append(text.substring(start));@b@ return buf.toString();@b@ }@b@@b@ public static String replaceEach(String text, String[] searchList, String[] replacementList)@b@ {@b@ return replaceEach(text, searchList, replacementList, false, 0);@b@ }@b@@b@ public static String replaceEachRepeatedly(String text, String[] searchList, String[] replacementList)@b@ {@b@ int timeToLive = (searchList == null) ? 0 : searchList.length;@b@ return replaceEach(text, searchList, replacementList, true, timeToLive);@b@ }@b@@b@ private static String replaceEach(String text, String[] searchList, String[] replacementList, boolean repeat, int timeToLive)@b@ {@b@ label205: int i;@b@ if ((text == null) || (text.isEmpty()) || (searchList == null) || (searchList.length == 0) || (replacementList == null) || (replacementList.length == 0))@b@ {@b@ return text;@b@ }@b@@b@ if (timeToLive < 0) {@b@ throw new IllegalStateException("Aborting to protect against StackOverflowError - output of one loop is the input of another");@b@ }@b@@b@ int searchLength = searchList.length;@b@ int replacementLength = replacementList.length;@b@@b@ if (searchLength != replacementLength) {@b@ throw new IllegalArgumentException(new StringBuilder().append("Search and Replace array lengths don't match: ").append(searchLength).append(" vs ").append(replacementLength).toString());@b@ }@b@@b@ boolean[] noMoreMatchesForReplIndex = new boolean[searchLength];@b@@b@ int textIndex = -1;@b@ int replaceIndex = -1;@b@ int tempIndex = -1;@b@@b@ for (int i = 0; i < searchLength; ++i) {@b@ if ((noMoreMatchesForReplIndex[i] == 0) && (searchList[i] != null) && (!(searchList[i].isEmpty()))) { if (replacementList[i] == null)@b@ {@b@ break label205:@b@ }@b@ tempIndex = text.indexOf(searchList[i]);@b@@b@ if (tempIndex == -1) {@b@ noMoreMatchesForReplIndex[i] = true;@b@ }@b@ else if ((textIndex == -1) || (tempIndex < textIndex)) {@b@ textIndex = tempIndex;@b@ replaceIndex = i;@b@ }@b@@b@ }@b@@b@ }@b@@b@ if (textIndex == -1) {@b@ return text;@b@ }@b@@b@ int start = 0;@b@@b@ int increase = 0;@b@@b@ for (int i = 0; i < searchList.length; ++i)@b@ if (searchList[i] != null) { if (replacementList[i] == null)@b@ break label283:@b@@b@ int greater = replacementList[i].length() - searchList[i].length();@b@ if (greater > 0)@b@ increase += 3 * greater;@b@ }@b@@b@@b@ label283: increase = Math.min(increase, text.length() / 5);@b@@b@ StringBuilder buf = new StringBuilder(text.length() + increase);@b@@b@ while (textIndex != -1)@b@ {@b@ for (i = start; i < textIndex; ++i)@b@ buf.append(text.charAt(i));@b@@b@ buf.append(replacementList[replaceIndex]);@b@@b@ start = textIndex + searchList[replaceIndex].length();@b@@b@ textIndex = -1;@b@ replaceIndex = -1;@b@ tempIndex = -1;@b@@b@ label477: for (i = 0; i < searchLength; ++i)@b@ if ((noMoreMatchesForReplIndex[i] == 0) && (searchList[i] != null) && (!(searchList[i].isEmpty()))) { if (replacementList[i] == null)@b@ {@b@ break label477:@b@ }@b@ tempIndex = text.indexOf(searchList[i], start);@b@@b@ if (tempIndex == -1) {@b@ noMoreMatchesForReplIndex[i] = true;@b@ }@b@ else if ((textIndex == -1) || (tempIndex < textIndex)) {@b@ textIndex = tempIndex;@b@ replaceIndex = i;@b@ }@b@ }@b@@b@@b@ }@b@@b@ int textLength = text.length();@b@ for (int i = start; i < textLength; ++i)@b@ buf.append(text.charAt(i));@b@@b@ String result = buf.toString();@b@ if (!(repeat)) {@b@ return result;@b@ }@b@@b@ return replaceEach(result, searchList, replacementList, repeat, timeToLive - 1);@b@ }@b@@b@ public static String replaceChars(String str, char searchChar, char replaceChar)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ return str.replace(searchChar, replaceChar);@b@ }@b@@b@ public static String replaceChars(String str, String searchChars, String replaceChars)@b@ {@b@ if ((isEmpty(str)) || (isEmpty(searchChars)))@b@ return str;@b@@b@ if (replaceChars == null)@b@ replaceChars = "";@b@@b@ boolean modified = false;@b@ int replaceCharsLength = replaceChars.length();@b@ int strLength = str.length();@b@ StringBuilder buf = new StringBuilder(strLength);@b@ for (int i = 0; i < strLength; ++i) {@b@ char ch = str.charAt(i);@b@ int index = searchChars.indexOf(ch);@b@ if (index >= 0) {@b@ modified = true;@b@ if (index < replaceCharsLength)@b@ buf.append(replaceChars.charAt(index));@b@ }@b@ else {@b@ buf.append(ch);@b@ }@b@ }@b@ if (modified)@b@ return buf.toString();@b@@b@ return str;@b@ }@b@@b@ public static String overlay(String str, String overlay, int start, int end)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ if (overlay == null)@b@ overlay = "";@b@@b@ int len = str.length();@b@ if (start < 0)@b@ start = 0;@b@@b@ if (start > len)@b@ start = len;@b@@b@ if (end < 0)@b@ end = 0;@b@@b@ if (end > len)@b@ end = len;@b@@b@ if (start > end) {@b@ int temp = start;@b@ start = end;@b@ end = temp;@b@ }@b@ return new StringBuilder(len + start - end + overlay.length() + 1).append(str.substring(0, start)).append(overlay).append(str.substring(end)).toString();@b@ }@b@@b@ public static String chomp(String str)@b@ {@b@ if (isEmpty(str)) {@b@ return str;@b@ }@b@@b@ if (str.length() == 1) {@b@ char ch = str.charAt(0);@b@ if ((ch == '\r') || (ch == '\n'))@b@ return "";@b@@b@ return str;@b@ }@b@@b@ int lastIdx = str.length() - 1;@b@ char last = str.charAt(lastIdx);@b@@b@ if (last == '\n')@b@ if (str.charAt(lastIdx - 1) == '\r')@b@ --lastIdx;@b@@b@ else if (last != '\r')@b@ ++lastIdx;@b@@b@ return str.substring(0, lastIdx);@b@ }@b@@b@ @Deprecated@b@ public static String chomp(String str, String separator)@b@ {@b@ return removeEnd(str, separator);@b@ }@b@@b@ public static String chop(String str)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ int strLen = str.length();@b@ if (strLen < 2)@b@ return "";@b@@b@ int lastIdx = strLen - 1;@b@ String ret = str.substring(0, lastIdx);@b@ char last = str.charAt(lastIdx);@b@ if ((last == '\n') && (ret.charAt(lastIdx - 1) == '\r'))@b@ return ret.substring(0, lastIdx - 1);@b@@b@ return ret;@b@ }@b@@b@ public static String repeat(String str, int repeat)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ if (repeat <= 0)@b@ return "";@b@@b@ int inputLength = str.length();@b@ if ((repeat == 1) || (inputLength == 0))@b@ return str;@b@@b@ if ((inputLength == 1) && (repeat <= 8192)) {@b@ return repeat(str.charAt(0), repeat);@b@ }@b@@b@ int outputLength = inputLength * repeat;@b@ switch (inputLength)@b@ {@b@ case 1:@b@ return repeat(str.charAt(0), repeat);@b@ case 2:@b@ char ch0 = str.charAt(0);@b@ char ch1 = str.charAt(1);@b@ char[] output2 = new char[outputLength];@b@ for (int i = repeat * 2 - 2; i >= 0; ) {@b@ output2[i] = ch0;@b@ output2[(i + 1)] = ch1;@b@@b@ --i; --i;@b@ }@b@@b@ return new String(output2);@b@ }@b@ StringBuilder buf = new StringBuilder(outputLength);@b@ for (int i = 0; i < repeat; ++i)@b@ buf.append(str);@b@@b@ return buf.toString();@b@ }@b@@b@ public static String repeat(String str, String separator, int repeat)@b@ {@b@ if ((str == null) || (separator == null)) {@b@ return repeat(str, repeat);@b@ }@b@@b@ String result = repeat(new StringBuilder().append(str).append(separator).toString(), repeat);@b@ return removeEnd(result, separator);@b@ }@b@@b@ public static String repeat(char ch, int repeat)@b@ {@b@ char[] buf = new char[repeat];@b@ for (int i = repeat - 1; i >= 0; --i)@b@ buf[i] = ch;@b@@b@ return new String(buf);@b@ }@b@@b@ public static String rightPad(String str, int size)@b@ {@b@ return rightPad(str, size, ' ');@b@ }@b@@b@ public static String rightPad(String str, int size, char padChar)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ int pads = size - str.length();@b@ if (pads <= 0)@b@ return str;@b@@b@ if (pads > 8192)@b@ return rightPad(str, size, String.valueOf(padChar));@b@@b@ return str.concat(repeat(padChar, pads));@b@ }@b@@b@ public static String rightPad(String str, int size, String padStr)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ if (isEmpty(padStr))@b@ padStr = " ";@b@@b@ int padLen = padStr.length();@b@ int strLen = str.length();@b@ int pads = size - strLen;@b@ if (pads <= 0)@b@ return str;@b@@b@ if ((padLen == 1) && (pads <= 8192)) {@b@ return rightPad(str, size, padStr.charAt(0));@b@ }@b@@b@ if (pads == padLen)@b@ return str.concat(padStr);@b@ if (pads < padLen)@b@ return str.concat(padStr.substring(0, pads));@b@@b@ char[] padding = new char[pads];@b@ char[] padChars = padStr.toCharArray();@b@ for (int i = 0; i < pads; ++i)@b@ padding[i] = padChars[(i % padLen)];@b@@b@ return str.concat(new String(padding));@b@ }@b@@b@ public static String leftPad(String str, int size)@b@ {@b@ return leftPad(str, size, ' ');@b@ }@b@@b@ public static String leftPad(String str, int size, char padChar)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ int pads = size - str.length();@b@ if (pads <= 0)@b@ return str;@b@@b@ if (pads > 8192)@b@ return leftPad(str, size, String.valueOf(padChar));@b@@b@ return repeat(padChar, pads).concat(str);@b@ }@b@@b@ public static String leftPad(String str, int size, String padStr)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ if (isEmpty(padStr))@b@ padStr = " ";@b@@b@ int padLen = padStr.length();@b@ int strLen = str.length();@b@ int pads = size - strLen;@b@ if (pads <= 0)@b@ return str;@b@@b@ if ((padLen == 1) && (pads <= 8192)) {@b@ return leftPad(str, size, padStr.charAt(0));@b@ }@b@@b@ if (pads == padLen)@b@ return padStr.concat(str);@b@ if (pads < padLen)@b@ return padStr.substring(0, pads).concat(str);@b@@b@ char[] padding = new char[pads];@b@ char[] padChars = padStr.toCharArray();@b@ for (int i = 0; i < pads; ++i)@b@ padding[i] = padChars[(i % padLen)];@b@@b@ return new String(padding).concat(str);@b@ }@b@@b@ public static int length(CharSequence cs)@b@ {@b@ return ((cs == null) ? 0 : cs.length());@b@ }@b@@b@ public static String center(String str, int size)@b@ {@b@ return center(str, size, ' ');@b@ }@b@@b@ public static String center(String str, int size, char padChar)@b@ {@b@ if ((str == null) || (size <= 0))@b@ return str;@b@@b@ int strLen = str.length();@b@ int pads = size - strLen;@b@ if (pads <= 0)@b@ return str;@b@@b@ str = leftPad(str, strLen + pads / 2, padChar);@b@ str = rightPad(str, size, padChar);@b@ return str;@b@ }@b@@b@ public static String center(String str, int size, String padStr)@b@ {@b@ if ((str == null) || (size <= 0))@b@ return str;@b@@b@ if (isEmpty(padStr))@b@ padStr = " ";@b@@b@ int strLen = str.length();@b@ int pads = size - strLen;@b@ if (pads <= 0)@b@ return str;@b@@b@ str = leftPad(str, strLen + pads / 2, padStr);@b@ str = rightPad(str, size, padStr);@b@ return str;@b@ }@b@@b@ public static String upperCase(String str)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ return str.toUpperCase();@b@ }@b@@b@ public static String upperCase(String str, Locale locale)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ return str.toUpperCase(locale);@b@ }@b@@b@ public static String lowerCase(String str)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ return str.toLowerCase();@b@ }@b@@b@ public static String lowerCase(String str, Locale locale)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ return str.toLowerCase(locale);@b@ }@b@@b@ public static String capitalize(String str)@b@ {@b@ int strLen;@b@ if (str != null) if ((strLen = str.length()) != 0) break label15;@b@ return str;@b@@b@ label15: char firstChar = str.charAt(0);@b@ if (Character.isTitleCase(firstChar))@b@ {@b@ return str;@b@ }@b@@b@ return new StringBuilder(strLen).append(Character.toTitleCase(firstChar)).append(str.substring(1)).toString();@b@ }@b@@b@ public static String uncapitalize(String str)@b@ {@b@ int strLen;@b@ if (str != null) if ((strLen = str.length()) != 0) break label15;@b@ return str;@b@@b@ label15: char firstChar = str.charAt(0);@b@ if (Character.isLowerCase(firstChar))@b@ {@b@ return str;@b@ }@b@@b@ return new StringBuilder(strLen).append(Character.toLowerCase(firstChar)).append(str.substring(1)).toString();@b@ }@b@@b@ public static String swapCase(String str)@b@ {@b@ if (isEmpty(str)) {@b@ return str;@b@ }@b@@b@ char[] buffer = str.toCharArray();@b@@b@ for (int i = 0; i < buffer.length; ++i) {@b@ char ch = buffer[i];@b@ if (Character.isUpperCase(ch))@b@ buffer[i] = Character.toLowerCase(ch);@b@ else if (Character.isTitleCase(ch))@b@ buffer[i] = Character.toLowerCase(ch);@b@ else if (Character.isLowerCase(ch))@b@ buffer[i] = Character.toUpperCase(ch);@b@ }@b@@b@ return new String(buffer);@b@ }@b@@b@ public static int countMatches(CharSequence str, CharSequence sub)@b@ {@b@ if ((isEmpty(str)) || (isEmpty(sub)))@b@ return 0;@b@@b@ int count = 0;@b@ int idx = 0;@b@ while ((idx = CharSequenceUtils.indexOf(str, sub, idx)) != -1) {@b@ ++count;@b@ idx += sub.length();@b@ }@b@ return count;@b@ }@b@@b@ public static boolean isAlpha(CharSequence cs)@b@ {@b@ if (isEmpty(cs))@b@ return false;@b@@b@ int sz = cs.length();@b@ for (int i = 0; i < sz; ++i)@b@ if (!(Character.isLetter(cs.charAt(i))))@b@ return false;@b@@b@@b@ return true;@b@ }@b@@b@ public static boolean isAlphaSpace(CharSequence cs)@b@ {@b@ if (cs == null)@b@ return false;@b@@b@ int sz = cs.length();@b@ for (int i = 0; i < sz; ++i)@b@ if ((!(Character.isLetter(cs.charAt(i)))) && (cs.charAt(i) != ' '))@b@ return false;@b@@b@@b@ return true;@b@ }@b@@b@ public static boolean isAlphanumeric(CharSequence cs)@b@ {@b@ if (isEmpty(cs))@b@ return false;@b@@b@ int sz = cs.length();@b@ for (int i = 0; i < sz; ++i)@b@ if (!(Character.isLetterOrDigit(cs.charAt(i))))@b@ return false;@b@@b@@b@ return true;@b@ }@b@@b@ public static boolean isAlphanumericSpace(CharSequence cs)@b@ {@b@ if (cs == null)@b@ return false;@b@@b@ int sz = cs.length();@b@ for (int i = 0; i < sz; ++i)@b@ if ((!(Character.isLetterOrDigit(cs.charAt(i)))) && (cs.charAt(i) != ' '))@b@ return false;@b@@b@@b@ return true;@b@ }@b@@b@ public static boolean isAsciiPrintable(CharSequence cs)@b@ {@b@ if (cs == null)@b@ return false;@b@@b@ int sz = cs.length();@b@ for (int i = 0; i < sz; ++i)@b@ if (!(CharUtils.isAsciiPrintable(cs.charAt(i))))@b@ return false;@b@@b@@b@ return true;@b@ }@b@@b@ public static boolean isNumeric(CharSequence cs)@b@ {@b@ if (isEmpty(cs))@b@ return false;@b@@b@ int sz = cs.length();@b@ for (int i = 0; i < sz; ++i)@b@ if (!(Character.isDigit(cs.charAt(i))))@b@ return false;@b@@b@@b@ return true;@b@ }@b@@b@ public static boolean isNumericSpace(CharSequence cs)@b@ {@b@ if (cs == null)@b@ return false;@b@@b@ int sz = cs.length();@b@ for (int i = 0; i < sz; ++i)@b@ if ((!(Character.isDigit(cs.charAt(i)))) && (cs.charAt(i) != ' '))@b@ return false;@b@@b@@b@ return true;@b@ }@b@@b@ public static boolean isWhitespace(CharSequence cs)@b@ {@b@ if (cs == null)@b@ return false;@b@@b@ int sz = cs.length();@b@ for (int i = 0; i < sz; ++i)@b@ if (!(Character.isWhitespace(cs.charAt(i))))@b@ return false;@b@@b@@b@ return true;@b@ }@b@@b@ public static boolean isAllLowerCase(CharSequence cs)@b@ {@b@ if ((cs == null) || (isEmpty(cs)))@b@ return false;@b@@b@ int sz = cs.length();@b@ for (int i = 0; i < sz; ++i)@b@ if (!(Character.isLowerCase(cs.charAt(i))))@b@ return false;@b@@b@@b@ return true;@b@ }@b@@b@ public static boolean isAllUpperCase(CharSequence cs)@b@ {@b@ if ((cs == null) || (isEmpty(cs)))@b@ return false;@b@@b@ int sz = cs.length();@b@ for (int i = 0; i < sz; ++i)@b@ if (!(Character.isUpperCase(cs.charAt(i))))@b@ return false;@b@@b@@b@ return true;@b@ }@b@@b@ public static String defaultString(String str)@b@ {@b@ return ((str == null) ? "" : str);@b@ }@b@@b@ public static String defaultString(String str, String defaultStr)@b@ {@b@ return ((str == null) ? defaultStr : str);@b@ }@b@@b@ public static <T extends CharSequence> T defaultIfBlank(T str, T defaultStr)@b@ {@b@ return ((isBlank(str)) ? defaultStr : str);@b@ }@b@@b@ public static <T extends CharSequence> T defaultIfEmpty(T str, T defaultStr)@b@ {@b@ return ((isEmpty(str)) ? defaultStr : str);@b@ }@b@@b@ public static String reverse(String str)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ return new StringBuilder(str).reverse().toString();@b@ }@b@@b@ public static String reverseDelimited(String str, char separatorChar)@b@ {@b@ if (str == null) {@b@ return null;@b@ }@b@@b@ String[] strs = split(str, separatorChar);@b@ ArrayUtils.reverse(strs);@b@ return join(strs, separatorChar);@b@ }@b@@b@ public static String abbreviate(String str, int maxWidth)@b@ {@b@ return abbreviate(str, 0, maxWidth);@b@ }@b@@b@ public static String abbreviate(String str, int offset, int maxWidth)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ if (maxWidth < 4)@b@ throw new IllegalArgumentException("Minimum abbreviation width is 4");@b@@b@ if (str.length() <= maxWidth)@b@ return str;@b@@b@ if (offset > str.length())@b@ offset = str.length();@b@@b@ if (str.length() - offset < maxWidth - 3)@b@ offset = str.length() - maxWidth - 3;@b@@b@ String abrevMarker = "...";@b@ if (offset <= 4)@b@ return new StringBuilder().append(str.substring(0, maxWidth - 3)).append("...").toString();@b@@b@ if (maxWidth < 7)@b@ throw new IllegalArgumentException("Minimum abbreviation width with offset is 7");@b@@b@ if (offset + maxWidth - 3 < str.length())@b@ return new StringBuilder().append("...").append(abbreviate(str.substring(offset), maxWidth - 3)).toString();@b@@b@ return new StringBuilder().append("...").append(str.substring(str.length() - maxWidth - 3)).toString();@b@ }@b@@b@ public static String abbreviateMiddle(String str, String middle, int length)@b@ {@b@ if ((isEmpty(str)) || (isEmpty(middle))) {@b@ return str;@b@ }@b@@b@ if ((length >= str.length()) || (length < middle.length() + 2)) {@b@ return str;@b@ }@b@@b@ int targetSting = length - middle.length();@b@ int startOffset = targetSting / 2 + targetSting % 2;@b@ int endOffset = str.length() - targetSting / 2;@b@@b@ StringBuilder builder = new StringBuilder(length);@b@ builder.append(str.substring(0, startOffset));@b@ builder.append(middle);@b@ builder.append(str.substring(endOffset));@b@@b@ return builder.toString();@b@ }@b@@b@ public static String difference(String str1, String str2)@b@ {@b@ if (str1 == null)@b@ return str2;@b@@b@ if (str2 == null)@b@ return str1;@b@@b@ int at = indexOfDifference(str1, str2);@b@ if (at == -1)@b@ return "";@b@@b@ return str2.substring(at);@b@ }@b@@b@ public static int indexOfDifference(CharSequence cs1, CharSequence cs2)@b@ {@b@ if (cs1 == cs2)@b@ return -1;@b@@b@ if ((cs1 == null) || (cs2 == null)) {@b@ return 0;@b@ }@b@@b@ for (int i = 0; (i < cs1.length()) && (i < cs2.length()); ++i)@b@ if (cs1.charAt(i) != cs2.charAt(i))@b@ break;@b@@b@@b@ if ((i < cs2.length()) || (i < cs1.length()))@b@ return i;@b@@b@ return -1;@b@ }@b@@b@ public static int indexOfDifference(CharSequence[] css)@b@ {@b@ if ((css == null) || (css.length <= 1))@b@ return -1;@b@@b@ boolean anyStringNull = false;@b@ boolean allStringsNull = true;@b@ int arrayLen = css.length;@b@ int shortestStrLen = 2147483647;@b@ int longestStrLen = 0;@b@@b@ for (int i = 0; i < arrayLen; ++i) {@b@ if (css[i] == null) {@b@ anyStringNull = true;@b@ shortestStrLen = 0;@b@ } else {@b@ allStringsNull = false;@b@ shortestStrLen = Math.min(css[i].length(), shortestStrLen);@b@ longestStrLen = Math.max(css[i].length(), longestStrLen);@b@ }@b@@b@ }@b@@b@ if ((allStringsNull) || ((longestStrLen == 0) && (!(anyStringNull)))) {@b@ return -1;@b@ }@b@@b@ if (shortestStrLen == 0) {@b@ return 0;@b@ }@b@@b@ int firstDiff = -1;@b@ for (int stringPos = 0; stringPos < shortestStrLen; ++stringPos) {@b@ char comparisonChar = css[0].charAt(stringPos);@b@ for (int arrayPos = 1; arrayPos < arrayLen; ++arrayPos)@b@ if (css[arrayPos].charAt(stringPos) != comparisonChar) {@b@ firstDiff = stringPos;@b@ break;@b@ }@b@@b@ if (firstDiff != -1)@b@ break;@b@@b@ }@b@@b@ if ((firstDiff == -1) && (shortestStrLen != longestStrLen))@b@ {@b@ return shortestStrLen;@b@ }@b@ return firstDiff;@b@ }@b@@b@ public static String getCommonPrefix(String[] strs)@b@ {@b@ if ((strs == null) || (strs.length == 0))@b@ return "";@b@@b@ int smallestIndexOfDiff = indexOfDifference(strs);@b@ if (smallestIndexOfDiff == -1)@b@ {@b@ if (strs[0] == null)@b@ return "";@b@@b@ return strs[0]; }@b@ if (smallestIndexOfDiff == 0)@b@ {@b@ return "";@b@ }@b@@b@ return strs[0].substring(0, smallestIndexOfDiff);@b@ }@b@@b@ public static int getLevenshteinDistance(CharSequence s, CharSequence t)@b@ {@b@ if ((s == null) || (t == null)) {@b@ throw new IllegalArgumentException("Strings must not be null");@b@ }@b@@b@ int n = s.length();@b@ int m = t.length();@b@@b@ if (n == 0)@b@ return m;@b@ if (m == 0) {@b@ return n;@b@ }@b@@b@ if (n > m)@b@ {@b@ CharSequence tmp = s;@b@ s = t;@b@ t = tmp;@b@ n = m;@b@ m = t.length();@b@ }@b@@b@ int[] p = new int[n + 1];@b@ int[] d = new int[n + 1];@b@@b@ for (int i = 0; i <= n; ++i) {@b@ p[i] = i;@b@ }@b@@b@ for (int j = 1; j <= m; ++j) {@b@ char t_j = t.charAt(j - 1);@b@ d[0] = j;@b@@b@ for (i = 1; i <= n; ++i) {@b@ int cost = (s.charAt(i - 1) == t_j) ? 0 : 1;@b@@b@ d[i] = Math.min(Math.min(d[(i - 1)] + 1, p[i] + 1), p[(i - 1)] + cost);@b@ }@b@@b@ int[] _d = p;@b@ p = d;@b@ d = _d;@b@ }@b@@b@ return p[n];@b@ }@b@@b@ public static int getLevenshteinDistance(CharSequence s, CharSequence t, int threshold)@b@ {@b@ if ((s == null) || (t == null))@b@ throw new IllegalArgumentException("Strings must not be null");@b@@b@ if (threshold < 0) {@b@ throw new IllegalArgumentException("Threshold must not be negative");@b@ }@b@@b@ int n = s.length();@b@ int m = t.length();@b@@b@ if (n == 0)@b@ return ((m <= threshold) ? m : -1);@b@ if (m == 0) {@b@ return ((n <= threshold) ? n : -1);@b@ }@b@@b@ if (n > m)@b@ {@b@ CharSequence tmp = s;@b@ s = t;@b@ t = tmp;@b@ n = m;@b@ m = t.length();@b@ }@b@@b@ int[] p = new int[n + 1];@b@ int[] d = new int[n + 1];@b@@b@ int boundary = Math.min(n, threshold) + 1;@b@ for (int i = 0; i < boundary; ++i) {@b@ p[i] = i;@b@ }@b@@b@ Arrays.fill(p, boundary, p.length, 2147483647);@b@ Arrays.fill(d, 2147483647);@b@@b@ for (int j = 1; j <= m; ++j) {@b@ char t_j = t.charAt(j - 1);@b@ d[0] = j;@b@@b@ int min = Math.max(1, j - threshold);@b@ int max = Math.min(n, j + threshold);@b@@b@ if (min > max) {@b@ return -1;@b@ }@b@@b@ if (min > 1) {@b@ d[(min - 1)] = 2147483647;@b@ }@b@@b@ for (int i = min; i <= max; ++i) {@b@ if (s.charAt(i - 1) == t_j)@b@ {@b@ d[i] = p[(i - 1)];@b@ }@b@ else {@b@ d[i] = (1 + Math.min(Math.min(d[(i - 1)], p[i]), p[(i - 1)]));@b@ }@b@@b@ }@b@@b@ int[] _d = p;@b@ p = d;@b@ d = _d;@b@ }@b@@b@ if (p[n] <= threshold)@b@ return p[n];@b@@b@ return -1;@b@ }@b@@b@ public static boolean startsWith(CharSequence str, CharSequence prefix)@b@ {@b@ return startsWith(str, prefix, false);@b@ }@b@@b@ public static boolean startsWithIgnoreCase(CharSequence str, CharSequence prefix)@b@ {@b@ return startsWith(str, prefix, true);@b@ }@b@@b@ private static boolean startsWith(CharSequence str, CharSequence prefix, boolean ignoreCase)@b@ {@b@ if ((str == null) || (prefix == null))@b@ return ((str == null) && (prefix == null));@b@@b@ if (prefix.length() > str.length())@b@ return false;@b@@b@ return CharSequenceUtils.regionMatches(str, ignoreCase, 0, prefix, 0, prefix.length());@b@ }@b@@b@ public static boolean startsWithAny(CharSequence string, CharSequence[] searchStrings)@b@ {@b@ if ((isEmpty(string)) || (ArrayUtils.isEmpty(searchStrings)))@b@ return false;@b@@b@ CharSequence[] arr$ = searchStrings; int len$ = arr$.length; for (int i$ = 0; i$ < len$; ++i$) { CharSequence searchString = arr$[i$];@b@ if (startsWith(string, searchString))@b@ return true;@b@ }@b@@b@ return false;@b@ }@b@@b@ public static boolean endsWith(CharSequence str, CharSequence suffix)@b@ {@b@ return endsWith(str, suffix, false);@b@ }@b@@b@ public static boolean endsWithIgnoreCase(CharSequence str, CharSequence suffix)@b@ {@b@ return endsWith(str, suffix, true);@b@ }@b@@b@ private static boolean endsWith(CharSequence str, CharSequence suffix, boolean ignoreCase)@b@ {@b@ if ((str == null) || (suffix == null))@b@ return ((str == null) && (suffix == null));@b@@b@ if (suffix.length() > str.length())@b@ return false;@b@@b@ int strOffset = str.length() - suffix.length();@b@ return CharSequenceUtils.regionMatches(str, ignoreCase, strOffset, suffix, 0, suffix.length());@b@ }@b@@b@ public static String normalizeSpace(String str)@b@ {@b@ if (str == null)@b@ return null;@b@@b@ return WHITESPACE_PATTERN.matcher(trim(str)).replaceAll(" ");@b@ }@b@@b@ public static boolean endsWithAny(CharSequence string, CharSequence[] searchStrings)@b@ {@b@ if ((isEmpty(string)) || (ArrayUtils.isEmpty(searchStrings)))@b@ return false;@b@@b@ CharSequence[] arr$ = searchStrings; int len$ = arr$.length; for (int i$ = 0; i$ < len$; ++i$) { CharSequence searchString = arr$[i$];@b@ if (endsWith(string, searchString))@b@ return true;@b@ }@b@@b@ return false;@b@ }@b@@b@ private static String appendIfMissing(String str, CharSequence suffix, boolean ignoreCase, CharSequence[] suffixes)@b@ {@b@ CharSequence[] arr$;@b@ int i$;@b@ if ((str == null) || (isEmpty(suffix)) || (endsWith(str, suffix, ignoreCase)))@b@ return str;@b@@b@ if ((suffixes != null) && (suffixes.length > 0)) {@b@ arr$ = suffixes; int len$ = arr$.length; for (i$ = 0; i$ < len$; ++i$) { CharSequence s = arr$[i$];@b@ if (endsWith(str, s, ignoreCase))@b@ return str;@b@ }@b@ }@b@@b@ return new StringBuilder().append(str).append(suffix.toString()).toString();@b@ }@b@@b@ public static String appendIfMissing(String str, CharSequence suffix, CharSequence[] suffixes)@b@ {@b@ return appendIfMissing(str, suffix, false, suffixes);@b@ }@b@@b@ public static String appendIfMissingIgnoreCase(String str, CharSequence suffix, CharSequence[] suffixes)@b@ {@b@ return appendIfMissing(str, suffix, true, suffixes);@b@ }@b@@b@ private static String prependIfMissing(String str, CharSequence prefix, boolean ignoreCase, CharSequence[] prefixes)@b@ {@b@ CharSequence[] arr$;@b@ int i$;@b@ if ((str == null) || (isEmpty(prefix)) || (startsWith(str, prefix, ignoreCase)))@b@ return str;@b@@b@ if ((prefixes != null) && (prefixes.length > 0)) {@b@ arr$ = prefixes; int len$ = arr$.length; for (i$ = 0; i$ < len$; ++i$) { CharSequence p = arr$[i$];@b@ if (startsWith(str, p, ignoreCase))@b@ return str;@b@ }@b@ }@b@@b@ return new StringBuilder().append(prefix.toString()).append(str).toString();@b@ }@b@@b@ public static String prependIfMissing(String str, CharSequence prefix, CharSequence[] prefixes)@b@ {@b@ return prependIfMissing(str, prefix, false, prefixes);@b@ }@b@@b@ public static String prependIfMissingIgnoreCase(String str, CharSequence prefix, CharSequence[] prefixes)@b@ {@b@ return prependIfMissing(str, prefix, true, prefixes);@b@ }@b@@b@ /**@b@ * @deprecated@b@ */@b@ public static String toString(byte[] bytes, String charsetName)@b@ throws UnsupportedEncodingException@b@ {@b@ return new String(bytes, Charset.defaultCharset());@b@ }@b@@b@ public static String toEncodedString(byte[] bytes, Charset charset)@b@ throws UnsupportedEncodingException@b@ {@b@ return new String(bytes, Charset.defaultCharset());@b@ }@b@}