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:StringUtil.java

/**
 * Finds last index of a character in the given source string in specified range [end, start]
 *//*from w  ww.j  a  v  a 2s . co m*/
public static int lastIndexOfIgnoreCase(String src, char c, int startIndex, int endIndex) {
    int total = src.length() - 1;
    if (total < 0) {
        return -1;
    }
    if (startIndex >= total) {
        startIndex = total;
    }
    if (endIndex < 0) {
        endIndex = 0;
    }
    c = Character.toLowerCase(c);
    for (int i = startIndex; i >= endIndex; i--) {
        if (Character.toLowerCase(src.charAt(i)) == c) {
            return i;
        }
    }
    return -1;
}

From source file:com.github.reinert.jjschema.JsonSchemaGenerator.java

private String firstToLowCase(String string) {
    return Character.toLowerCase(string.charAt(0)) + (string.length() > 1 ? string.substring(1) : "");
}

From source file:org.teavm.flavour.json.emit.ClassInformationProvider.java

private String decapitalize(String name) {
    if (name.length() > 1 && name.charAt(1) == Character.toUpperCase(name.charAt(1))) {
        return name;
    }//from w ww  .j  a  v  a2s .c  om
    return Character.toLowerCase(name.charAt(0)) + name.substring(1);
}

From source file:org.dhatim.cdr.annotation.Configurator.java

private static String getPropertyName(Method method) {
    if (!method.getName().startsWith("set")) {
        return null;
    }/*from w  ww.  j av  a  2  s  . c  om*/

    StringBuffer methodName = new StringBuffer(method.getName());

    if (methodName.length() < 4) {
        return null;
    }

    methodName.delete(0, 3);
    methodName.setCharAt(0, Character.toLowerCase(methodName.charAt(0)));

    return methodName.toString();
}

From source file:org.apache.nifi.processors.ParseCSV.ParseCSV.java

private String mask(String str) {

    final String consotant = "bcdfghjklmnpqrstvwxz";
    final String vowel = "aeiouy";
    final String digit = "0123456789";

    DateFormat dateFormat = new SimpleDateFormat("ssSSS");
    Date date = new Date();
    Random ran = new Random();
    Random r = new Random(Integer.parseInt(dateFormat.format(date) + ran.nextInt(1000)));

    char data[] = str.toCharArray();

    for (int n = 0; n < data.length; ++n) {
        char ln = Character.toLowerCase(data[n]);
        if (consotant.indexOf(ln) >= 0)
            data[n] = randomChar(r, consotant, ln != data[n]);
        else if (vowel.indexOf(ln) >= 0)
            data[n] = randomChar(r, vowel, ln != data[n]);
        else if (digit.indexOf(ln) >= 0)
            data[n] = randomChar(r, digit, ln != data[n]);
    }//from   w ww  . j a v  a2s.  c  o  m
    return new String(data);
}

From source file:com.github.zhanhb.ckfinder.connector.support.XmlConfigurationParser.java

/**
 * parses max size value from config (ex. 16M to number of bytes).
 *
 * @param maxSize string representation of the max size
 * @return number of bytes in max size./*w  w  w. j ava  2  s . c  o  m*/
 */
private long parseMaxSize(String maxSize) {
    char lastChar = Character.toLowerCase(maxSize.charAt(maxSize.length() - 1));
    int a = 1, off = 1;
    switch (lastChar) {
    case 'k':
        a = BYTES;
        break;
    case 'm':
        a = BYTES * BYTES;
        break;
    case 'g':
        a = BYTES * BYTES * BYTES;
        break;
    default:
        off = 0;
        break;
    }
    long value = Long.parseLong(maxSize.substring(0, maxSize.length() - off));
    return value * a;
}

From source file:com.nttec.everychan.ui.presentation.HtmlParser.java

