List of utility methods to do String Pluralize
String | plural(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"; |
String | plural(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; |
String | plural(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; |
String | plural(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); |
StringBuffer | plural(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; ... |
String | pluralForm(final String string, final int number) Return a default plural form string. return (number == 1) ? string : (string + "s"); |
String | pluralify(String term, int value) pluralify term = (Math.abs(value) == 1) ? term : term + "s"; return " " + term; |
String | pluralise(int count, String singular, String plural) pluralise return (count == 1) ? singular : plural;
|
String | pluralise(int num, String word) E.g. return (num == 1 ? word : word + "s"); |
String | pluralise(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")) { ... |