Java Utililty Methods String Plural

List of utility methods to do String Plural

  1. HOME
  2. Java
  3. S
  4. String Plural

Description

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

Method

String toPlural(String _str)
to Plural
String plural;
if (_str != null && _str.length() > 0) {
 char ch = _str.charAt(_str.length() - 1);
 StringBuffer pluralBuffer = new StringBuffer(_str);
 if (ch == 's' || ch == 'x') {
 pluralBuffer.append("es");
 } else if (ch == 'y') {
 pluralBuffer.setLength(pluralBuffer.length() - 1);
...
String toPlural(String candidate)
Converts string to plural form
if (candidate.length() >= 1 && !candidate.endsWith("s")) {
 return candidate + "s";
return candidate;
String toPlural(String name)
to Plural
if (name.endsWith("y")) {
 int length = name.length();
 name = name.substring(0, length - 2);
 return name + "ies";
if (name.endsWith("s"))
 return name + "es";
if (name.equalsIgnoreCase("child"))
...
String toPlural(String name)
to Plural
if (name.endsWith("y")) {
 if (name.length() > 1)
 return name.substring(0, name.length() - 1) + "ies";
 else
 return "ys";
} else if (name.endsWith("x")) {
 if (name.length() > 1)
 return name + "es";
...
String toPluralForm(String propertyName)
to Plural Form
String endString;
if (propertyName.endsWith("Parson") || propertyName.endsWith("parson")) {
 propertyName = propertyName.replace("Parson", "");
 propertyName = propertyName.replace("parson", "");
 if ("".equals(propertyName)) {
 endString = "people";
 } else {
 endString = "People";
...

AltStyle によって変換されたページ (->オリジナル) /