Java String Uncapitalize uncapitalize(String str)

Here you can find the source of uncapitalize(String str)

Description

uncapitalize

License

Mozilla Public License

Declaration

public static String uncapitalize(String str) 

Method Source Code

//package com.java2s;
//License from project: Mozilla Public License 

public class Main {
    public static String uncapitalize(String str) {
        return uncapitalize(str, null);
    }/*w w  w . ja  v a2s .  c o  m*/

    public static String uncapitalize(String str, char[] delimiters) {
        int delimLen = (delimiters == null ? -1 : delimiters.length);

        if (str == null || str.length() == 0 || delimLen == 0) {
            return str;
        }

        int strLen = str.length();

        StringBuilder buffer = new StringBuilder(strLen);

        boolean uncapitalizeNext = true;

        for (int i = 0; i < strLen; i++) {
            char ch = str.charAt(i);

            if (isDelimiter(ch, delimiters)) {
                buffer.append(ch);

                uncapitalizeNext = true;
            } else if (uncapitalizeNext) {
                buffer.append(Character.toLowerCase(ch));

                uncapitalizeNext = false;
            } else {
                buffer.append(ch);
            }
        }

        return buffer.toString();
    }

    private static boolean isDelimiter(char ch, char[] delimiters) {
        if (delimiters == null) {
            return Character.isWhitespace(ch);
        }

        for (int i = 0, isize = delimiters.length; i < isize; i++) {
            if (ch == delimiters[i]) {
                return true;
            }
        }

        return false;
    }
}

Related

  1. uncapitalize(String s)
  2. uncapitalize(String source)
  3. unCapitalize(String str)
  4. uncapitalize(String str)
  5. uncapitalize(String str)
  6. uncapitalize(String str)
  7. uncapitalize(String str)
  8. uncapitalize(String str)
  9. uncapitalize(String str)