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:io.github.jeddict.jcode.util.JavaUtil.java

/**
 * a derived methodName from variableName Eg nickname -> getNickname /
 * setNickname/*from   w  w w  .  jav a 2s .c  om*/
 */
public static String getMethodName(String type, String fieldName) {
    String methodName;
    if (fieldName.charAt(0) == '_') {
        char ch = Character.toUpperCase(fieldName.charAt(1));
        methodName = Character.toString(ch) + fieldName.substring(2);
    } else {
        char ch = Character.toUpperCase(fieldName.charAt(0));
        methodName = Character.toString(ch) + fieldName.substring(1);
    }
    if (type != null) {
        methodName = type + methodName;
    }
    return methodName;
}

From source file:ems.emsystem.service.EmployeeServiceImpl.java

public String format(String name) {
    StringBuilder sb = new StringBuilder();
    char first = Character.toUpperCase(name.charAt(0));
    sb.append(first);//ww  w. ja v a 2s. c  om
    String substring = name.substring(1, name.length());
    sb.append(substring);
    return sb.toString();
}

From source file:annis.dao.autogenqueries.AutoSimpleRegexQuery.java

@Override
public void analyzingQuery(SaltProject saltProject) {

    List<String> tokens = new ArrayList<>();
    for (SCorpusGraph g : saltProject.getSCorpusGraphs()) {
        if (g != null) {
            for (SDocument doc : g.getSDocuments()) {
                SDocumentGraph docGraph = doc.getSDocumentGraph();
                EList<SNode> sNodes = docGraph.getSNodes();

                if (sNodes != null) {
                    for (SNode n : sNodes) {
                        if (n instanceof SToken) {
                            tokens.add(CommonHelper.getSpannedText((SToken) n));
                        }//from   w w  w .j a  v a 2s .co m
                    }
                }
            }
        }
    }

    // try to find a word with which is contained twice with Capitalize letter.
    text = null;
    for (int i = 0; i < tokens.size(); i++) {
        for (int j = i + 1; j < tokens.size(); j++) {
            if (tokens.get(i).equalsIgnoreCase(tokens.get(j))) {

                if (tokens.get(i).length() > 1 && ((Character.isLowerCase(tokens.get(i).charAt(0))
                        && Character.isUpperCase(tokens.get(j).charAt(0)))
                        || (Character.isLowerCase(tokens.get(j).charAt(0))
                                && Character.isUpperCase(tokens.get(i).charAt(0))))) {
                    text = tokens.get(i);
                    break;
                }
            }
        }
    }

    if (text != null) {
        Character upperLetter = Character.toUpperCase(text.charAt(0));
        Character lowerLetter = Character.toLowerCase(text.charAt(0));
        String rest = StringUtils.substring(text, -(text.length() - 1));

        finalAQL = "/[" + upperLetter + lowerLetter + "]" + rest + "/";
    } else {
        // select one random token from the result
        int tries = 10;
        int r = new Random().nextInt(tokens.size() - 1);
        text = tokens.get(r);
        while ("".equals(text) && tries > 0) {
            r = new Random().nextInt(tokens.size() - 1);
            text = tokens.get(r);
            tries--;
        }

        if (!"".equals(text) && text.length() > 1) {
            Character upperLetter = Character.toUpperCase(text.charAt(0));
            Character lowerLetter = Character.toLowerCase(text.charAt(0));
            String rest = StringUtils.substring(text, -(text.length() - 1));

            finalAQL = "/[" + upperLetter + lowerLetter + "]" + rest + "/";
        } else {
            finalAQL = "";
        }
    }
}

