Back to project page sqlite-analyzer.
The source code is released under:
Apache License
If you think the Android project sqlite-analyzer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.novoda.sqlite; // ww w. j a va2s . co m import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; // Taken from novoda/typewriter public class StringUtil { public static final String SET = "set"; public static final String GET = "get"; public static String camelify(String original) { if (original == null) { return ""; } StringBuilder builder = new StringBuilder(); Pattern p = Pattern.compile("[a-zA-Z0-9]+"); Matcher m = p.matcher(original); String word; while (m.find()) { word = m.group(); builder.append(capitalize(word)); } return builder.toString(); } private static String capitalize(String string) { if (string.length() > 1) { return string.substring(0, 1).toUpperCase(Locale.US) + string.substring(1).toLowerCase(Locale.US); } return ""; } public static String snakify(String original) { if (original == null || original.length() == 0) { return ""; } StringBuilder builder = new StringBuilder(); Pattern p = Pattern.compile("[A-Z][a-z0-9]+"); Matcher m = p.matcher(original); String word; while (m.find()) { word = m.group(); builder.append(word.toLowerCase()); if (!m.hitEnd()) { builder.append('_'); } } if (builder.length() == 0) { return original.toLowerCase(); } return builder.toString(); } public static String asCamelifyGetMethod(String original) { return GET + camelify(original); } public static String asCamelifySetMethod(String original) { return SET + camelify(original); } }