List of usage examples for java.lang Character toUpperCase
public static int toUpperCase(int codePoint)
From source file:com.taobao.tdhs.jdbc.util.StringUtil.java
public static int indexOfIgnoreCaseRespectMarker(int startAt, String src, String target, String marker, String markerCloses, boolean allowBackslashEscapes) { char contextMarker = Character.MIN_VALUE; boolean escaped = false; int markerTypeFound = 0; int srcLength = src.length(); int ind = 0;//w w w . j a v a 2 s . c om for (int i = startAt; i < srcLength; i++) { char c = src.charAt(i); if (allowBackslashEscapes && c == '\\') { escaped = !escaped; } else if (contextMarker != Character.MIN_VALUE && c == markerCloses.charAt(markerTypeFound) && !escaped) { contextMarker = Character.MIN_VALUE; } else if ((ind = marker.indexOf(c)) != -1 && !escaped && contextMarker == Character.MIN_VALUE) { markerTypeFound = ind; contextMarker = c; } else if ((Character.toUpperCase(c) == Character.toUpperCase(target.charAt(0)) || Character.toLowerCase(c) == Character.toLowerCase(target.charAt(0))) && !escaped && contextMarker == Character.MIN_VALUE) { if (startsWithIgnoreCase(src, i, target)) return i; } } return -1; }
From source file:com.gorillalogic.fonemonkey.PropertyUtil.java
private static Object getValue(Object obj, String name) throws Throwable { String method = "get" + Character.toUpperCase(name.charAt(0)) + name.substring(1); String method2 = "is" + Character.toUpperCase(name.charAt(0)) + name.substring(1); try {//from w w w .j av a 2 s .c o m // Not supported in API 8 // Method meth = obj.getClass().getMethod(method, null); Method meth = getMethod(obj.getClass(), method, method2); if (meth == null) { throw new IllegalArgumentException("No such property method " + method + " or " + method2 + " on class " + obj.getClass().getName()); } return meth.invoke(obj); } catch (Throwable e) { Log.log(e); throw e; } }
From source file:Util.java
/** * Returns a string that is equivalent to the specified string with its * first character converted to uppercase as by {@link String#toUpperCase}. * The returned string will have the same value as the specified string if * its first character is non-alphabetic, if its first character is already * uppercase, or if the specified string is of length 0. * * <p>For example:/*from ww w. j a va 2 s .com*/ * <pre> * capitalize("foo bar").equals("Foo bar"); * capitalize("2b or not 2b").equals("2b or not 2b") * capitalize("Foo bar").equals("Foo bar"); * capitalize("").equals(""); * </pre> * * @param s the string whose first character is to be uppercased * @return a string equivalent to <tt>s</tt> with its first character * converted to uppercase * @throws NullPointerException if <tt>s</tt> is null */ public static String capitalize(String s) { if (s.length() == 0) return s; char first = s.charAt(0); char capitalized = Character.toUpperCase(first); return (first == capitalized) ? s : capitalized + s.substring(1); }
From source file:Utils.java
/** * Capitlize each word in a string (journal titles, etc) * /*from w w w . ja v a2 s.c om*/ * @param text * Text to inspect * @return Capitalized text */ public static String capitalize(String text) { StringBuilder resultText; char previousC; resultText = new StringBuilder(); previousC = '.'; for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (Character.isLetter(c) && !Character.isLetter(previousC)) { resultText.append(Character.toUpperCase(c)); } else { resultText.append(c); } previousC = c; } return resultText.toString(); }
From source file:Main.java
/** * Returns attribute's getter method. If the method not found then * NoSuchMethodException will be thrown. * /*from w ww. j ava2s. c o m*/ * @param cls * the class the attribute belongs too * @param attr * the attribute's name * @return attribute's getter method * @throws NoSuchMethodException * if the getter was not found */ public final static Method getAttributeGetter(Class cls, String attr) throws NoSuchMethodException { StringBuffer buf = new StringBuffer(attr.length() + 3); buf.append("get"); if (Character.isLowerCase(attr.charAt(0))) { buf.append(Character.toUpperCase(attr.charAt(0))).append(attr.substring(1)); } else { buf.append(attr); } try { return cls.getMethod(buf.toString(), (Class[]) null); } catch (NoSuchMethodException e) { buf.replace(0, 3, "is"); return cls.getMethod(buf.toString(), (Class[]) null); } }
From source file:com.adguard.commons.lang.StringHelperUtils.java
public static boolean containsIgnoreCase(String where, String what) { final int length = what.length(); if (length == 0) return true; // Empty string is contained final char firstLo = Character.toLowerCase(what.charAt(0)); final char firstUp = Character.toUpperCase(what.charAt(0)); for (int i = where.length() - length; i >= 0; i--) { // Quick check before calling the more expensive regionMatches() method: final char ch = where.charAt(i); if (ch != firstLo && ch != firstUp) continue; if (where.regionMatches(true, i, what, 0, length)) return true; }/*from www . j a va2 s . com*/ return false; }
From source file:net.certiv.antlr.project.util.Strings.java
public static String camelCase(String in) { StringBuilder sb = new StringBuilder(in); for (int idx = sb.length() - 1; idx >= 0; idx--) { char c = sb.charAt(idx); if (c == '_') { sb.deleteCharAt(idx);// w ww. jav a2s . c o m sb.setCharAt(idx, Character.toUpperCase(sb.charAt(idx))); } else if (Character.isUpperCase(c)) { sb.setCharAt(idx, Character.toLowerCase(c)); } } sb.setCharAt(0, Character.toLowerCase(sb.charAt(0))); return sb.toString(); }
From source file:io.proleap.cobol.TestGenerator.java
public static String firstToUpper(final String str) { return Character.toUpperCase(str.charAt(0)) + str.substring(1); }
From source file:Main.java
/** * Returns attribute's setter method. If the method not found then * NoSuchMethodException will be thrown. * // w w w . j a v a2 s . c o m * @param cls * the class the attribute belongs to * @param attr * the attribute's name * @param type * the attribute's type * @return attribute's setter method * @throws NoSuchMethodException * if the setter was not found */ public final static Method getAttributeSetter(Class cls, String attr, Class type) throws NoSuchMethodException { StringBuffer buf = new StringBuffer(attr.length() + 3); buf.append("set"); if (Character.isLowerCase(attr.charAt(0))) { buf.append(Character.toUpperCase(attr.charAt(0))).append(attr.substring(1)); } else { buf.append(attr); } return cls.getMethod(buf.toString(), new Class[] { type }); }
From source file:corelyzer.util.StringUtility.java
public static String capitalizeHeadingCharacter(final String value) { return value.length() > 0 ? Character.toUpperCase(value.charAt(0)) + value.substring(1) : value; }