@Test public void testToConstName() { final String input = "Tĥïŝ-ĩš â__fůňķŷ_Šťŕĭńġ.äÄüÿÆ¼.!/\\?+*]{[}$#@@!$%^&&ß!$%&'()*+,-./:;<=>?@[\\]^_`{|}~\""; final String expected= "THIS_IS_A_FUNKY_STRING_AEAEUEYAE14_SS"; final String actual= BundleNormalizer.toConstName(input); assertThat(actual).isEqualTo(expected); }
public static String toConstName(String s) { Require.nonNull(s, "parameter s may not be null or empty."); Require.nonWhitespace(s, "parameter s may not be null or empty."); s= normalize(s); final char[] chars= s.toCharArray(); final StringBuilder sb= new StringBuilder(); if (Character.isDigit(chars[0])) { sb.append("_"); } for (int i=0; i<chars.length; i++) { sb.append(Character.toUpperCase(chars[i])); } return sb.toString(); }
BundleNormalizer { public static String toConstName(String s) { Require.nonNull(s, "parameter s may not be null or empty."); Require.nonWhitespace(s, "parameter s may not be null or empty."); s= normalize(s); final char[] chars= s.toCharArray(); final StringBuilder sb= new StringBuilder(); if (Character.isDigit(chars[0])) { sb.append("_"); } for (int i=0; i<chars.length; i++) { sb.append(Character.toUpperCase(chars[i])); } return sb.toString(); } }
BundleNormalizer { public static String toConstName(String s) { Require.nonNull(s, "parameter s may not be null or empty."); Require.nonWhitespace(s, "parameter s may not be null or empty."); s= normalize(s); final char[] chars= s.toCharArray(); final StringBuilder sb= new StringBuilder(); if (Character.isDigit(chars[0])) { sb.append("_"); } for (int i=0; i<chars.length; i++) { sb.append(Character.toUpperCase(chars[i])); } return sb.toString(); }  }
BundleNormalizer { public static String toConstName(String s) { Require.nonNull(s, "parameter s may not be null or empty."); Require.nonWhitespace(s, "parameter s may not be null or empty."); s= normalize(s); final char[] chars= s.toCharArray(); final StringBuilder sb= new StringBuilder(); if (Character.isDigit(chars[0])) { sb.append("_"); } for (int i=0; i<chars.length; i++) { sb.append(Character.toUpperCase(chars[i])); } return sb.toString(); }  static String toClassName(String s); static String toFieldName(String s); static String toConstName(String s); static String toBundleName(String s); }
BundleNormalizer { public static String toConstName(String s) { Require.nonNull(s, "parameter s may not be null or empty."); Require.nonWhitespace(s, "parameter s may not be null or empty."); s= normalize(s); final char[] chars= s.toCharArray(); final StringBuilder sb= new StringBuilder(); if (Character.isDigit(chars[0])) { sb.append("_"); } for (int i=0; i<chars.length; i++) { sb.append(Character.toUpperCase(chars[i])); } return sb.toString(); }  static String toClassName(String s); static String toFieldName(String s); static String toConstName(String s); static String toBundleName(String s);  }