Modifier and Type | Method and Description |
---|---|
String |
camelize(String word)
Convert the given word to camel case.
|
String |
camelize(String word,
boolean lower)
Convert the given word to camel case.
|
String |
capitalize(String word)
Capitalize the given string.
|
String |
classify(String text)
Convert the given word to class name.
|
String |
dasherize(String word)
Convert the give word to dasherized form.
|
String |
ellipsize(String text,
int length)
Shorten the given text upto the length by appending three ellipses.
|
static Inflector |
getInstance() |
String |
humanize(String word)
Convert the given word to human readable form.
|
String |
ordinalize(int number)
Return ordinal suffixed string for the given number.
|
String |
pluralize(String word)
Returns the plural form of the word in the given string.
|
String |
simplify(String text)
Simplify the text to its unaccented version.
|
String |
singularize(String word)
Returns the singular form of the word in the given string.
|
String |
tableize(String camelCase)
Convert the given word to table name.
|
String |
titleize(String word)
Convert the given string to nicer looking title string.
|
String |
underscore(String camelCase)
Convert the given string to underscored, lowercase form.
|
public static Inflector getInstance()
public String pluralize(String word)
inflection.pluralize("post"); // "posts" inflection.pluralize("child"); // "children" inflection.pluralize("octopus"); // "octopi" inflection.pluralize("sheep"); // "sheep"
word
- the string to pluralizepublic String singularize(String word)
inflection.singularize("posts"); // "post" inflection.singularize("children"); // "child" inflection.singularize("octopi"); // "octopus" inflection.singularize("sheep"); // "sheep"
word
- the string to singularizepublic String camelize(String word, boolean lower)
inflection.camelcase("address_book", false); // "AddressBook" inflection.camelcase("address-book", true); // "addressBook" inflection.camelcase("Address book", false); // "AddressBook"
word
- the word to convertlower
- whether to create lower camel casepublic String camelize(String word)
inflection.camelcase("address_book"); // "AddressBook" inflection.camelcase("address-book"); // "AddressBook" inflection.camelcase("Address book"); // "AddressBook"
word
- the word to convertpublic String underscore(String camelCase)
inflection.underscore("AddressBook"); // "address_book" inflection.underscore("address-book"); // "address_book" inflection.underscore("Address book"); // "address_book"
camelCase
- the string to convertpublic String humanize(String word)
inflection.humanize("contact_id"); // "Contact" inflection.humanize("address_list"); // "Addresses" inflection.humanize("_id"); // "Id"
word
- the string to convertpublic String titleize(String word)
inflection.titleize("address_book"); // "Address Book" inflection.titleize("My address_book"); // "My Address Book"
word
- the string to convertpublic String tableize(String camelCase)
inflection.tableize("AddressBook"); // "address_books" inflection.tableize("Contact"); // "contacts"
camelCase
- the string to convertpublic String classify(String text)
inflection.tableize("address_books"); // "AddressBook" inflection.tableize("contacts"); // "Contact"
text
- the string to convertpublic String dasherize(String word)
inflection.tableize("address_books"); // "address-book" inflection.tableize("AddressBook"); // "address-book"
word
- the string to convertpublic String capitalize(String word)
word
- the string to convertpublic String ordinalize(int number)
inflection.ordinalize(1); // "1st" inflection.ordinalize(2); // "2nd" inflection.ordinalize(3); // "3rd" inflection.ordinalize(100); // "100th" inflection.ordinalize(103); // "103rd" inflection.ordinalize(10013); // "10013th"
number
- the number to suffixpublic String ellipsize(String text, int length)
text
- text to shortenlength
- desired lengthpublic String simplify(String text)
It uses Normalizer.normalize(CharSequence, java.text.Normalizer.Form)
with Normalizer.Form.NFD
normalization and then replaces accented characters with their equivalent unaccented
characters.
text
- the text to normalize