/** * Capitalizes all the words and replaces some characters in the string to create a nicer looking title. Underscores are * changed to spaces, a trailing "_id" is removed, and any of the supplied tokens are removed. Like * {@link #humanize(String, String[])}, this is meant for creating pretty output. * <p> * Examples: * * <pre> * inflector.titleCase("man from the boondocks") #=> "Man From The Boondocks" * inflector.titleCase("x-men: the last stand") #=> "X Men: The Last Stand" * </pre> * * </p> * * @param words the input to be turned into title case * @param removableTokens optional array of tokens that are to be removed * @return the title-case version of the supplied words */ public String titleCase( String words, String... removableTokens ) { String result = humanize(words, removableTokens); result = replaceAllWithUppercase(result, "\\b([a-z])", 1); // change first char of each word to uppercase return result; }
/** * Capitalizes all the words and replaces some characters in the string to create a nicer looking title. Underscores are * changed to spaces, a trailing "_id" is removed, and any of the supplied tokens are removed. Like * {@link #humanize(String, String[])}, this is meant for creating pretty output. * <p> * Examples: * * <pre> * inflector.titleCase("man from the boondocks") #=> "Man From The Boondocks" * inflector.titleCase("x-men: the last stand") #=> "X Men: The Last Stand" * </pre> * * </p> * * @param words the input to be turned into title case * @param removableTokens optional array of tokens that are to be removed * @return the title-case version of the supplied words */ public String titleCase( String words, String... removableTokens ) { String result = humanize(words, removableTokens); result = replaceAllWithUppercase(result, "\\b([a-z])", 1); // change first char of each word to uppercase return result; }
/** * Capitalizes all the words and replaces some characters in the string to create a nicer looking title. Underscores are * changed to spaces, a trailing "_id" is removed, and any of the supplied tokens are removed. Like * {@link #humanize(String, String[])}, this is meant for creating pretty output. * <p> * Examples: * * <pre> * inflector.titleCase("man from the boondocks") #=> "Man From The Boondocks" * inflector.titleCase("x-men: the last stand") #=> "X Men: The Last Stand" * </pre> * * </p> * * @param words the input to be turned into title case * @param removableTokens optional array of tokens that are to be removed * @return the title-case version of the supplied words */ public String titleCase( String words, String... removableTokens ) { String result = humanize(words, removableTokens); result = replaceAllWithUppercase(result, "\\b([a-z])", 1); // change first char of each word to uppercase return result; }
/** * Set the human-readable label for the property. If null, this will be set to the * {@link Inflector#humanize(String, String...) humanized} form of the {@link #getName() property name}. * * @param label the new label for the property; may be null */ public void setLabel( String label ) { if (label == null && name != null) { label = INFLECTOR.titleCase(INFLECTOR.humanize(INFLECTOR.underscore(name))); } this.label = label; }
/** * Set the human-readable label for the property. If null, this will be set to the * {@link Inflector#humanize(String, String...) humanized} form of the {@link #getName() property name}. * * @param label the new label for the property; may be null */ public void setLabel( String label ) { if (label == null && name != null) { label = INFLECTOR.titleCase(INFLECTOR.humanize(INFLECTOR.underscore(name))); } this.label = label; }
/** * Set the human-readable label for the property. If null, this will be set to the * {@link Inflector#humanize(String, String...) humanized} form of the {@link #getName() property name}. * * @param label the new label for the property; may be null */ public void setLabel( String label ) { if (label == null && name != null) { label = INFLECTOR.titleCase(INFLECTOR.humanize(INFLECTOR.underscore(name))); } this.label = label; }
public void humanize( String word, String expectedValue, String... removableTokens ) { // Test humanizing the word String actualValue = inflector.humanize(word, removableTokens); assertEquals(expectedValue, actualValue); }