List of usage examples for java.lang Character toUpperCase
public static int toUpperCase(int codePoint)
From source file:com.g3net.tool.StringUtils.java
private static String changeFirstCharacterCase(String str, boolean capitalize) { if (str == null || str.length() == 0) { return str; }//from ww w.j a v a2s . com StringBuilder buf = new StringBuilder(str.length()); if (capitalize) { buf.append(Character.toUpperCase(str.charAt(0))); } else { buf.append(Character.toLowerCase(str.charAt(0))); } buf.append(str.substring(1)); return buf.toString(); }
From source file:io.manasobi.utils.StringUtils.java
/** * char? ? ? ?? camel case <br><br> * * StringUtils.convertToCamelCase("anyframe-java-test", "-") = "anyframeJavaTest" * * @param targetString ? ?/*from w ww. j a va2 s . c o m*/ * @param posChar ?? ? ? * @return camel case ? ? */ public static String convertToCamelCase(String targetString, String posChar) { StringBuilder result = new StringBuilder(); boolean nextUpper = false; String allLower = targetString.toLowerCase(); for (int i = 0; i < allLower.length(); i++) { char currentChar = allLower.charAt(i); if (currentChar == CharUtils.toChar(posChar)) { nextUpper = true; } else { if (nextUpper) { currentChar = Character.toUpperCase(currentChar); nextUpper = false; } result.append(currentChar); } } return result.toString(); }
From source file:com.taobao.android.builder.tools.bundleinfo.ApkFileListUtils.java
private static boolean equals(char c1, char c2, boolean isCaseSensitive) { return c1 == c2 ? true : !isCaseSensitive && (Character.toUpperCase(c1) == Character.toUpperCase(c2) || Character.toLowerCase(c1) == Character.toLowerCase(c2)); }
From source file:com.netspective.commons.text.TextUtils.java
/** * Given a text string, return a string that would be suitable for that string to be used * as a Java constant (public static final XXX). The rule is to basically take every letter * or digit and return it in uppercase and every non-letter or non-digit as an underscore. *//*from w w w . ja va 2 s . c o m*/ public String xmlTextToJavaConstant(String xml) { if (xml == null || xml.length() == 0) return xml; StringBuffer constant = new StringBuffer(); for (int i = 0; i < xml.length(); i++) { char ch = xml.charAt(i); constant.append(Character.isJavaIdentifierPart(ch) ? Character.toUpperCase(ch) : '_'); } return constant.toString(); }
From source file:com.epam.catgenome.util.ProteinSequenceUtils.java
private static char complement(final char nucleotide) { char complement; switch (Character.toUpperCase(nucleotide)) { case 'A': complement = 'U'; break;//from w ww . ja v a 2 s .co m case 'T': case 'U': complement = 'A'; break; case 'C': complement = 'G'; break; case 'G': complement = 'C'; break; default: throw new IllegalArgumentException( MessageHelper.getMessage(MessagesConstants.ERROR_INVALID_NUCLEOTIDE, nucleotide)); } return complement; }
From source file:org.apache.uima.ruta.resource.MultiTreeWordList.java
/** * Returns true, if the MultiTreeWordList contains the string text, false otherwise. * /*from w w w. ja va 2 s. co m*/ * @param pointer * The MultiTextNode we are looking at. * @param text * The string which is contained or not. * @param index * The index of the string text we checked until now. * @param ignoreCase * Indicates whether we search case sensitive or not. * @param fragment * Indicates whether we are looking for a prefix of the string text. * @param ignoreChars * Characters which can be ignored. * @param maxIgnoreChars * Maximum number of characters which are allowed to be ignored. * @return True, if the TreeWordList contains the string text, false otherwise. */ private List<String> recursiveContains2(MultiTextNode pointer, String text, int index, boolean ignoreCase, boolean fragment, char[] ignoreChars, int maxIgnoreChars) { if (pointer == null) { return null; } if (index == text.length()) { if (pointer.isWordEnd()) { return new ArrayList<String>(pointer.getTypes()); } if (fragment) { return Collections.emptyList(); } } char charAt = text.charAt(index); boolean charAtIgnored = false; if (ignoreChars != null) { for (char each : ignoreChars) { if (each == charAt) { charAtIgnored = true; break; } } charAtIgnored &= index != 0; } int next = ++index; if (ignoreCase) { // Lower Case Node. MultiTextNode childNodeL = pointer.getChildNode(Character.toLowerCase(charAt)); if (childNodeL == null) { childNodeL = skipWS(pointer, Character.toLowerCase(charAt)); } // Upper Case Node. MultiTextNode childNodeU = pointer.getChildNode(Character.toUpperCase(charAt)); if (childNodeU == null) { childNodeU = skipWS(pointer, Character.toUpperCase(charAt)); } if (charAtIgnored && childNodeL == null && childNodeU == null) { // Character is ignored and does not appear. return recursiveContains2(pointer, text, next, ignoreCase, fragment, ignoreChars, maxIgnoreChars); } else { // Recursion. Collection<String> recursiveContainsL = recursiveContains2(childNodeL, text, next, ignoreCase, fragment, ignoreChars, maxIgnoreChars); Collection<String> recursiveContainsU = recursiveContains2(childNodeU, text, next, ignoreCase, fragment, ignoreChars, maxIgnoreChars); if (recursiveContainsL == null && recursiveContainsU == null) { return null; } List<String> result = new LinkedList<String>(); if (recursiveContainsL != null) { result.addAll(recursiveContainsL); } if (recursiveContainsU != null) { result.addAll(recursiveContainsU); } return result; } } else { // Case sensitive. MultiTextNode childNode = pointer.getChildNode(charAt); if (charAtIgnored && childNode == null) { // Recursion with incremented index. return recursiveContains2(pointer, text, next, ignoreCase, fragment, ignoreChars, maxIgnoreChars); } else { // Recursion with new node. return recursiveContains2(childNode, text, next, ignoreCase, fragment, ignoreChars, maxIgnoreChars); } } }
From source file:org.teavm.flavour.json.emit.ClassInformationProvider.java
private boolean isGetterName(String name) { return name.startsWith("get") && name.length() > 3 && Character.toUpperCase(name.charAt(3)) == name.charAt(3); }
From source file:org.teavm.flavour.json.emit.ClassInformationProvider.java
private boolean isBooleanName(String name) { return name.startsWith("is") && name.length() > 2 && Character.toUpperCase(name.charAt(2)) == name.charAt(2); }
From source file:org.teavm.flavour.json.emit.ClassInformationProvider.java
private boolean isSetterName(String name) { return name.startsWith("set") && name.length() > 3 && Character.toUpperCase(name.charAt(3)) == name.charAt(3); }
From source file:org.teavm.flavour.json.emit.ClassInformationProvider.java
private String decapitalize(String name) { if (name.length() > 1 && name.charAt(1) == Character.toUpperCase(name.charAt(1))) { return name; }/*from w w w. ja v a2s . com*/ return Character.toLowerCase(name.charAt(0)) + name.substring(1); }