List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(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 w w w . j a va2s.c o m*/ 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:com.egt.core.util.STP.java
public static String getHumplessCase(String string, char hump) { if (string == null) { return null; }// w ww . j av a2 s . com String x = string.trim(); String y = ""; boolean b = false; char c; for (int i = 0; i < x.length(); i++) { c = x.charAt(i); if (Character.isUpperCase(c)) { if (b) { y += hump; } y += Character.toLowerCase(c); } else { y += c; } b = true; } return y; }
From source file:org.ballerinalang.composer.service.workspace.swagger.SwaggerConverterUtils.java
/** * This will generate UUID specific to given resource. * * @param path/*from w w w . j a va2s. c o m*/ * @param verb * @return */ public static String generateServiceUUID(String path, String verb) { String tmpPath = path; tmpPath = tmpPath.replaceAll("\\{", ""); tmpPath = tmpPath.replaceAll("\\}", ""); String[] parts = (tmpPath + "/" + verb).split("/"); StringBuilder builder = new StringBuilder(); if ("/".equals(tmpPath)) { // must be root tmpPath builder.append("root"); } for (String part : parts) { if (part.length() > 0) { if (builder.toString().length() == 0) { part = Character.toLowerCase(part.charAt(0)) + part.substring(1); } else { part = capitalize(part); } builder.append(part); } } return builder.toString().replaceAll("[^a-zA-Z0-9_]", ""); }
From source file:eu.trentorise.opendata.josman.Josmans.java
/** * Returns the name displayed on the website as menu item for a given page. * * @param relPath path relative to the {@link JosmanProject#sourceRepoDir()} (i.e. * LICENSE.txt or docs/README.md)/*w w w. j a v a2 s . c om*/ */ public static String targetName(String relPath) { String htmlizedPath = htmlizePath(relPath); if (htmlizedPath.endsWith("/index.html")) { return "Usage"; } if (htmlizedPath.endsWith("/CHANGES.html")) { return "Release notes"; } String withoutFiletype = htmlizedPath.replace(".html", ""); int lastSlash = withoutFiletype.lastIndexOf("/"); String fileName = withoutFiletype; if (lastSlash != -1) { fileName = withoutFiletype.substring(lastSlash + 1); } StringBuilder sb = new StringBuilder(); sb.append(Character.toUpperCase(fileName.charAt(0))); int i = 1; while (i < fileName.length()) { char ch = fileName.charAt(i); if (i + 1 < fileName.length()) { char nextCh = fileName.charAt(i + 1); if (Character.isLowerCase(ch) && Character.isUpperCase(nextCh)) { sb.append(ch + " "); i += 1; continue; } else { if (i + 2 < fileName.length()) { char nextNextCh = fileName.charAt(i + 2); if (Character.isUpperCase(ch) && Character.isUpperCase(nextCh) && Character.isLowerCase(nextNextCh)) { sb.append(ch); sb.append(" "); sb.append(Character.toLowerCase(nextCh)); i += 2; continue; } else { if (Character.isUpperCase(ch) && Character.isUpperCase(nextCh)) { sb.append(ch); i += 1; continue; } } } } } sb.append(Character.toLowerCase(ch)); i += 1; } return sb.toString(); }
From source file:org.ballerinalang.composer.service.ballerina.parser.service.BallerinaParserService.java
private static String toJsonName(String name, int prefixLen) { return Character.toLowerCase(name.charAt(prefixLen)) + name.substring(prefixLen + 1); }
From source file:org.apache.click.extras.spring.SpringClickServlet.java
/** * Load the pageClass bean setter methods * * @param pageClass the page class/*w w w . ja v a2s. com*/ */ private void loadSpringBeanSetterMethods(Class<? extends Page> pageClass) { Method[] methods = pageClass.getMethods(); for (int j = 0; j < methods.length; j++) { Method method = methods[j]; String methodName = method.getName(); if (methodName.startsWith("set") && !SETTER_METHODS_IGNORE_SET.contains(methodName) && method.getParameterTypes().length == 1) { // Get the bean name from the setter method name HtmlStringBuffer buffer = new HtmlStringBuffer(); buffer.append(Character.toLowerCase(methodName.charAt(3))); buffer.append(methodName.substring(4)); String beanName = buffer.toString(); // If Spring contains the bean then cache in map list if (getApplicationContext().containsBean(beanName)) { List<BeanNameAndMethod> beanList = pageSetterBeansMap.get(pageClass); if (beanList == null) { beanList = new ArrayList<BeanNameAndMethod>(); pageSetterBeansMap.put(pageClass, beanList); } beanList.add(new BeanNameAndMethod(beanName, method)); } } } }
From source file:org.apache.uima.ruta.resource.MultiTreeWordList.java
/** * Returns true, if the MultiTreeWordList contains the string text, false otherwise. * //w w w . java 2s.com * @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: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:org.dhatim.edisax.util.EDIUtils.java
public static String encodeAttributeName(String name) { String result;// w w w. j av a2 s . c o m if (name.toUpperCase().equals(name)) { result = name.toLowerCase(); } else { result = name; } result = deleteWithPascalNotation(result, '_'); result = encodeJavaIdentifier(result); if (Character.isUpperCase(result.charAt(0))) { result = Character.toLowerCase(result.charAt(0)) + result.substring(1); } if (reservedKeywords.contains(result)) { result = "_" + result; } return result; }
From source file:com.cohort.util.String2.java
/** * This goes beyond indexOfIgnoreCase by looking after punctuation removed. * * @param s//ww w . j a v a 2s.com * @param find * @return true if find is loosely in s. Return false if s or find !isSomething. */ public static boolean looselyContains(String s, String find) { if (s == null || find == null) return false; int sLength = s.length(); StringBuilder ssb = new StringBuilder(); for (int i = 0; i < sLength; i++) { char ch = s.charAt(i); if (Character.isLetterOrDigit(ch)) ssb.append(Character.toLowerCase(ch)); } if (ssb.length() == 0) return false; int fLength = find.length(); StringBuilder fsb = new StringBuilder(); for (int i = 0; i < fLength; i++) { char ch = find.charAt(i); if (Character.isLetterOrDigit(ch)) fsb.append(Character.toLowerCase(ch)); } if (fsb.length() == 0) return false; return ssb.indexOf(fsb.toString()) >= 0; }