com.fredericboisguerin.excel.StringUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of excel-reader-writer Show documentation
Show all versions of excel-reader-writer Show documentation
A library to read/write excel files with simple descriptions of the model
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;
}
}