All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fredericboisguerin.excel.StringUtils Maven / Gradle / Ivy

The newest version!
package com.fredericboisguerin.excel;

import java.util.Locale;

/**
 * Created by fboisguerin on 03/08/2015.
 */
public class StringUtils {

    private static final Locale LOCALE = Locale.FRENCH;

    public static String capitalize(String s, CapitalizeMode mode) {
        StringBuilder builder = new StringBuilder();
        if (s.length() > 0) {
            // First letter
            builder.append(s.substring(0, 1).toUpperCase(LOCALE));
        }
        if (s.length() > 1) {
            // Other letters
            String rest = s.substring(1, s.length());
            switch (mode) {
                case ALL:
                    builder.append(rest.toUpperCase(LOCALE));
                    break;
                case FIRST_ONLY:
                    builder.append(rest.toLowerCase(LOCALE));
                    break;
            }
        }
        return builder.toString();
    }

    public static boolean isEmpty(String s) {
        return s == null || s.isEmpty();
    }

    public enum CapitalizeMode {
        ALL, FIRST_ONLY;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy