List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:co.marcin.novaguilds.util.StringUtils.java
public static String unTranslateAlternateColorCodes(String msg) { char altColorChar = ChatColor.COLOR_CHAR; char[] b = msg.toCharArray(); for (int i = 0; i < b.length - 1; i++) { if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) { b[i] = '&'; b[i + 1] = Character.toLowerCase(b[i + 1]); }//w w w . ja va 2 s.c o m } return new String(b); }
From source file:com.amazonaws.hal.client.ConversionUtil.java
static String getPropertyName(String original) { StringBuilder propertyName = new StringBuilder(original.substring("get".length())); propertyName.setCharAt(0, Character.toLowerCase(propertyName.charAt(0))); return propertyName.toString(); }
From source file:grails.web.HyphenatedUrlConverter.java
public String toUrlElement(String propertyOrClassName) { if (StringUtils.isBlank(propertyOrClassName)) { return propertyOrClassName; }//ww w . j a va2 s . c om StringBuilder builder = new StringBuilder(); char[] charArray = propertyOrClassName.toCharArray(); for (char c : charArray) { if (Character.isUpperCase(c)) { if (builder.length() > 0) { builder.append("-"); } builder.append(Character.toLowerCase(c)); } else { builder.append(c); } } return builder.toString(); }
From source file:Main.java
/** * Green implementation of regionMatches. * * @param cs the {@code CharSequence} to be processed * @param ignoreCase whether or not to be case insensitive * @param thisStart the index to start on the {@code cs} CharSequence * @param substring the {@code CharSequence} to be looked for * @param start the index to start on the {@code substring} CharSequence * @param length character length of the region * @return whether the region matched//from w ww . j a va2 s . c o m */ static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, final int thisStart, final CharSequence substring, final int start, final int length) { if (cs instanceof String && substring instanceof String) { return ((String) cs).regionMatches(ignoreCase, thisStart, (String) substring, start, length); } else { int index1 = thisStart; int index2 = start; int tmpLen = length; while (tmpLen-- > 0) { char c1 = cs.charAt(index1++); char c2 = substring.charAt(index2++); if (c1 == c2) { continue; } if (!ignoreCase) { return false; } // The same check as in String.regionMatches(): if (Character.toUpperCase(c1) != Character.toUpperCase(c2) && Character.toLowerCase(c1) != Character.toLowerCase(c2)) { return false; } } return true; } }
From source file:com.jaxio.celerio.util.IdentifiableProperty.java
public IdentifiableProperty(String property) { getter = GET.build(property);/*from w w w .jav a 2s. c o m*/ setter = SET.build(property); iser = HAS.build(property); var = Character.toLowerCase(property.charAt(0)) + property.substring(1); varUp = capitalize(property); }
From source file:Main.java
/** * <p>Swaps the case of a String changing upper and title case to * lower case, and lower case to upper case.</p> * * <ul>/*from w w w. j a va 2 s .c o m*/ * <li>Upper case character converts to Lower case</li> * <li>Title case character converts to Lower case</li> * <li>Lower case character converts to Upper case</li> * </ul> * * <p>For a word based algorithm, see {@link WordUtils#swapCase(String)}. * A <code>null</code> input String returns <code>null</code>.</p> * * <pre> * StringUtils.swapCase(null) = null * StringUtils.swapCase("") = "" * StringUtils.swapCase("The dog has a BONE") = "tHE DOG HAS A bone" * </pre> * * <p>NOTE: This method changed in Lang version 2.0. * It no longer performs a word based algorithm. * If you only use ASCII, you will notice no change. * That functionality is available in WordUtils.</p> * * @param str the String to swap case, may be null * @return the changed String, <code>null</code> if null String input */ public static String swapCase(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return str; } StringBuffer buffer = new StringBuffer(strLen); char ch = 0; for (int i = 0; i < strLen; i++) { ch = str.charAt(i); if (Character.isUpperCase(ch)) { ch = Character.toLowerCase(ch); } else if (Character.isTitleCase(ch)) { ch = Character.toLowerCase(ch); } else if (Character.isLowerCase(ch)) { ch = Character.toUpperCase(ch); } buffer.append(ch); } return buffer.toString(); }
From source file:MiscUtils.java
/** * Compares two strings.<p>/*from w ww . ja v a 2s . co m*/ * <p/> * Unlike <function>String.compareTo()</function>, * this method correctly recognizes and handles embedded numbers. * For example, it places "My file 2" before "My file 10".<p> * * @param str1 The first string * @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 * @since jEdit 4.3pre5 */ 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])) { //_i--; break; } } for (; _j < char2.length; _j++) { if (!Character.isDigit(char2[_j])) { //_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.hippoecm.frontend.util.PluginConfigMapper.java
private static String toConfigKey(String camelKey) { StringBuilder b = new StringBuilder(camelKey.length() + 4); for (char ch : camelKey.toCharArray()) { if (Character.isUpperCase(ch)) { b.append('.').append(Character.toLowerCase(ch)); } else {/* ww w .jav a 2s. c o m*/ b.append(ch); } } return b.toString(); }
From source file:Main.java
/** * Green implementation of regionMatches. * * @param cs/*from w w w.j a v a 2 s . com*/ * the <code>CharSequence</code> to be processed * @param ignoreCase * whether or not to be case insensitive * @param thisStart * the index to start on the <code>cs</code> CharSequence * @param substring * the <code>CharSequence</code> to be looked for * @param start * the index to start on the <code>substring</code> CharSequence * @param length * character length of the region * @return whether the region matched */ static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, final int thisStart, final CharSequence substring, final int start, final int length) { if (cs instanceof String && substring instanceof String) { return ((String) cs).regionMatches(ignoreCase, thisStart, (String) substring, start, length); } int index1 = thisStart; int index2 = start; int tmpLen = length; while (tmpLen-- > 0) { char c1 = cs.charAt(index1++); char c2 = substring.charAt(index2++); if (c1 == c2) { continue; } if (!ignoreCase) { return false; } // The same check as in String.regionMatches(): if (Character.toUpperCase(c1) != Character.toUpperCase(c2) && Character.toLowerCase(c1) != Character.toLowerCase(c2)) { return false; } } return true; }
From source file:Main.java
/** * Similar to String.contains() with two main differences: * <p>/*w w w . ja v a 2s .c om*/ * 1) Only searches token prefixes. A token is defined as any combination of letters or * numbers. * <p> * 2) Returns the starting index where the substring is found. * * @param value The string to search. * @param substring The substring to look for. * @return The starting index where the substring is found. {@literal -1} if substring is not * found in value. */ @VisibleForTesting static int contains(String value, String substring) { if (value.length() < substring.length()) { return -1; } // i18n support // Generate the code points for the substring once. // There will be a maximum of substring.length code points. But may be fewer. // Since the array length is not an accurate size, we need to keep a separate variable. final int[] substringCodePoints = new int[substring.length()]; int substringLength = 0; // may not equal substring.length()!! for (int i = 0; i < substring.length();) { final int codePoint = Character.codePointAt(substring, i); substringCodePoints[substringLength] = codePoint; substringLength++; i += Character.charCount(codePoint); } for (int i = 0; i < value.length(); i = findNextTokenStart(value, i)) { int numMatch = 0; for (int j = i; j < value.length() && numMatch < substringLength; ++numMatch) { int valueCp = Character.toLowerCase(value.codePointAt(j)); int substringCp = substringCodePoints[numMatch]; if (valueCp != substringCp) { break; } j += Character.charCount(valueCp); } if (numMatch == substringLength) { return i; } } return -1; }