@Test public void testToLabel() { Assert.assertEquals("Test", NamingUtil.toLabel("Test")); Assert.assertEquals("Test", NamingUtil.toLabel("test")); Assert.assertEquals("Test Codes", NamingUtil.toLabel("TestCodes")); Assert.assertEquals("Test Codes", NamingUtil.toLabel("testCodes")); Assert.assertEquals("Test Codes Form Z", NamingUtil.toLabel("TestCodesFormZ")); Assert.assertEquals("", NamingUtil.toLabel("")); }
public static String toLabel(String name) { if (StringUtil.isEmpty(name)) { return ""; } String label = name.startsWith("get")?name.replaceFirst("get", ""):name; StringBuilder buffer = new StringBuilder(); for (int i=0; i<label.length();i++) { if (i==0) { buffer.append(label.substring(0, 1).toUpperCase()); } else { if (label.charAt(i) >= 'A' && label.charAt(i)<= 'Z') { buffer.append(" "); } buffer.append(label.charAt(i)); } } return buffer.toString(); }
NamingUtil { public static String toLabel(String name) { if (StringUtil.isEmpty(name)) { return ""; } String label = name.startsWith("get")?name.replaceFirst("get", ""):name; StringBuilder buffer = new StringBuilder(); for (int i=0; i<label.length();i++) { if (i==0) { buffer.append(label.substring(0, 1).toUpperCase()); } else { if (label.charAt(i) >= 'A' && label.charAt(i)<= 'Z') { buffer.append(" "); } buffer.append(label.charAt(i)); } } return buffer.toString(); } }
NamingUtil { public static String toLabel(String name) { if (StringUtil.isEmpty(name)) { return ""; } String label = name.startsWith("get")?name.replaceFirst("get", ""):name; StringBuilder buffer = new StringBuilder(); for (int i=0; i<label.length();i++) { if (i==0) { buffer.append(label.substring(0, 1).toUpperCase()); } else { if (label.charAt(i) >= 'A' && label.charAt(i)<= 'Z') { buffer.append(" "); } buffer.append(label.charAt(i)); } } return buffer.toString(); } private  NamingUtil(); }
NamingUtil { public static String toLabel(String name) { if (StringUtil.isEmpty(name)) { return ""; } String label = name.startsWith("get")?name.replaceFirst("get", ""):name; StringBuilder buffer = new StringBuilder(); for (int i=0; i<label.length();i++) { if (i==0) { buffer.append(label.substring(0, 1).toUpperCase()); } else { if (label.charAt(i) >= 'A' && label.charAt(i)<= 'Z') { buffer.append(" "); } buffer.append(label.charAt(i)); } } return buffer.toString(); } private  NamingUtil(); static String toLabel(String name); static String toGetterName(String name); static String toSetterName(String name); static String toAttributeName(String name); static String toElementName(String name); static String toDisplayName(String name); static String toSQLName(String name); static String getPropertyName(String methodName); static String getSimpleName(String qualifiedName); static String getPackageName(String qualifiedName); }
NamingUtil { public static String toLabel(String name) { if (StringUtil.isEmpty(name)) { return ""; } String label = name.startsWith("get")?name.replaceFirst("get", ""):name; StringBuilder buffer = new StringBuilder(); for (int i=0; i<label.length();i++) { if (i==0) { buffer.append(label.substring(0, 1).toUpperCase()); } else { if (label.charAt(i) >= 'A' && label.charAt(i)<= 'Z') { buffer.append(" "); } buffer.append(label.charAt(i)); } } return buffer.toString(); } private  NamingUtil(); static String toLabel(String name); static String toGetterName(String name); static String toSetterName(String name); static String toAttributeName(String name); static String toElementName(String name); static String toDisplayName(String name); static String toSQLName(String name); static String getPropertyName(String methodName); static String getSimpleName(String qualifiedName); static String getPackageName(String qualifiedName);  }