List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:com.rabbitframework.commons.utils.StringUtils.java
public static String toSeparatorName(String property, String separator) { StringBuilder result = new StringBuilder(); if (property != null && property.length() > 0) { result.append(property.substring(0, 1).toLowerCase()); for (int i = 1; i < property.length(); i++) { char ch = property.charAt(i); if (Character.isUpperCase(ch)) { result.append(separator); result.append(Character.toLowerCase(ch)); } else { result.append(ch);/*from www. jav a2 s.co m*/ } } } return result.toString(); }
From source file:de.tudarmstadt.ukp.lmf.transform.wordnet.SynsetGenerator.java
protected String cleanText(final String text) { StringBuilder result = new StringBuilder(); boolean wasWhitespace = false; for (char c : text.toCharArray()) { if (" \t\n\r.,!?:;()`'-".indexOf(c) >= 0) { if (!wasWhitespace) { result.append(' '); }//from w ww. j a v a 2s. co m wasWhitespace = true; } else { result.append(Character.toLowerCase(c)); wasWhitespace = false; } } return result.toString().trim(); }
From source file:gmgen.util.MiscUtilities.java
/** * A more intelligent version of String.compareTo() that handles numbers * specially. For example, it places "My file 2" before "My file 10". * *@param str1 The first string//from w ww. j a va 2 s .c o m *@param str2 The second string *@param ignoreCase If true, case will be ignored *@return negative If str1 < str2, 0 if both are the same, * positive if str1 > str2 */ public static int compareStrings(String str1, String str2, boolean ignoreCase) { char[] char1 = str1.toCharArray(); char[] char2 = str2.toCharArray(); int len = Math.min(char1.length, char2.length); for (int i = 0, j = 0; (i < len) && (j < len); i++, j++) { char ch1 = char1[i]; char ch2 = char2[j]; if (Character.isDigit(ch1) && Character.isDigit(ch2) && (ch1 != '0') && (ch2 != '0')) { int _i = i + 1; int _j = j + 1; for (; _i < char1.length; _i++) { if (!Character.isDigit(char1[_i])) { break; } } for (; _j < char2.length; _j++) { if (!Character.isDigit(char2[_j])) { break; } } int len1 = _i - i; int len2 = _j - j; if (len1 > len2) { return 1; } else if (len1 < len2) { return -1; } else { for (int k = 0; k < len1; k++) { ch1 = char1[i + k]; ch2 = char2[j + k]; if (ch1 != ch2) { return ch1 - ch2; } } } i = _i - 1; j = _j - 1; } else { if (ignoreCase) { ch1 = Character.toLowerCase(ch1); ch2 = Character.toLowerCase(ch2); } if (ch1 != ch2) { return ch1 - ch2; } } } return char1.length - char2.length; }
From source file:org.eclipse.smila.connectivity.framework.crawler.web.metadata.Metadata.java
/** * Normalize.// w w w .j a va 2 s . c o m * * @param str * the string to normalize * * @return the string */ private static String normalize(final String str) { char c; final StringBuffer buf = new StringBuffer(); for (int i = 0; i < str.length(); i++) { c = str.charAt(i); if (Character.isLetter(c)) { buf.append(Character.toLowerCase(c)); } } return buf.toString(); }
From source file:CaseInsensitiveMap.java
static int caseInsenitiveHashCode(String input) { if (input == null) return NULL_HASH; int length = input.length(); int hash = 0; // This should end up more or less equal to input.toLowerCase().hashCode(), unless String // changes its implementation. Let's hope this is reasonably fast. for (int i = 0; i < length; i++) { int ch = input.charAt(i); int caselessCh = Character.toLowerCase(ch); hash = 31 * hash + caselessCh;//from w w w .j av a2 s . co m } return hash; }
From source file:de.hybris.platform.test.CaseInsensitiveStringMapTest.java
private List<String> shuffleCase(final List<String> keys) { final List<String> shuffled = new ArrayList<String>(keys.size()); for (final String key : keys) { final char[] chars = key.toCharArray(); for (int i = 0; i < chars.length; i++) { final char character = chars[i]; if (Character.isUpperCase(character)) { chars[i] = Character.toLowerCase(character); } else if (Character.isLowerCase(character)) { chars[i] = Character.toUpperCase(character); }//from ww w . j a va 2 s . c om shuffled.add(new String(chars)); } } return shuffled; }
From source file:maspack.fileutil.FileManager.java
private static String uncap(String word) { char chars[] = word.toCharArray(); chars[0] = Character.toLowerCase(chars[0]); return new String(chars); }
From source file:com.gargoylesoftware.htmlunit.runners.TestCaseCorrector.java
private static void addMethodWithExpectation(final List<String> lines, int i, final String browserString, final String methodName, final ComparisonFailure comparisonFailure, final String defaultExpectations) { String parent = methodName;//from ww w .j a va 2s . c o m final String child = parent.substring(parent.lastIndexOf('_') + 1); final int index = parent.indexOf('_', 1); if (index != -1) { parent = parent.substring(1, index); } else { parent = parent.substring(1); } if (!lines.get(i).isEmpty()) { i++; } lines.add(i++, ""); lines.add(i++, " /**"); lines.add(i++, " * @throws Exception if the test fails"); lines.add(i++, " */"); lines.add(i++, " @Test"); lines.add(i++, " @Alerts(DEFAULT = \"" + defaultExpectations + "\","); lines.add(i++, " " + browserString + " = " + getActualString(comparisonFailure) + ")"); if (index != -1) { lines.add(i++, " public void _" + parent + "_" + child + "() throws Exception {"); lines.add(i++, " test(\"" + parent + "\", \"" + child + "\");"); } else { String method = parent; for (final String prefix : HostExtractor.PREFIXES_) { if (method.startsWith(prefix)) { method = prefix.toLowerCase(Locale.ROOT) + method.substring(prefix.length()); break; } } if (Character.isUpperCase(method.charAt(0))) { method = Character.toLowerCase(method.charAt(0)) + method.substring(1); } lines.add(i++, " public void " + method + "() throws Exception {"); lines.add(i++, " test(\"" + parent + "\");"); } lines.add(i++, " }"); lines.add(i++, "}"); while (lines.size() > i) { lines.remove(i); } }
From source file:org.ballerinalang.swagger.code.generator.BallerinaConnectorCodeGenerator.java
@Override protected String getOrGenerateOperationId(Operation operation, String path, String httpMethod) { String operationId = operation.getOperationId(); if (path.contains("?")) { path = path.substring(0, path.indexOf("?")); }/*from w w w.j a v a 2 s . com*/ if (StringUtils.isBlank(operationId)) { String tmpPath = path.replaceAll("\\{", ""); tmpPath = tmpPath.replaceAll("\\}", ""); String[] parts = (tmpPath + "/" + httpMethod).split("/"); StringBuilder builder = new StringBuilder(); if ("/".equals(tmpPath)) { builder.append("root"); } for (int i = 0; i < parts.length; ++i) { String part = parts[i]; if (part.length() > 0) { if (builder.toString().length() == 0) { part = Character.toLowerCase(part.charAt(0)) + part.substring(1); } else { part = this.initialCaps(part); } builder.append(part); } } operationId = this.sanitizeName(builder.toString()); LOGGER.warn("Empty operationId found for path: " + httpMethod + " " + path + ". Renamed to auto-generated operationId: " + operationId); } return operationId; }
From source file:org.bonitasoft.engine.bdm.BDMQueryUtil.java
public static String createSelectAllQueryContent(final String businessObjectName) { if (businessObjectName == null) { throw new IllegalArgumentException("businessObjectName is null"); }// w ww . j a v a 2 s. c om final String simpleName = getSimpleBusinessObjectName(businessObjectName); final char var = Character.toLowerCase(simpleName.charAt(0)); final StringBuilder sb = new StringBuilder(); sb.append(buildSelectFrom(simpleName, var)); sb.append(buildOrderBy(var)); return sb.toString(); }