Example usage for java.lang Character toLowerCase

List of usage examples for java.lang Character toLowerCase

Introduction

In this page you can find the example usage for java.lang Character toLowerCase.

Prototype

public static int toLowerCase(int codePoint) 

Source Link

Document

Converts the character (Unicode code point) argument to lowercase using case mapping information from the UnicodeData file.

Usage

From source file:android.databinding.tool.reflection.ModelClass.java

private static String stripFieldName(String fieldName) {
    // TODO: Make this configurable through IntelliJ
    if (fieldName.length() > 2) {
        final char start = fieldName.charAt(2);
        if (fieldName.startsWith("m_") && Character.isJavaIdentifierStart(start)) {
            return Character.toLowerCase(start) + fieldName.substring(3);
        }/*from ww w . j  a  v a 2s  .  c o  m*/
    }
    if (fieldName.length() > 1) {
        final char start = fieldName.charAt(1);
        final char fieldIdentifier = fieldName.charAt(0);
        final boolean strip;
        if (fieldIdentifier == '_') {
            strip = true;
        } else if (fieldIdentifier == 'm' && Character.isJavaIdentifierStart(start)
                && !Character.isLowerCase(start)) {
            strip = true;
        } else {
            strip = false; // not mUppercase format
        }
        if (strip) {
            return Character.toLowerCase(start) + fieldName.substring(2);
        }
    }
    return fieldName;
}

From source file:de.codesourcery.springmass.springmass.SimulationParamsBuilder.java

private String extractParameterName(Method m) {
    Method methodWithLabel = null;
    if (isParameterGetter(m)) {
        // look for @Label on corresponding setter
        if (m.getName().startsWith("get") || m.getName().startsWith("is")) {
            final int charsToRemove = m.getName().startsWith("get") ? 3 : 2;
            final String setterName = "set" + m.getName().substring(charsToRemove);
            try {
                methodWithLabel = m.getDeclaringClass().getMethod(setterName,
                        new Class<?>[] { m.getReturnType() });
            } catch (NoSuchMethodException | SecurityException e) {
                /* ok */ }
        }/*ww w  .  j  a  va  2s .c o m*/
    } else {
        methodWithLabel = m;
    }

    if (methodWithLabel != null) {
        final Label label = methodWithLabel.getAnnotation(Label.class);
        if (label != null && !StringUtils.isBlank(label.value())) {
            return label.value();
        }
    }

    String name;
    if (m.getName().startsWith("set") || m.getName().startsWith("get")) {
        name = m.getName().substring(3);
    } else if (m.getName().startsWith("is")) {
        name = m.getName().substring(2);
    } else {
        throw new IllegalArgumentException("Invalid method name: " + m);
    }
    name = Character.toUpperCase(name.charAt(0)) + name.substring(1);
    final List<String> split = new ArrayList<>();
    final StringBuffer buffer = new StringBuffer();
    for (char s : name.toCharArray()) {
        if (Character.isUpperCase(s)) {
            if (buffer.length() > 1) {
                split.add(buffer.toString());
                buffer.setLength(0);
                buffer.append(Character.toLowerCase(s));
                continue;
            }
        }
        if (split.isEmpty()) {
            buffer.append(s);
        } else {
            buffer.append(Character.toLowerCase(s));
        }
    }
    if (buffer.length() > 0) {
        split.add(buffer.toString());
    }

    return StringUtils.join(split, " ");
}

From source file:com.zenesis.qx.remote.ProxyTypeImpl.java

/**
 * Detects whether the method is a property accessor
 * @param method//w  w  w .  j  a v a 2 s .c om
 * @return
 */
protected boolean isPropertyAccessor(Method method) {
    String name = method.getName();
    if (!name.startsWith("set") && !name.startsWith("get"))
        return false;
    name = Character.toLowerCase(name.charAt(3)) + name.substring(4);
    return isProperty(name);
}

From source file:com.nridge.core.base.std.StrUtl.java

/**
 * Uses a simple Caesar-cypher encryption to replace each English letter
 * with the one 13 places forward or back along the alphabet, so that
 * "The butler did it!" becomes "Gur ohgyre qvq vg!".   major advantage
 * of rot13 over rot(N) for other N is that it is self-inverse, so the
 * same code can be used for encoding and decoding.
 * <p>/* w  w w  .ja  va  2 s. c o m*/
 * <i>Note: The returned string will be wrapped with the less-than and
 * greater-than characters to signify that they were encrypted by this method.
 * These wrappers will be expected when the string is recovered.</i>
 * </p>
 *
 * @param aStringPlain A plain text string to encode.
 * @return An encrypted <i>String</i> object.
 */
