List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:com.adito.boot.Util.java
/** * Turn a constant like name into an key like structure. E.g. <i>HTTP_ERROR</i> * would be turned into <i>httpError</i>. * //from ww w.j a v a 2 s . com * @param constant constant * @return key */ public static String makeConstantKey(String constant) { StringBuffer buf = new StringBuffer(); char ch; boolean firstChar = false; for (int i = 0; i < constant.length(); i++) { ch = constant.charAt(i); if (ch == '_') { firstChar = true; } else { if (firstChar) { ch = Character.toUpperCase(ch); firstChar = false; } else { ch = Character.toLowerCase(ch); } buf.append(ch); } } return buf.toString(); }
From source file:com.adito.boot.Util.java
/** * Re-process the case of a space separated string of words. The first * character is capitalised, all others or lower cased. * /* www. ja v a 2 s . c om*/ * @param unCased uncased string * @return cased string */ public static String reCase(String unCased) { StringBuffer buf = new StringBuffer(); char ch; boolean wordNext = false; for (int i = 0; i < unCased.length(); i++) { ch = unCased.charAt(i); if (ch == ' ') { wordNext = true; } else { if (wordNext) { ch = Character.toUpperCase(ch); wordNext = false; } else { ch = Character.toLowerCase(ch); } buf.append(ch); } } return buf.toString(); }
From source file:org.wrml.runtime.format.text.html.WrmldocFormatter.java
private String buildLinkSignature(final String linkFunctionName, final URI responseSchemaUri, final URI requestSchemaUri, final URI thisSchemaUri) { final Context context = getContext(); final SchemaLoader schemaLoader = context.getSchemaLoader(); final StringBuilder signatureBuilder = new StringBuilder(); if (responseSchemaUri != null) { final Prototype responsePrototype = schemaLoader.getPrototype(responseSchemaUri); final String responseSchemaName = responsePrototype.getUniqueName().getLocalName(); signatureBuilder.append(responseSchemaName); } else {//from w w w . j a v a 2 s. c o m signatureBuilder.append("void"); } signatureBuilder.append(" "); signatureBuilder.append(linkFunctionName).append(" ( "); if (requestSchemaUri != null && !requestSchemaUri.equals(thisSchemaUri)) { final Prototype requestPrototype = schemaLoader.getPrototype(requestSchemaUri); final String requestSchemaName = requestPrototype.getUniqueName().getLocalName(); signatureBuilder.append(requestSchemaName); signatureBuilder.append(" "); final String parameterName = Character.toLowerCase(requestSchemaName.charAt(0)) + requestSchemaName.substring(1); signatureBuilder.append(parameterName); } signatureBuilder.append(" ) "); final String signature = signatureBuilder.toString(); return signature; }
From source file:adalid.commons.util.StrUtils.java
public static String getCamelCase(String string, String gap, boolean toLowerCaseLess) { if (string == null) { return null; }/*from ww w. j a v a 2s . c o m*/ String x = string.trim(); String y = ""; String z = StringUtils.isBlank(gap) ? StringUtils.EMPTY : gap.trim(); boolean b = false; boolean g = false; char c; for (int i = 0; i < x.length(); i++) { c = x.charAt(i); if (isLetterOrDigit(c)) { if (b) { y += g ? z : ""; y += Character.toUpperCase(c); } else { y += toLowerCaseLess ? c : Character.toLowerCase(c); } b = false; g = true; } else { b = true; } } return y; }
From source file:br.msf.commons.util.CharSequenceUtils.java
public static Map<Character, Integer> getCharCount(final int fromIndex, final CharSequence sequence, final Boolean caseSensitive) { ArgumentUtils.rejectIfOutOfBounds(fromIndex, 0, length(sequence) - 1); if (isEmptyOrNull(sequence)) { return Collections.EMPTY_MAP; }//from w ww . j a v a 2s. c o m final Map<Character, Integer> chars = new TreeMap<Character, Integer>(); for (int i = fromIndex; i < length(sequence); i++) { Character ch = caseSensitive ? sequence.charAt(i) : Character.toLowerCase(sequence.charAt(i)); Integer count = chars.get(ch); chars.put(ch, (count == null) ? 1 : count + 1); } return chars; }
From source file:org.apache.openjpa.lib.conf.ConfigurationImpl.java
/** * Convert <code>propName</code> to a lowercase-with-hyphens-style string. * This algorithm is only designed for mixes of uppercase and lowercase * letters and lone digits. A more sophisticated conversion should probably * be handled by a proper parser generator or regular expressions. *//*from w w w . j a v a2s . c o m*/ public static String toXMLName(String propName) { if (propName == null) return null; StringBuilder buf = new StringBuilder(); char c; for (int i = 0; i < propName.length(); i++) { c = propName.charAt(i); // convert sequences of all-caps to downcase with dashes around // them. put a trailing cap that is followed by downcase into the // downcase word. if (i != 0 && Character.isUpperCase(c) && (Character.isLowerCase(propName.charAt(i - 1)) || (i > 1 && i < propName.length() - 1 && Character.isUpperCase(propName.charAt(i - 1)) && Character.isLowerCase(propName.charAt(i + 1))))) buf.append('-'); // surround sequences of digits with dashes. if (i != 0 && ((!Character.isLetter(c) && Character.isLetter(propName.charAt(i - 1))) || (Character.isLetter(c) && !Character.isLetter(propName.charAt(i - 1))))) buf.append('-'); buf.append(Character.toLowerCase(c)); } return buf.toString(); }
From source file:adalid.commons.util.StrUtils.java
public static String getHumplessCase(String string, String hump) { if (string == null) { return null; }/*from www.ja v a 2 s.c o m*/ if (hump == null) { return null; } if (isNotMixedCase(string)) { return string; } 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 = isLetterOrDigit(c); } return y; }
From source file:nl.gridline.zieook.data.rest.RatingEventsImpl.java
private String createCaseInsensitive(String search) { StringBuilder b = new StringBuilder("("); for (int i = 0; i < search.length(); i++) { char c = search.charAt(i); if (Character.isLetter(c)) { b.append('(').append(Character.toUpperCase(c)).append('|').append(Character.toLowerCase(c)) .append(')'); } else {//from ww w . j av a 2 s .c om b.append(b); } } b.append(")"); String result = b.toString(); LOG.debug("crafted regexp: '{}'", result); return result; }
From source file:org.cesecore.util.CertTools.java
public static List<String> getPartsFromDNInternal(final String dn, final String dnPart, final boolean onlyReturnFirstMatch) { if (log.isTraceEnabled()) { log.trace(">getPartsFromDNInternal: dn:'" + dn + "', dnpart=" + dnPart + ", onlyReturnFirstMatch=" + onlyReturnFirstMatch); }/* w ww . j av a 2 s . c om*/ final List<String> parts = new ArrayList<String>(); if (dn != null && dnPart != null) { final String dnPartLowerCase = dnPart.toLowerCase(); final int dnPartLenght = dnPart.length(); boolean quoted = false; boolean escapeNext = false; int currentStartPosition = -1; for (int i = 0; i < dn.length(); i++) { final char current = dn.charAt(i); // Toggle quoting for every non-escaped "-char if (!escapeNext && current == '"') { quoted = !quoted; } // If there is an unescaped and unquoted =-char we need to investigate if it is a match for the sought after part if (!quoted && !escapeNext && current == '=' && dnPartLenght <= i) { // Check that the character before our expected partName isn't a letter (e.g. dnsName=.. should not match E=..) if (i - dnPartLenght - 1 < 0 || !Character.isLetter(dn.charAt(i - dnPartLenght - 1))) { boolean match = true; for (int j = 0; j < dnPartLenght; j++) { if (Character.toLowerCase(dn.charAt(i - dnPartLenght + j)) != dnPartLowerCase .charAt(j)) { match = false; break; } } if (match) { currentStartPosition = i + 1; } } } // When we have found a start marker, we need to be on the lookout for the ending marker if (currentStartPosition != -1 && ((!quoted && !escapeNext && (current == ',' || current == '+')) || i == dn.length() - 1)) { int endPosition = (i == dn.length() - 1) ? dn.length() - 1 : i - 1; // Remove white spaces from the end of the value while (endPosition > currentStartPosition && dn.charAt(endPosition) == ' ') { endPosition--; } // Remove white spaces from the beginning of the value while (endPosition > currentStartPosition && dn.charAt(currentStartPosition) == ' ') { currentStartPosition++; } // Only return the inner value if the part is quoted if (dn.charAt(currentStartPosition) == '"' && dn.charAt(endPosition) == '"') { currentStartPosition++; endPosition--; } parts.add(dn.substring(currentStartPosition, endPosition + 1)); if (onlyReturnFirstMatch) { break; } currentStartPosition = -1; } if (escapeNext) { // This character was escaped, so don't escape the next one escapeNext = false; } else { if (!quoted && current == '\\') { // This escape character is not escaped itself, so the next one should be escapeNext = true; } } } } if (log.isTraceEnabled()) { log.trace("<getPartsFromDNInternal: resulting DN part=" + parts.toString()); } return parts; }
From source file:org.codehaus.groovy.grails.commons.GrailsClassUtils.java
private static String convertPropertyName(String prop) { if (prop.length() == 1) { return prop.toLowerCase(); }/* ww w . j a v a 2 s.c o m*/ if (Character.isUpperCase(prop.charAt(0)) && Character.isUpperCase(prop.charAt(1))) { return prop; } if (Character.isDigit(prop.charAt(0))) { return prop; } return Character.toLowerCase(prop.charAt(0)) + prop.substring(1); }