Github user ansell commented on a diff in the pull request: https://github.com/apache/any23/pull/32#discussion_r95259126 --- Diff: core/src/main/java/org/apache/any23/util/StringUtils.java --- @@ -146,31 +149,59 @@ public static String escapeDoubleQuotes(String in) { } /** - * Escapes the <code>in</code> string as <b>JSON</b> string - * to let it being embeddable within a string field. + * Escapes the <code>in</code> string as <b>JSON</b> string to let it being + * embeddable within a string field. * * @param in string to be escaped. * @return escaped string. */ public static String escapeAsJSONString(String in) { - return escapeDoubleQuotes( in.replaceAll("\n", "\\\\n") ); + return escapeDoubleQuotes(in.replaceAll("\n", "\\\\n")); } /** - * Builds a string composed of the given char <code>c</code> <code>n</code> times. + * Builds a string composed of the given char <code>c</code> <code>n</code> + * times. * * @param c char to be multiplied. * @param times number of times. * @return the string containing the multiplied char. */ public static String multiply(char c, int times) { - if(times <= 0) throw new IllegalArgumentException("Invalid number of times, must be > 0 ."); + if (times <= 0) { + throw new IllegalArgumentException("Invalid number of times, must be > 0 ."); + } final char[] buffer = new char[times]; - for(int i = 0; i < times; i++) { + for (int i = 0; i < times; i++) { buffer[i] = c; } return new String(buffer); } - private StringUtils() {} + /** + * Changes string with following convention: + * <ul> + * <li>Changes '-' -> '_' + * <li>remove space characters and make first letter word uppercase: 'some + * string' -> 'someString' + * </ul> + * + * @param in + * @return + */ + public static String implementJavaNaming(String in) { + in = in.trim() + .replaceAll("-", "_") + .toLowerCase(); + + if (Pattern.matches("\\S+(\\s+\\S+)+", in)) { + String[] words = in.split("\\s", 2); + in = words[0] + WordUtils.capitalize(words[1]); --- End diff -- The tests only test for two-word combinations. Need more unit tests for this method with longer word combinations.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---