public static String hidePassword(String aStringPlain) {
    char ch;
    boolean isAllUpper;
    StringBuilder strBuilder;
    int strLength, someNumber;

    if (StringUtils.isEmpty(aStringPlain))
        return aStringPlain;
    else {
        strBuilder = new StringBuilder();
        strLength = aStringPlain.length();
        if (strLength > STRUTL_ROT13PW_SIZE)
            strLength = STRUTL_ROT13PW_SIZE - 1;

        isAllUpper = true;

        for (int i = 0; i < strLength; i++) {
            ch = aStringPlain.charAt(i);
            if (Character.isLowerCase(ch)) {
                isAllUpper = false;
                break;
            }
        }

        strBuilder.append(STRUTL_CHAR_PWBEGIN);

        if (isAllUpper)
            ch = 'A';
        else
            ch = 'a';
        ch += strLength;
        strBuilder.append(ch);

        if (strLength > STRUTL_ROT13PW_SIZE)
            strBuilder.append(aStringPlain, 0, STRUTL_ROT13PW_SIZE);
        else
            strBuilder.append(aStringPlain);

        someNumber = 2;
        for (int i = strLength; i < STRUTL_ROT13PW_SIZE; i++) {
            if (isAllUpper)
                ch = 'A';
            else
                ch = 'a';
            ch += i;
            if ((NumUtl.isEven(i)) && (!isAllUpper))
                ch = Character.toLowerCase(ch);
            else if ((i % 3) == 0) {
                ch = '1';
                ch += someNumber;
                someNumber++;
            }
            strBuilder.append(ch);
        }

        strBuilder.append(STRUTL_CHAR_PWFINISH);

        return simple13Rotation(strBuilder.toString());
    }
}

From source file:app.sunstreak.yourpisd.net.Parser.java

public static String toTitleCase(String str) {
    StringBuilder sb = new StringBuilder(str.length());
    boolean capitalize = false;
    for (int charNum = 0; charNum < str.length(); charNum++) {

        capitalize = (charNum == 0 || !Character.isLetter(str.charAt(charNum - 1))
                || (str.substring(charNum - 1, charNum + 1).equals("AP")
                        || str.substring(charNum - 1, charNum + 1).equals("IB")
                        || str.substring(charNum - 1, charNum + 1).equals("IH"))
                        && (charNum + 2 >= str.length() || !Character.isLetter(str.charAt(charNum + 1))));

        if (capitalize)
            sb.append(Character.toUpperCase(str.charAt(charNum)));
        else/*from  w w w.j  av a  2 s  . com*/
            sb.append(Character.toLowerCase(str.charAt(charNum)));
    }
    return sb.toString();
}

From source file:ips1ap101.lib.base.util.StrUtils.java

public static String getHumplessCase(String string, String hump) {
    if (string == null) {
        return null;
    }//from   ww w .  j a v  a  2  s  .  c  om
    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 = true;
    }
    return y;
}

From source file:de.homelab.madgaksha.lotsofbs.util.LocaleRootWordUtils.java

/**
 * <p>//from  w  ww  . j a  v a  2  s . com
 * Uncapitalizes all the whitespace separated words in a String. Only the
 * first letter of each word is changed.
 * </p>
 *
 * <p>
 * The delimiters represent a set of characters understood to separate
 * words. The first string character and the first non-delimiter character
 * after a delimiter will be uncapitalized.
 * </p>
 *
 * <p>
 * Whitespace is defined by {@link Character#isWhitespace(char)}. A
 * <code>null</code> input String returns <code>null</code>.
 * </p>
 *
 * <pre>
 * WordUtils.uncapitalize(null, *)            = null
 * WordUtils.uncapitalize("", *)              = ""
 * WordUtils.uncapitalize(*, null)            = *
 * WordUtils.uncapitalize(*, new char[0])     = *
 * WordUtils.uncapitalize("I AM.FINE", {'.'}) = "i AM.fINE"
 * </pre>
 * 
 * @param str
 *            the String to uncapitalize, may be null
 * @param delimiters
 *            set of characters to determine uncapitalization, null means
 *            whitespace
 * @return uncapitalized String, <code>null</code> if null String input
 * @see #capitalize(String)
 * @since 2.1
 */