From source file:net.sourceforge.jabm.VariableBindingsIterator.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public Class getType(String beanProperty) {
    int dot = beanProperty.indexOf('.');
    String beanName = beanProperty.substring(0, dot);
    String attributeName = beanProperty.substring(dot + 1);
    Class beanType = beanFactory.getType(beanName);
    String getterName = "get" + Character.toUpperCase(attributeName.charAt(0)) + attributeName.substring(1);
    try {// ww w.j  a  v a2s.  c  o  m
        Method method = beanType.getMethod(getterName, new Class[] {});
        Type returnType = method.getGenericReturnType();
        if (returnType instanceof Class) {
            Class result = (Class) returnType;
            return result;
        } else {
            throw new IllegalArgumentException(beanProperty);
        }
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
}

From source file:Main.java

/**
 * Returns the length of the filename prefix, such as <code>C:/</code> or <code>~/</code>.
 * <p>//w w  w  .  j ava 2s  . co m
 * This method will handle a file in either Unix or Windows format.
 * <p>
 * The prefix length includes the first slash in the full filename
 * if applicable. Thus, it is possible that the length returned is greater
 * than the length of the input string.
 * <pre>
 * Windows:
 * a\b\c.txt           --> ""          --> relative
 * \a\b\c.txt          --> "\"         --> current drive absolute
 * C:a\b\c.txt         --> "C:"        --> drive relative
 * C:\a\b\c.txt        --> "C:\"       --> absolute
 * \\server\a\b\c.txt  --> "\\server\" --> UNC
 *
 * Unix:
 * a/b/c.txt           --> ""          --> relative
 * /a/b/c.txt          --> "/"         --> absolute
 * ~/a/b/c.txt         --> "~/"        --> current user
 * ~                   --> "~/"        --> current user (slash added)
 * ~user/a/b/c.txt     --> "~user/"    --> named user
 * ~user               --> "~user/"    --> named user (slash added)
 * </pre>
 * <p>
 * The output will be the same irrespective of the machine that the code is running on.
 * ie. both Unix and Windows prefixes are matched regardless.
 *
 * @param filename  the filename to find the prefix in, null returns -1
 * @return the length of the prefix, -1 if invalid or null
 */
public static int getPrefixLength(String filename) {
    if (filename == null) {
        return -1;
    }
    int len = filename.length();
    if (len == 0) {
        return 0;
    }
    char ch0 = filename.charAt(0);
    if (ch0 == ':') {
        return -1;
    }
    if (len == 1) {
        if (ch0 == '~') {
            return 2; // return a length greater than the input
        }
        return isSeparator(ch0) ? 1 : 0;
    } else {
        if (ch0 == '~') {
            int posUnix = filename.indexOf(UNIX_SEPARATOR, 1);
            int posWin = filename.indexOf(WINDOWS_SEPARATOR, 1);
            if (posUnix == -1 && posWin == -1) {
                return len + 1; // return a length greater than the input
            }
            posUnix = posUnix == -1 ? posWin : posUnix;
            posWin = posWin == -1 ? posUnix : posWin;
            return Math.min(posUnix, posWin) + 1;
        }
        char ch1 = filename.charAt(1);
        if (ch1 == ':') {
            ch0 = Character.toUpperCase(ch0);
            if (ch0 >= 'A' && ch0 <= 'Z') {
                if (len == 2 || isSeparator(filename.charAt(2)) == false) {
                    return 2;
                }
                return 3;
            }
            return -1;

        } else if (isSeparator(ch0) && isSeparator(ch1)) {
            int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
            int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
            if (posUnix == -1 && posWin == -1 || posUnix == 2 || posWin == 2) {
                return -1;
            }
            posUnix = posUnix == -1 ? posWin : posUnix;
            posWin = posWin == -1 ? posUnix : posWin;
            return Math.min(posUnix, posWin) + 1;
        } else {
            return isSeparator(ch0) ? 1 : 0;
        }
    }
}

From source file:com.liferay.cucumber.util.StringUtil.java

public static boolean equalsIgnoreCase(String s1, String s2) {
    if (s1 == s2) {
        return true;
    }//from   w w w .j  ava 2s  .c o m

    if ((s1 == null) || (s2 == null)) {
        return false;
    }

    if (s1.length() != s2.length()) {
        return false;
    }

    for (int i = 0; i < s1.length(); i++) {
        char c1 = s1.charAt(i);

        char c2 = s2.charAt(i);

        if (c1 == c2) {
            continue;
        }

        if ((c1 > 127) || (c2 > 127)) {

            // Georgian alphabet needs to check both upper and lower case

            if ((Character.toLowerCase(c1) == Character.toLowerCase(c2))
                    || (Character.toUpperCase(c1) == Character.toUpperCase(c2))) {

                continue;
            }

            return false;
        }

        int delta = c1 - c2;

        if ((delta != 32) && (delta != -32)) {
            return false;
        }
    }

    return true;
}

From source file:com.yunmel.syncretic.utils.commons.StrUtils.java

/**
 * ?//from  w ww.j av  a  2  s. c o  m
 * @param str
 * @return
 */
public static String firstCharToUpper(String str) {
    StringBuffer sb = new StringBuffer(str);
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    return sb.toString();
}

From source file:name.martingeisse.common.util.string.StringUtil.java

/**
 * Returns the specified string, with the first character capitalized.
 * Returns null/empty if the argument is null/empty.
 * @param s the input string//from   w  ww  .  j a va2 s . c o m
 * @return the output string
 */
public static String capitalizeFirst(String s) {
    if (s == null) {
        return null;
    } else if (s.isEmpty()) {
        return s;
    } else {
        return Character.toUpperCase(s.charAt(0)) + s.substring(1);
    }
}

From source file:com.mawujun.utils.string.StringUtils.java

/**
 *  ?//  w  ww  .j av a 2 s  .c o m
 * @author mawujun email:160649888@163.com qq:16064988
 * @param param
 * @return
 */
public static String underlineToCamel(String param) {
    if (param == null || "".equals(param.trim())) {
        return "";
    }
    int len = param.length();
    StringBuilder sb = new StringBuilder(len);
    for (int i = 0; i < len; i++) {
        char c = param.charAt(i);
        if (c == UNDERLINE) {
            if (++i < len) {
                sb.append(Character.toUpperCase(param.charAt(i)));
            }
        } else {
            sb.append(c);
        }
    }
    return sb.toString();
}

From source file:net.sourceforge.atunes.utils.StringUtils.java

/**
 * Converts the first character of a String to uppercase.
 * //  w w w.  j  a va  2s  . co m
 * @param s
 *            A String that should be converted
 * 
 * @return The String with the first character converted to uppercase
 */
public static String convertFirstCharacterToUppercase(final String s) {
    if (s != null && !s.isEmpty()) {
        String result;
        result = String.valueOf(Character.toUpperCase(s.charAt(0)));
        if (s.length() > 1) {
            result += s.substring(1);
        }
        return result;
    }
    return s;
}