public class WordUtil extends Object
Conversion between singular and plural form of a noun word.
| 限定符和类型 | 字段和说明 |
|---|---|
static Map<String,String> |
plural2singles |
static List<String> |
plurals |
static Map<String,String> |
single2plurals |
static List<String> |
singles |
| 构造器和说明 |
|---|
WordUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
addPlural(String single,
String plural)
Adds more pairs of single and plural words.
|
static String |
camelize(String word)
Converts string to Camel case.
|
static String |
camelize(String word,
boolean firstLetterInLowerCase)
Converts string to Camel case.
|
static String |
classify(String tableName)
Returns a entityClass class tableName corresponding to the input database
table tableName.
|
static String |
humanize(String phase)
Replaces all dashes and underscores by spaces and capitalizes the first
word.
|
static boolean |
isEmpty(String str) |
static String |
ordinalize(int number)
Returns an ordinalized string.
|
static String |
pluralize(String word)
Returns a pluralized word.
|
static String |
removeEnd(String str,
String remove) |
static String |
replaceLast(String data,
String oldSymbol,
String newSymbol)
Replaces the last occurance of an old symbol with a new symbol.
|
static String |
singularize(String word)
Returns a singularized word from a plural word.
|
static String |
tableize(String modelClassName)
Returns a database table tableName corresponding to the input entityClass class
tableName.
|
static String |
titleize(String phase)
Replaces all dashes and underscores by spaces and capitalizes all the words.
|
static String |
underscore(String phase)
underscore is the reverse of camelize method.
|
public static String pluralize(String word)
word - the word to be converted to plural formpublic static String singularize(String word)
word - the word to be converted to singular formpublic static String replaceLast(String data, String oldSymbol, String newSymbol)
data - the original stringoldSymbol - the old symbols to be replacednewSymbol - the corresponding new symbolpublic static void addPlural(String single, String plural)
single - singular form of the wordplural - plural form of the wordpublic static String camelize(String word)
word - the word to be converted to camelized formpublic static String camelize(String word, boolean firstLetterInLowerCase)
Examples:
camelize("hello") "Hello"
camelize("hello world") "Hello world"
camelize("active_record") "ActiveRecord"
camelize("active_record", true) "activeRecord"
word - the word to be converted to camelized formfirstLetterInLowerCase - true if the first character should be in lower casepublic static String underscore(String phase)
Examples:
underscore("Hello world") "hello world"
underscore("ActiveRecord") "active_record"
underscore("The RedCross") "the red_cross"
underscore("ABCD") "abcd"
phase - the original stringpublic static String titleize(String phase)
Examples:
titleize("ch 1: Java-ActiveRecordIsFun") "Ch 1: Java Active Record Is Fun"
phase - the original stringpublic static String humanize(String phase)
Examples:
humanize("active_record") "Active record"
humanize("post_id") "Post"
phase - the original stringpublic static String tableize(String modelClassName)
Examples:
tableize("Person") "people"
tableize("LineItem") "line_items"
modelClassName - public static String classify(String tableName)
Examples:
classify("people") "Person"
classify("line_items") "LineItem"
tableName - java class tableName of the entityClasspublic static boolean isEmpty(String str)
public static String ordinalize(int number)
Examples: ordinalize(100) "100th" ordinalize(1003) "1003rd"
number - the numberCopyright © 2020 com.github.braisdom. All rights reserved.