private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength);
    } else if (tag.equalsIgnoreCase("div")) {
        handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength);
    } else if (tag.equalsIgnoreCase("strong")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("b")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("em")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("cite")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("dfn")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("i")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("s")) {
        end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("strike")) {
        end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("del")) {
        end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("big")) {
        end(mSpannableStringBuilder, Big.class, new RelativeSizeSpan(1.25f));
    } else if (tag.equalsIgnoreCase("small")) {
        end(mSpannableStringBuilder, Small.class, new RelativeSizeSpan(0.8f));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength);
        endBlockquote(mSpannableStringBuilder, mColors);
    } else if (tag.equalsIgnoreCase("tt")) {
        end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan("monospace"));
    } else if (tag.equalsIgnoreCase("code")) {
        end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan("monospace"));
    } else if (tag.equalsIgnoreCase("ul")) {
        if (!mListTags.isEmpty())
            mListTags.removeFirst();// w  ww .j  a v a 2 s .  c om
    } else if (tag.equalsIgnoreCase("ol")) {
        if (!mListTags.isEmpty())
            mListTags.removeFirst();
    } else if (tag.equalsIgnoreCase("li")) {
        //??  ?? <li>
    } else if (tag.equalsIgnoreCase("tr")) {
        handleTr(mSpannableStringBuilder, false);
    } else if (tag.equalsIgnoreCase("td")) {
        handleTd(mSpannableStringBuilder, false);
    } else if (tag.equalsIgnoreCase("a")) {
        endA(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("u")) {
        end(mSpannableStringBuilder, Underline.class, new UnderlineSpan());
    } else if (tag.equalsIgnoreCase("sup")) {
        end(mSpannableStringBuilder, Super.class, new SuperscriptSpan());
    } else if (tag.equalsIgnoreCase("sub")) {
        end(mSpannableStringBuilder, Sub.class, new SubscriptSpan());
    } else if (tag.length() == 2 && Character.toLowerCase(tag.charAt(0)) == 'h' && tag.charAt(1) >= '1'
            && tag.charAt(1) <= '6') {
        handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength);
        endHeader(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("span")) {
        endSpan(mSpannableStringBuilder, mColors, mOpenSpoilers);
    } else if (tag.equalsIgnoreCase("aibquote")) {
        end(mSpannableStringBuilder, Aibquote.class,
                new ForegroundColorSpan(mColors != null ? mColors.quoteForeground : Color.GREEN));
    } else if (tag.equalsIgnoreCase("aibspoiler")) {
        endAibspoiler(mSpannableStringBuilder, mColors, mOpenSpoilers);
    } /* else if (mTagHandler != null) {
      mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
      }*/
}

From source file:com.cohort.util.String2.java

/**
 * This goes beyond equalsIgnoreCase by looking after punctuation removed.
 *
 * @param s1/*w w w  . ja  va2 s  .  c  om*/
 * @param s2
 * @return true if find is loosely in s. Return false if s or find !isSomething.
 */
public static boolean looselyEquals(String s1, String s2) {
    if (s1 == null || s2 == null)
        return false;

    int s1Length = s1.length();
    StringBuilder s1sb = new StringBuilder();
    for (int i = 0; i < s1Length; i++) {
        char ch = s1.charAt(i);
        if (Character.isLetterOrDigit(ch))
            s1sb.append(Character.toLowerCase(ch));
    }
    if (s1sb.length() == 0)
        return false;

    int s2Length = s2.length();
    StringBuilder s2sb = new StringBuilder();
    for (int i = 0; i < s2Length; i++) {
        char ch = s2.charAt(i);
        if (Character.isLetterOrDigit(ch))
            s2sb.append(Character.toLowerCase(ch));
    }
    if (s2sb.length() == 0)
        return false;

    return s1sb.toString().equals(s2sb.toString());
}

From source file:com.netspective.commons.text.TextUtils.java

/**
 * Given a text string, return a string that would be suitable for an XML element name. For example,
 * when given Person_Address it would return person-address. The rule is to basically take every letter
 * or digit and return it in lowercase and every non-letter or non-digit as a dash.
 *//*from ww  w .jav  a2 s  .  c  o  m*/
public String xmlTextToNodeName(String xml) {
    if (xml == null || xml.length() == 0)
        return xml;

    StringBuffer constant = new StringBuffer();
    for (int i = 0; i < xml.length(); i++) {
        char ch = xml.charAt(i);
        constant.append(Character.isLetterOrDigit(ch) ? Character.toLowerCase(ch) : '-');
    }
    return constant.toString();
}

From source file:org.loklak.geo.GeoNames.java

/**
 * Split the text into word tokens. The tokens are lower-cased. To maintain the original spelling
 * of the word without lowercasing them, the original word is attached too.
 * @param text/*from   www.j ava 2 s.  com*/
 * @return a List of Map.Entry objects where the key is the lower-cased word token and the value is the original word
 */
public static ArrayList<Map.Entry<String, String>> split(final String text) {
    ArrayList<Map.Entry<String, String>> a = new ArrayList<>(1 + text.length() / 4);
    final StringBuilder o = new StringBuilder();
    final StringBuilder l = new StringBuilder();
    for (int i = 0; i < text.length(); i++) {
        final char c = text.charAt(i);
        if (Character.isLetterOrDigit(c)) {
            o.append(c);
            l.append(Character.toLowerCase(c));
            continue;
        }
        // if it is not letter or digit, we split it.
        if (o.length() > 0) {
            a.add(new AbstractMap.SimpleEntry<String, String>(l.toString(), o.toString()));
            o.setLength(0);
            l.setLength(0);
        }
    }
    if (o.length() > 0) {
        a.add(new AbstractMap.SimpleEntry<String, String>(l.toString(), o.toString()));
        o.setLength(0);
        l.setLength(0);
    }
    return a;
}