Java Utililty Methods String Pluralize

List of utility methods to do String Pluralize

Description

The list of methods to do String Pluralize are organized into topic(s).

Method

Stringplural(String txt)
plural
if (txt.endsWith("y"))
    return txt.substring(0, txt.length() - 1) + "ies";
if (txt.endsWith("h"))
    return txt + "es";
return txt + "s";
Stringplural(String type)
plural
int len = type.length();
if (type.substring(len - 1, len).equals("y")) {
    return type.substring(0, len - 1) + "ies";
} else if (!(type.substring(len - 1, len).equals("s"))) {
    return type.concat("s");
} else {
    return type;
Stringplural(String word)
plural
if (word.endsWith("y") && !word.endsWith("ay") && !word.endsWith("ey") && !word.endsWith("oy")
        && !word.endsWith("uy")) {
    word = word.subSequence(0, word.length() - 1).toString() + "ies";
} else if (word.endsWith("ss")) {
    word = word + "es";
} else if (!word.endsWith("s")) {
    word = word + "s";
return word;
Stringplural(String word, Number cardinality)
Returns the plural form of the specified word if cardinality != 1.
String suffix = "s";
char lastChar = word.charAt(word.length() - 1);
if (lastChar == 'h' || lastChar == 's' || lastChar == 'x') {
    suffix = "es";
return plural(word, suffix, cardinality);
StringBufferplural(StringBuffer buffer, int i, String s1, String s2)
plural
buffer.append(i);
buffer.append(" ");
if (i > 1 || i == 0) {
    buffer.append(s1);
} else {
    buffer.append(s2);
return buffer;
...
StringpluralForm(final String string, final int number)
Return a default plural form string.
return (number == 1) ? string : (string + "s");
Stringpluralify(String term, int value)
pluralify
term = (Math.abs(value) == 1) ? term : term + "s";
return " " + term;
Stringpluralise(int count, String singular, String plural)
pluralise
return (count == 1) ? singular : plural;
Stringpluralise(int num, String word)
E.g.
return (num == 1 ? word : word + "s");
Stringpluralise(String name)
Utility methods used to convert DB object names to appropriate Java type and field name
if (name == null || "".equals(name))
    return "";
String result = name;
if (name.length() == 1) {
    result += 's';
} else if (!seemsPluralised(name)) {
    String lower = name.toLowerCase();
    if (!lower.endsWith("data")) { 
...