public static String uncapitalize(final String str, final char... delimiters) {
    final int delimLen = delimiters == null ? -1 : delimiters.length;
    if (StringUtils.isEmpty(str) || delimLen == 0) {
        return str;
    }
    final char[] buffer = str.toCharArray();
    boolean uncapitalizeNext = true;
    for (int i = 0; i < buffer.length; i++) {
        final char ch = buffer[i];
        if (isDelimiter(ch, delimiters)) {
            uncapitalizeNext = true;
        } else if (uncapitalizeNext) {
            buffer[i] = Character.toLowerCase(ch);
            uncapitalizeNext = false;
        }
    }
    return new String(buffer);
}

From source file:StringUtil.java

/**
 * Finds first index of a substring in the given source string and range with
 * ignored case./*from   w  ww  .java2 s  .  co  m*/
 *
 * @param src   source string for examination
 * @param sub   substring to find
 * @param startIndex  starting index from where search begins
 * @param endIndex    endint index
 * @return index of founded substring or -1 if substring is not found
 * @see #indexOfIgnoreCase(String, String, int)
 */
public static int indexOfIgnoreCase(String src, String sub, int startIndex, int endIndex) {
    if (startIndex < 0) {
        startIndex = 0;
    }
    int srclen = src.length();
    if (endIndex > srclen) {
        endIndex = srclen;
    }

    int sublen = sub.length();
    if (sublen == 0) {
        return startIndex > srclen ? srclen : startIndex;
    }
    sub = sub.toLowerCase();
    int total = endIndex - sublen + 1;
    char c = sub.charAt(0);
    mainloop: for (int i = startIndex; i < total; i++) {
        if (Character.toLowerCase(src.charAt(i)) != c) {
            continue;
        }
        int j = 1;
        int k = i + 1;
        while (j < sublen) {
            char source = Character.toLowerCase(src.charAt(k));
            if (sub.charAt(j) != source) {
                continue mainloop;
            }
            j++;
            k++;
        }
        return i;
    }
    return -1;
}

From source file:com.sun.faces.generate.HtmlTaglibGenerator.java

/**
 * Build the tag name from componentFamily and rendererType.  The name will
 * be "camel case"./*from  ww w  .j a va  2 s.  c o  m*/
 *
 * @param componentFamily the component family
 * @param rendererType the renderer type
 */
private static String makeTldTagName(String componentFamily, String rendererType) {
    if (componentFamily == null) {
        return null;
    }
    String tagName = Character.toLowerCase(componentFamily.charAt(0)) + componentFamily.substring(1);
    if (rendererType == null) {
        return tagName;
    }
    if (componentFamily.equals(rendererType)) {
        return tagName;
    }
    if (rendererType != null) {
        tagName = tagName + rendererType;
    }
    return tagName;
}

From source file:com.aiblockchain.api.StringUtils.java

/**
 * Gets a lower case predicate or variable name derived from the given simple class name.
 *
 * @param simpleClassName the given simple class name
 *
 * @return a lower case predicate or variable name derived from the given simple class name
 *//*from   w ww .ja  va 2  s  . co  m*/
public static String getLowerCasePredicateName(final String simpleClassName) {
    //Preconditions
    assert simpleClassName != null : "simpleClassName must not be null";
    assert !simpleClassName.isEmpty() : "simpleClassName must not be empty";

    // predicates begin with a lower case letter, but class names are capitalized and may also begin with a accronym
    if (simpleClassName.length() == 1) {
        // trivial case
        return simpleClassName.toLowerCase(Locale.ENGLISH);
    } else {
        final StringBuilder stringBuilder = new StringBuilder();

        int index = 0;
        final int simpleClassName_len = simpleClassName.length();
        while (true) {
            if (index >= simpleClassName_len) {
                // reached the end with all upper case characters
                break;
            }
            char ch = simpleClassName.charAt(index);
            stringBuilder.append(Character.toLowerCase(ch));

            if (index < simpleClassName_len - 2 && Character.isUpperCase(simpleClassName.charAt(index + 1))
                    && Character.isLowerCase(simpleClassName.charAt(index + 2))) {
                break;
            } else if (index < simpleClassName_len - 1
                    && Character.isLowerCase(simpleClassName.charAt(index + 1))) {
                break;
            }
            index++;
        }

        // copy any remaining characters unchanged
        for (int i = index + 1; i < simpleClassName_len; i++) {
            stringBuilder.append(simpleClassName.charAt(i));
        }
        return stringBuilder.toString();
    }
}