/** * <p>Capitalizes all the whitespace separated words in a String. * Only the first letter of each word is changed.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. * A <code>null</code> input String returns <code>null</code>.</p> * * @param str the String to capitalize, may be null * @return capitalized String, <code>null</code> if null String input * @deprecated Use the relocated {@link WordUtils#capitalize(String)}. * Method will be removed in Commons Lang 3.0. */ public static String capitaliseAllWords(String str) { return WordUtils.capitalize(str); }
/** * <p>Converts all the whitespace separated words in a String into capitalized words, * that is each word is made up of a titlecase character and then a series of * lowercase characters. </p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. * A <code>null</code> input String returns <code>null</code>. * Capitalization uses the unicode title case, normally equivalent to * upper case.</p> * * <pre> * WordUtils.capitalizeFully(null) = null * WordUtils.capitalizeFully("") = "" * WordUtils.capitalizeFully("i am FINE") = "I Am Fine" * </pre> * * @param str the String to capitalize, may be null * @return capitalized String, <code>null</code> if null String input */ public static String capitalizeFully(String str) { return capitalizeFully(str, null); }
/** * <p>Wraps a single line of text, identifying words by <code>' '</code>.</p> * * <p>New lines will be separated by the system property line separator. * Very long words, such as URLs will <i>not</i> be wrapped.</p> * * <p>Leading spaces on a new line are stripped. * Trailing spaces are not stripped.</p> * * <pre> * WordUtils.wrap(null, *) = null * WordUtils.wrap("", *) = "" * </pre> * * @param str the String to be word wrapped, may be null * @param wrapLength the column to wrap the words at, less than 1 is treated as 1 * @return a line with newlines inserted, <code>null</code> if null input */ public static String wrap(String str, int wrapLength) { return wrap(str, wrapLength, null, false); }
public String evaluate(String s, Boolean fully) { if (s == null || fully == null) { return null; } if (fully) { return WordUtils.capitalizeFully(s); } else { return WordUtils.capitalize(s); } }
private static String renderJavaName(String name, String keywordSuffix, boolean firstCharLowerCase) { // First, strip off any custom suffix if (name.endsWith("__c") || name.endsWith("__r")) { name = name.substring(0, name.length() - CUSTOM_POSTFIX_LENGTH); } // Convert to camelCase name = WordUtils.capitalize(name, new char[]{'_'}); //Remove all underscores ('_') name = name.replace("_", ""); // If the name we're going to generate is a Java keyword // then we'll tweak it with the suffix argument if (SourceVersion.isKeyword(name.toLowerCase())) { name = name + keywordSuffix; } // Enforce the desired case on the first character if (firstCharLowerCase) { name = WordUtils.uncapitalize(name); } else { name = WordUtils.capitalize(name); } return name; } }
/** * <p>Uncapitalizes all the whitespace separated words in a String. * Only the first letter of each word is changed.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. * A <code>null</code> input String returns <code>null</code>.</p> * * <pre> * WordUtils.uncapitalize(null) = null * WordUtils.uncapitalize("") = "" * WordUtils.uncapitalize("I Am FINE") = "i am fINE" * </pre> * * @param str the String to uncapitalize, may be null * @return uncapitalized String, <code>null</code> if null String input * @see #capitalize(String) */ public static String uncapitalize(String str) { return uncapitalize(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); }
/** * Changes string with following convention: * <ul> * <li>Changes '-' -> '_' * <li>remove space characters and make first letter word uppercase: 'some * string' -> 'someString' * </ul> * If input string does not contains a whitespace than return unchanged. * * @param in an input string to convert to Java code convention * @return the correctly formatter string as per Java spec. */ public static String implementJavaNaming(String in) { in = in.trim().replaceAll("-", "_"); // If no white chars found inside a string return uncapitalized if (in.trim().matches("\\S+")) { return WordUtils.uncapitalize(in); } in = in.toLowerCase(); if (Pattern.matches("\\S+(\\s+\\S+)+", in)) { String[] words = in.split("\\s", 2); in = words[0] + WordUtils.capitalize(words[1]).replaceAll("\\s", ""); } return in; }
public static String toCamelCase(String str) { return WordUtils.uncapitalize(str); }
/** * 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>Capitalizes all the whitespace separated words in a String. * Only the first letter of each word is changed. To convert the * rest of each word to lowercase at the same time, * use {@link #capitalizeFully(String)}.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. * A <code>null</code> input String returns <code>null</code>. * Capitalization uses the unicode title case, normally equivalent to * upper case.</p> * * <pre> * WordUtils.capitalize(null) = null * WordUtils.capitalize("") = "" * WordUtils.capitalize("i am FINE") = "I Am FINE" * </pre> * * @param str the String to capitalize, may be null * @return capitalized String, <code>null</code> if null String input * @see #uncapitalize(String) * @see #capitalizeFully(String) */ public static String capitalize(String str) { return capitalize(str, null); }
@Override public Text evaluate(Text s) { if (s == null) { return null; } t.set(WordUtils.capitalizeFully(s.toString())); return t; } });
/** * Format strings for command line output * * @param unformattedText * @param indentFirstLine * @param indentBalance * @return */ private String indentFormat( String unformattedText, int indentFirstLine, int indentBalance ) { final int maxWidth = 79; String leadLine = WordUtils.wrap( unformattedText, maxWidth - indentFirstLine ); StringBuilder result = new StringBuilder(); result.append( "\n" ); if ( leadLine.indexOf( NEW_LINE ) == -1 ) { result.append( NEW_LINE ).append( StringUtils.repeat( " ", indentFirstLine ) ).append( unformattedText ); } else { int lineBreakPoint = leadLine.indexOf( NEW_LINE ); String indentString = StringUtils.repeat( " ", indentBalance ); result.append( NEW_LINE ).append( StringUtils.repeat( " ", indentFirstLine ) ).append( leadLine.substring( 0, lineBreakPoint ) ); String formattedText = WordUtils.wrap( unformattedText.substring( lineBreakPoint ), maxWidth - indentBalance ); for ( String line : formattedText.split( NEW_LINE ) ) { result.append( NEW_LINE ).append( indentString ).append( line ); } } return result.toString(); }
public static String toCamelCase(String str) { return WordUtils.uncapitalize(str); }
/** * <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); }
return capitalize(str, delimiters);
@Override public Text evaluate(Text s) { if (s == null) { return null; } t.set(WordUtils.capitalizeFully(s.toString())); return t; } });
String descr = "# " + WordUtils.wrap(opt.getDescription(), WRAP_COLUMNS, "\n# ", false); String dt = "# Data Type: "; if (opt.getDatatype().isArray()) { dt += opt.getDatatype().getSimpleName() + " enum:"; String s = "\n# " + "{ " + Joiner.on(", ").join(names) + " }"; dt += WordUtils.wrap(s, WRAP_COLUMNS, "\n# ", false); } else { dt += opt.getDatatype().getSimpleName(); "this file's copy of this setting is ignored. Use Titan's Management " + "System to read or modify this value after bootstrapping."; mut += WordUtils.wrap(warning, WRAP_COLUMNS, "\n# ", false);
/** * <p>Uncapitalizes all the whitespace separated words in a String. * Only the first letter of each word is changed.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. * A <code>null</code> input String returns <code>null</code>.</p> * * <pre> * WordUtils.uncapitalize(null) = null * WordUtils.uncapitalize("") = "" * WordUtils.uncapitalize("I Am FINE") = "i am fINE" * </pre> * * @param str the String to uncapitalize, may be null * @return uncapitalized String, <code>null</code> if null String input * @see #capitalize(String) */ public static String uncapitalize(String str) { return uncapitalize(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); }