Android Open Source - sqlite-analyzer String Util






From Project

Back to project page sqlite-analyzer.

License

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.

Java Source Code

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);
    }
}




Java Source Code List

com.example.MainActivity.java
com.example.MainActivity.java
com.example.MyDatabase.java
com.example.MyDatabase.java
com.novoda.sqlite.Analyzer.java
com.novoda.sqlite.Connector.java
com.novoda.sqlite.FileConnector.java
com.novoda.sqlite.MigrationsConnector.java
com.novoda.sqlite.MigrationsInDir.java
com.novoda.sqlite.Migrations.java
com.novoda.sqlite.NumberedFilesComparator.java
com.novoda.sqlite.StringUtilOld.java
com.novoda.sqlite.StringUtil.java
com.novoda.sqlite.impl.SQLFile.java
com.novoda.sqlite.impl.TableCreateStatementParser.java
com.novoda.sqlite.model.Column.java
com.novoda.sqlite.model.DataAffinity.java
com.novoda.sqlite.model.Database.java
com.novoda.sqlite.model.Table.java
com.novoda.sqliteprovider.demo.simple.provider.FireworkProvider.java
com.novoda.sqliteprovider.demo.simple.ui.MainActivity.java
com.novoda.sqliteprovider.demo.simple.ui.MainFragment.java