Here you can find the source of pluralise(String name)
public static String pluralise(String name)
//package com.java2s; /**/*from w ww. ja va 2 s. c o m*/ SpagoBI, the Open Source Business Intelligence suite Copyright (C) 2012 Engineering Ingegneria Informatica S.p.A. - SpagoBI Competency Center This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. **/ public class Main { /** * Utility methods used to convert DB object names to * appropriate Java type and field name */ public static String pluralise(String 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")) { //orderData --> orderDatas is dumb char secondLast = lower.charAt(name.length() - 2); if (!isVowel(secondLast) && lower.endsWith("y")) { // city, body etc --> cities, bodies result = name.substring(0, name.length() - 1) + "ies"; } else if (lower.endsWith("ch") || lower.endsWith("s")) { // switch --> switches or bus --> buses result = name + "es"; } else { result = name + "s"; } } } return result; } private static boolean seemsPluralised(String name) { name = name.toLowerCase(); boolean pluralised = false; pluralised |= name.endsWith("es"); pluralised |= name.endsWith("s"); pluralised &= !(name.endsWith("ss") || name.endsWith("us")); return pluralised; } private final static boolean isVowel(char c) { boolean vowel = false; vowel |= c == 'a'; vowel |= c == 'e'; vowel |= c == 'i'; vowel |= c == 'o'; vowel |= c == 'u'; vowel |= c == 'y'; return vowel; } }