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();
        text = text.substring(0, 1).toUpperCase() + text.substring(1).toLowerCase();
        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();
    }

}

@@ -292,32 +292,69 @@
 .toLowerCase();%0A
+        if (text.length() %3E 2) %7B%0A    
         text = t
@@ -414,32 +414,98 @@
 .toLowerCase();%0A
+        %7D else %7B%0A            text = text.toUpperCase();%0A        %7D%0A
         return t

fix crash on too short strings