public static String clean(String str) { CharSequence result = clean((CharSequence) str); return result!=null?result.toString():null; }
/** * Check whether the given String has actual text. * More specifically, returns <code>true</code> if the string not <code>null</code>, * its length is greater than 0, and it contains at least one non-whitespace character. * @param str the String to check (may be <code>null</code>) * @return <code>true</code> if the String is not <code>null</code>, its length is * greater than 0, and it does not contain whitespace only * @see #hasText(CharSequence) */ public static boolean hasText(String str) { return hasText((CharSequence) str); }
/** * Remove duplicate Strings from the given array. * Also sorts the array, as it uses a TreeSet. * @param array the String array * @return an array without duplicates, in natural sort order */ public static String[] removeDuplicateStrings(String[] array) { if (Objects.isEmpty(array)) { return array; } Set<String> set = new TreeSet<String>(); for (String element : array) { set.add(element); } return toStringArray(set); }
if ("".equals(delimiter)) { for (int i = 0; i < str.length(); i++) { result.add(deleteAny(str.substring(i, i + 1), charsToDelete)); int delPos; while ((delPos = str.indexOf(delimiter, pos)) != -1) { result.add(deleteAny(str.substring(pos, delPos), charsToDelete)); pos = delPos + delimiter.length(); result.add(deleteAny(str.substring(pos), charsToDelete)); return toStringArray(result);
return null; String pathToUse = replace(path, WINDOWS_FOLDER_SEPARATOR, FOLDER_SEPARATOR); String[] pathArray = delimitedListToStringArray(pathToUse, FOLDER_SEPARATOR); List<String> pathElements = new LinkedList<String>(); int tops = 0; return prefix + collectionToDelimitedString(pathElements, FOLDER_SEPARATOR);
/** * Convenience method to return a Collection as a CSV String. * E.g. useful for <code>toString()</code> implementations. * @param coll the Collection to display * @return the delimited String */ public static String collectionToCommaDelimitedString(Collection<?> coll) { return collectionToDelimitedString(coll, ","); }
/** * Capitalize a <code>String</code>, changing the first letter to * upper case as per {@link Character#toUpperCase(char)}. * No other letters are changed. * @param str the String to capitalize, may be <code>null</code> * @return the capitalized String, <code>null</code> if null */ public static String capitalize(String str) { return changeFirstCharacterCase(str, true); }
/** * Check whether the given String contains any whitespace characters. * @param str the String to check (may be <code>null</code>) * @return <code>true</code> if the String is not empty and * contains at least 1 whitespace character * @see #containsWhitespace(CharSequence) */ public static boolean containsWhitespace(String str) { return containsWhitespace((CharSequence) str); }
/** * Compare two paths after normalization of them. * @param path1 first path for comparison * @param path2 second path for comparison * @return whether the two paths are equivalent after normalization */ public static boolean pathEquals(String path1, String path2) { return cleanPath(path1).equals(cleanPath(path2)); }
/** * Convenience method to return a String array as a CSV String. * E.g. useful for <code>toString()</code> implementations. * @param arr the array to display * @return the delimited String */ public static String arrayToCommaDelimitedString(Object[] arr) { return arrayToDelimitedString(arr, ","); }
/** * Convenience method to convert a CSV string list to a set. * Note that this will suppress duplicates. * @param str the input String * @return a Set of String entries in the list */ public static Set<String> commaDelimitedListToSet(String str) { Set<String> set = new TreeSet<String>(); String[] tokens = commaDelimitedListToStringArray(str); for (String token : tokens) { set.add(token); } return set; }
return null; String pathToUse = replace(path, WINDOWS_FOLDER_SEPARATOR, FOLDER_SEPARATOR); String[] pathArray = delimitedListToStringArray(pathToUse, FOLDER_SEPARATOR); List<String> pathElements = new LinkedList<String>(); int tops = 0; return prefix + collectionToDelimitedString(pathElements, FOLDER_SEPARATOR);
if ("".equals(delimiter)) { for (int i = 0; i < str.length(); i++) { result.add(deleteAny(str.substring(i, i + 1), charsToDelete)); int delPos; while ((delPos = str.indexOf(delimiter, pos)) != -1) { result.add(deleteAny(str.substring(pos, delPos), charsToDelete)); pos = delPos + delimiter.length(); result.add(deleteAny(str.substring(pos), charsToDelete)); return toStringArray(result);
/** * Convenience method to return a Collection as a delimited (e.g. CSV) * String. E.g. useful for <code>toString()</code> implementations. * @param coll the Collection to display * @param delim the delimiter to use (probably a ",") * @return the delimited String */ public static String collectionToDelimitedString(Collection<?> coll, String delim) { return collectionToDelimitedString(coll, delim, "", ""); }
/** * Uncapitalize a <code>String</code>, changing the first letter to * lower case as per {@link Character#toLowerCase(char)}. * No other letters are changed. * @param str the String to uncapitalize, may be <code>null</code> * @return the uncapitalized String, <code>null</code> if null */ public static String uncapitalize(String str) { return changeFirstCharacterCase(str, false); }
/** * Check whether the given String contains any whitespace characters. * @param str the String to check (may be <code>null</code>) * @return <code>true</code> if the String is not empty and * contains at least 1 whitespace character * @see #containsWhitespace(CharSequence) */ public static boolean containsWhitespace(String str) { return containsWhitespace((CharSequence) str); }