package fr.sciencespo.medialab.hci.memorystructure.util;

import java.lang.String;
import java.lang.StringBuffer;

/**
 * Utility methods for Strings.
 *
 * @author benjamin ooghe-tabanou
 */
public class StringUtil {

    public static String toProperCase(String text) {
        text = text.toLowerCase();
        if (text.length() > 2) {
            text = text.substring(0, 1).toUpperCase() + text.substring(1).toLowerCase();
        } else {
            text = text.toUpperCase();
        }
        return text;
    }

    public static String toTitle(String text) {
        StringBuffer output = new StringBuffer();
        String[] tokens = text.replace(".", " ").split(" ");
        for (int i=0; i<tokens.length; i++) {
            output.append(" "+toProperCase(tokens[i]));
        }
        return output.toString().trim();
    }

}

package fr.sciencespo.medialab.hci.memorystructure.util;

import java.lang.String;
import java.lang.StringBuffer;

/**
 * Utility methods for Strings.
 *
 * @author benjamin ooghe-tabanou
 */
public class StringUtil {

    public static String toProperCase(String text) {
        text = text.toLowerCase();
        if (text.length() > 1) {
            text = text.substring(0, 1).toUpperCase() + text.substring(1).toLowerCase();
        } else {
            text = text.toUpperCase();
        }
        return text;
    }

    public static String toTitle(String text) {
        StringBuffer output = new StringBuffer();
        String[] tokens = text.replace(".", " ").replace("-", "- ").split(" ");
        for (int i=0; i<tokens.length; i++) {
            output.append(" "+toProperCase(tokens[i]));
        }
        return output.toString().replace("- ", "-").trim();
    }

}

fix Titlify urls with dashes and 2 letters TLD