/** * <p>Extracts the initial letters from each word in the String.</p> * * <p>The first letter of the string and all first letters after * whitespace are returned as a new string. * Their case is not changed.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. * A <code>null</code> input String returns <code>null</code>.</p> * * <pre> * WordUtils.initials(null) = null * WordUtils.initials("") = "" * WordUtils.initials("Ben John Lee") = "BJL" * WordUtils.initials("Ben J.Lee") = "BJ" * </pre> * * @param str the String to get initials from, may be null * @return String of initial letters, <code>null</code> if null String input * @see #initials(String,char[]) * @since 2.2 */ public static String initials(String str) { return initials(str, null); }
/** * rrd datasources must be less than 21 characters in length, so work to * make it shorter. Not ideal at all, but works fairly well it seems. */ public String getDataSourceName(String typeName, String attributeName, List<String> valuePath) { String result; String entry = StringUtils.join(valuePath, '.'); if (typeName != null) { result = typeName + attributeName + entry; } else { result = attributeName + entry; } if (attributeName.length() > 15) { String[] split = StringUtils.splitByCharacterTypeCamelCase(attributeName); String join = StringUtils.join(split, '.'); attributeName = WordUtils.initials(join, INITIALS); } result = attributeName + DigestUtils.md5Hex(result); result = StringUtils.left(result, 19); return result; }
/** * <p>Extracts the initial letters from each word in the String.</p> * * <p>The first letter of the string and all first letters after * whitespace are returned as a new string. * Their case is not changed.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. * A <code>null</code> input String returns <code>null</code>.</p> * * <pre> * WordUtils.initials(null) = null * WordUtils.initials("") = "" * WordUtils.initials("Ben John Lee") = "BJL" * WordUtils.initials("Ben J.Lee") = "BJ" * </pre> * * @param str the String to get initials from, may be null * @return String of initial letters, <code>null</code> if null String input * @see #initials(String,char[]) * @since 2.2 */ public static String initials(String str) { return initials(str, null); }
/** * <p>Extracts the initial letters from each word in the String.</p> * * <p>The first letter of the string and all first letters after * whitespace are returned as a new string. * Their case is not changed.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. * A <code>null</code> input String returns <code>null</code>.</p> * * <pre> * WordUtils.initials(null) = null * WordUtils.initials("") = "" * WordUtils.initials("Ben John Lee") = "BJL" * WordUtils.initials("Ben J.Lee") = "BJ" * </pre> * * @param str the String to get initials from, may be null * @return String of initial letters, <code>null</code> if null String input * @see #initials(String,char[]) * @since 2.2 */ public static String initials(String str) { return initials(str, null); }
/** * <p>Extracts the initial letters from each word in the String.</p> * * <p>The first letter of the string and all first letters after * whitespace are returned as a new string. * Their case is not changed.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. * A <code>null</code> input String returns <code>null</code>.</p> * * <pre> * WordUtils.initials(null) = null * WordUtils.initials("") = "" * WordUtils.initials("Ben John Lee") = "BJL" * WordUtils.initials("Ben J.Lee") = "BJ" * </pre> * * @param str the String to get initials from, may be null * @return String of initial letters, <code>null</code> if null String input * @see #initials(String,char[]) * @since 2.2 */ public static String initials(String str) { return initials(str, null); }
/** * <p>Extracts the initial letters from each word in the String.</p> * * <p>The first letter of the string and all first letters after * whitespace are returned as a new string. * Their case is not changed.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. * A <code>null</code> input String returns <code>null</code>.</p> * * <pre> * WordUtils.initials(null) = null * WordUtils.initials("") = "" * WordUtils.initials("Ben John Lee") = "BJL" * WordUtils.initials("Ben J.Lee") = "BJ" * </pre> * * @param str the String to get initials from, may be null * @return String of initial letters, <code>null</code> if null String input * @see #initials(String,char[]) * @since 2.2 */ public static String initials(String str) { return initials(str, null); }
/** * <p>Extracts the initial letters from each word in the String.</p> * * <p>The first letter of the string and all first letters after * whitespace are returned as a new string. * Their case is not changed.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. * A <code>null</code> input String returns <code>null</code>.</p> * * <pre> * WordUtils.initials(null) = null * WordUtils.initials("") = "" * WordUtils.initials("Ben John Lee") = "BJL" * WordUtils.initials("Ben J.Lee") = "BJ" * </pre> * * @param str the String to get initials from, may be null * @return String of initial letters, <code>null</code> if null String input * @see #initials(String,char[]) * @since 2.2 */ public static String initials(String str) { return initials(str, null); }