Example usage for java.lang Character toUpperCase

List of usage examples for java.lang Character toUpperCase

Introduction

In this page you can find the example usage for java.lang Character toUpperCase.

Prototype

public static int toUpperCase(int codePoint) 

Source Link

Document

Converts the character (Unicode code point) argument to uppercase using case mapping information from the UnicodeData file.

Usage

From source file:Main.java

private static char labelFor(String username) {
    return Character.toUpperCase(username.charAt(0));
}

From source file:net.sensemaker.snappy.SnappyUtil.java

public static Object getPropertyValue(String property, Object target) {
    Class clazz = target.getClass();
    property = Character.toUpperCase(property.charAt(0)) + property.substring(1);
    Method method = null;/*from w  w  w  . j av a  2 s  . co m*/
    try {
        String methodName = "get" + property;
        method = clazz.getMethod(methodName);
        log.finest("Found [" + methodName + "]");
    } catch (NoSuchMethodException e) {
        try {
            String methodName = "is" + property;
            method = clazz.getMethod(methodName);
            log.finest("Found [" + methodName + "]");
        } catch (NoSuchMethodException e2) {
            throw new RuntimeException("Property " + property + " not found in " + clazz.getName());
        }
    }
    try {
        Object o = method.invoke(target, new Object[0]);
        log.finest("Returniong [" + o + "]");
        return o;
    } catch (Exception e) {
        throw new RuntimeException("Error getting property " + property + " from " + clazz.getName(), e);
    }

}

From source file:Main.java

/**
 * Green implementation of regionMatches.
 *
 * @param cs the {@code CharSequence} to be processed
 * @param ignoreCase whether or not to be case insensitive
 * @param thisStart the index to start on the {@code cs} CharSequence
 * @param substring the {@code CharSequence} to be looked for
 * @param start the index to start on the {@code substring} CharSequence
 * @param length character length of the region
 * @return whether the region matched/*from w w w . ja  v a2 s  .co  m*/
 */
static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, final int thisStart,
        final CharSequence substring, final int start, final int length) {
    if (cs instanceof String && substring instanceof String) {
        return ((String) cs).regionMatches(ignoreCase, thisStart, (String) substring, start, length);
    } else {
        int index1 = thisStart;
        int index2 = start;
        int tmpLen = length;

        while (tmpLen-- > 0) {
            char c1 = cs.charAt(index1++);
            char c2 = substring.charAt(index2++);

            if (c1 == c2) {
                continue;
            }

            if (!ignoreCase) {
                return false;
            }

            // The same check as in String.regionMatches():
            if (Character.toUpperCase(c1) != Character.toUpperCase(c2)
                    && Character.toLowerCase(c1) != Character.toLowerCase(c2)) {
                return false;
            }
        }

        return true;
    }
}

From source file:asia.gkc.vneedu.utils.FilterUtil.java

/**
 * ????//w w  w.  j av  a2  s . c o  m
 * @param name - ????
 * @param prefix - ?,get/set
 * @param delimiter - ??
 * @return ??
 */
public static String getMethodName(String name, String prefix, String delimiter) {
    String[] parts = name.split(delimiter == null ? "_" : delimiter);
    StringBuilder sbOut = new StringBuilder(prefix == null ? "get" : prefix);

    if (parts.length >= 1) {
        for (String str : parts) {
            StringBuilder sb = new StringBuilder(str);
            sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
            sbOut.append(sb);
        }
    }

    return new String(sbOut);
}

From source file:Strings.java

/**
 * Returns a title-cased version of the specified word,
 * which involves capitalizing the first character in
 * the word if it is a letter./*from w ww.j a  va  2s.c o m*/
 *
 * @param word The word to convert to title case.
 * @return Title cased version of specified word.
 */
public static String titleCase(String word) {
    if (word.length() < 1)
        return word;
    if (!Character.isLetter(word.charAt(0)))
        return word;
    return Character.toUpperCase(word.charAt(0)) + word.substring(1);
}

From source file:com.dukescript.presenters.androidapp.test.Knockout.java

