List of usage examples for java.lang Character isUpperCase
public static boolean isUpperCase(int codePoint)
From source file:Main.java
public static String camelCaseToDash(String string) { StringBuilder sb = new StringBuilder(2 * string.length()); boolean prevLowerCase = false, prevIsAlpha = false; for (int i = 0; i < string.length(); ++i) { boolean nextLowerCase = i < string.length() - 1 ? Character.isLowerCase(string.charAt(i + 1)) : false; char c = string.charAt(i); if (Character.isUpperCase(c)) { if ((prevLowerCase || nextLowerCase) && prevIsAlpha) sb.append('-'); sb.append(String.valueOf(c).toLowerCase(Locale.ENGLISH)); } else if (c == '.') { sb.append('-'); } else {/* www . ja v a 2s. c om*/ sb.append(c); } prevLowerCase = Character.isLowerCase(c); prevIsAlpha = Character.isAlphabetic(c); } return sb.toString(); }
From source file:Main.java
static private String capitalize(String s) { if (s == null || s.length() == 0) { return ""; }/* ww w . j a v a2 s . c o m*/ char first = s.charAt(0); if (Character.isUpperCase(first)) { return s; } else { return Character.toUpperCase(first) + s.substring(1); } }
From source file:Main.java
public static String capitial(String str) { if (str == "" || str.length() == 0) return ""; char first = str.charAt(0); if (Character.isUpperCase(first)) return str; else//from w ww. ja va 2s . c o m return Character.toUpperCase(first) + str.substring(1); }
From source file:Main.java
/** * Converts a method name to a Java attribute name, e.g. getFooBar() --> fooBar, isFlag --> flag. * @param methodName/*from ww w . ja va 2 s . c o m*/ * @return */ public static String methodNameToJavaAttributeName(final String methodName) { String name = methodName; if ((methodName.startsWith("get") || methodName.startsWith("set")) && methodName.length() > 3) name = methodName.substring(3); else if (methodName.startsWith("is") && methodName.length() > 2) name = methodName.substring(2); if (Character.isUpperCase(name.charAt(0))) return name.substring(0, 1).toLowerCase() + name.substring(1); return name; }
From source file:com.inkubator.hrm.util.StringsUtils.java
public static Boolean isHaveUpperCase(String str) { Boolean isCondition = Boolean.FALSE; for (int i = str.length() - 1; i >= 0; i--) { if (Character.isUpperCase(str.charAt(i))) { isCondition = Boolean.TRUE; }/*from w ww . j ava2s .c o m*/ } return isCondition; }
From source file:Main.java
/** * capitalize first letter//from ww w . j a va 2 s.co m * * <pre> * capitalizeFirstLetter(null) = null; * capitalizeFirstLetter("") = ""; * capitalizeFirstLetter("2ab") = "2ab" * capitalizeFirstLetter("a") = "A" * capitalizeFirstLetter("ab") = "Ab" * capitalizeFirstLetter("Abc") = "Abc" * </pre> * * @param str * @return */ public static String capitalizeFirstLetter(String str) { if (isEmpty(str)) { return str; } char c = str.charAt(0); return (!Character.isLetter(c) || Character.isUpperCase(c)) ? str : new StringBuilder(str.length()).append(Character.toUpperCase(c)).append(str.substring(1)) .toString(); }
From source file:Main.java
public static String convertCamelCaseToAllCaps(String qualifiedClassName) { StringBuffer sb = new StringBuffer(); final char[] charArray = qualifiedClassName.toCharArray(); for (int c = 0; c < charArray.length; c++) { char character = charArray[c]; final boolean isEnd = c + 1 == charArray.length; boolean nextIsUpper = !isEnd && Character.isUpperCase(charArray[c + 1]); boolean nextNextIsLower = c + 2 < (charArray.length) && Character.isLowerCase(charArray[c + 2]); sb.append(Character.toUpperCase(character)); if (Character.isLowerCase(character) && nextIsUpper) { sb.append('_'); } else {//from w ww . j a v a 2s . c om if (nextIsUpper && nextNextIsLower) { sb.append('_'); } } } return sb.toString(); }
From source file:Main.java
public static String capitalize(String s) { if (TextUtils.isEmpty(s)) { return ""; }/* ww w. ja va 2s . co m*/ final char first = s.charAt(0); if (Character.isUpperCase(first)) { return s; } else { return Character.toUpperCase(first) + s.substring(1); } }
From source file:Main.java
public static String getGetter(String variable) { StringBuilder builder = new StringBuilder("get"); if (variable.length() > 1) { final char first = variable.charAt(0); final char second = variable.charAt(1); if (!Character.isUpperCase(variable.charAt(0)) && first == 'm' && Character.isUpperCase(second)) { builder.append(capitalize(variable.substring(1, variable.length()))); } else {/* w ww.j a va 2s . c om*/ builder.append(capitalize(variable.substring(0, variable.length()))); } } return builder.append("()").toString(); }
From source file:Main.java
public static String getSetter(String variable) { StringBuilder builder = new StringBuilder("set"); if (variable.length() > 1) { final char first = variable.charAt(0); final char second = variable.charAt(1); if (!Character.isUpperCase(variable.charAt(0)) && first == 'm' && Character.isUpperCase(second)) { builder.append(capitalize(variable.substring(1, variable.length()))); } else {/*from w w w. j a v a 2 s. co m*/ builder.append(capitalize(variable.substring(0, variable.length()))); } } return builder.toString(); }