public static Map<String, Method> assertMethods(Class<?> test) throws Exception {
    Map<String, Method> all = new HashMap<String, Method>();
    StringBuilder errors = new StringBuilder();
    int cnt = 0;//from  w w  w .  ja v  a2  s.c  o m
    final Class<?>[] classes = testClasses();
    for (Class<?> c : classes) {
        for (Method method : c.getMethods()) {
            if (method.getAnnotation(KOTest.class) != null) {
                cnt++;
                String name = method.getName();
                if (!name.startsWith("test")) {
                    name = "test" + Character.toUpperCase(name.charAt(0)) + name.substring(1);
                }
                try {
                    Method m = test.getMethod(name);
                    all.put(name, method);
                } catch (NoSuchMethodException ex) {
                    errors.append("\n").append(name);
                }
            }
        }
    }
    if (errors.length() > 0) {
        errors.append("\nTesting classes: ").append(Arrays.toString(classes));
        fail("Missing method: " + errors);
    }
    assert cnt > 0 : "Some methods found";
    return all;
}

From source file:Main.java

/**
 * Green implementation of regionMatches.
 *
 * @param cs//from  w  w w .j  a v a 2s. com
 *            the <code>CharSequence</code> to be processed
 * @param ignoreCase
 *            whether or not to be case insensitive
 * @param thisStart
 *            the index to start on the <code>cs</code> CharSequence
 * @param substring
 *            the <code>CharSequence</code> to be looked for
 * @param start
 *            the index to start on the <code>substring</code> CharSequence
 * @param length
 *            character length of the region
 * @return whether the region matched
 */
static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, final int thisStart,
        final CharSequence substring, final int start, final int length) {
    if (cs instanceof String && substring instanceof String) {
        return ((String) cs).regionMatches(ignoreCase, thisStart, (String) substring, start, length);
    }
    int index1 = thisStart;
    int index2 = start;
    int tmpLen = length;

    while (tmpLen-- > 0) {
        char c1 = cs.charAt(index1++);
        char c2 = substring.charAt(index2++);

        if (c1 == c2) {
            continue;
        }

        if (!ignoreCase) {
            return false;
        }

        // The same check as in String.regionMatches():
        if (Character.toUpperCase(c1) != Character.toUpperCase(c2)
                && Character.toLowerCase(c1) != Character.toLowerCase(c2)) {
            return false;
        }
    }

    return true;
}

From source file:com.boundary.plugin.sdk.PluginUtil.java

/**
 * Transform a camel case string into a upper case string with underscores
 * //from   www.  j a v  a2  s. c  o  m
 * @param s {@link String} to transform
 * @param d replacement character for white space
 * @return {@link String}
 */
public static String toUpperUnderscore(String s, Character d) {
    StringBuilder builder = new StringBuilder();
    s = s.trim();

    boolean first = true;
    for (int i = 0; i < s.length(); i++) {
        if (Character.isWhitespace(s.charAt(i))) {
            builder.append(d);
        } else {
            if (Character.isUpperCase(s.charAt(i))) {
                if (first == false) {
                    if (i + 1 < s.length() && Character.isLowerCase(s.charAt(i + 1))) {
                        builder.append(d);
                    }
                }
            }
            builder.append(Character.toUpperCase(s.charAt(i)));
        }
        first = false;
    }
    StringBuilder r = new StringBuilder();
    r.append('\\').append(d).append('\\').append(d);

    return builder.toString().replaceAll(r.toString(), d.toString());
}

From source file:org.wiztools.commons.RotN.java

private static String process(final String inString,
        final Map<Character, Character> map) throws IllegalArgumentException {
    char[] arr = inString.toCharArray();
    StringBuilder sb = new StringBuilder(arr.length);
    for(char c: arr) {
        Character out = map.get(c);
        if(out == null) {
            sb.append(c);/*from   w w w  . j a v a 2s .com*/
        }
        else {
            if(Character.isUpperCase(c))
                sb.append(Character.toUpperCase(out));
            else
                sb.append(out);
        }
    }
    return sb.toString();
}

From source file:com.technion.studybuddy.GCM.ServerUtilities.java

private static String capitalize(String s) {
    if (s == null || s.length() == 0)
        return "";
    char first = s.charAt(0);
    if (Character.isUpperCase(first))
        return s;
    else// w  ww .  ja  v a 2 s. c om
        return Character.toUpperCase(first) + s.substring(1);
}