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:org.archive.util.SURT.java

/**
 * Utility method for creating the SURT form of the URI in the
 * given String./*from  w w  w  .j a  va2s. co  m*/
 * 
 * If it appears a bit convoluted in its approach, note that it was
 * optimized to minimize object-creation after allocation-sites profiling 
 * indicated this method was a top source of garbage in long-running crawls.
 * 
 * Assumes that the String URI has already been cleaned/fixed (eg
 * by UURI fixup) in ways that put it in its crawlable form for 
 * evaluation.
 * 
 * @param s String URI to be converted to SURT form
 * @param preserveCase whether original case should be preserved
 * @return SURT form 
 */
public static String fromURI(String s, boolean preserveCase) {
    Matcher m = TextUtils.getMatcher(URI_SPLITTER, s);
    if (!m.matches()) {
        // not an authority-based URI scheme; return unchanged
        TextUtils.recycleMatcher(m);
        return s;
    }
    // preallocate enough space for SURT form, which includes
    // 3 extra characters ('(', ')', and one more ',' than '.'s
    // in original)
    StringBuffer builder = new StringBuffer(s.length() + 3);
    append(builder, s, m.start(1), m.end(1)); // scheme://
    builder.append(BEGIN_TRANSFORMED_AUTHORITY); // '('

    if (m.start(4) > -1) {
        // dotted-quad ip match: don't reverse
        append(builder, s, m.start(4), m.end(4));
    } else {
        // other hostname match: do reverse
        int hostSegEnd = m.end(5);
        int hostStart = m.start(5);
        for (int i = m.end(5) - 1; i >= hostStart; i--) {
            if (s.charAt(i - 1) != DOT && i > hostStart) {
                continue;
            }
            append(builder, s, i, hostSegEnd); // rev host segment
            builder.append(TRANSFORMED_HOST_DELIM); // ','
            hostSegEnd = i - 1;
        }
    }

    append(builder, s, m.start(6), m.end(6)); // :port
    append(builder, s, m.start(3), m.end(3)); // at
    append(builder, s, m.start(2), m.end(2)); // userinfo
    builder.append(END_TRANSFORMED_AUTHORITY); // ')'
    append(builder, s, m.start(7), m.end(7)); // path
    if (!preserveCase) {
        for (int i = 0; i < builder.length(); i++) {
            builder.setCharAt(i, Character.toLowerCase(builder.charAt((i))));
        }
    }
    TextUtils.recycleMatcher(m);
    return builder.toString();
}

From source file:com.ing.connector.util.WStringUtil.java

/**
 *  generalFormating --> makes the first letter of any character
 *                       string uppercase; otherwise, makes all
 *                       characters lowercase
 *//*from   w  w  w  .  jav a2 s  .com*/
private String generalFormating(String aString) {
    String lString = aString;
    char lPreviousChar = '\u0000';

    lString = lString.toUpperCase();

    char[] lCharArray = lString.toCharArray();

    for (int i = 0; i < lString.length(); i++) {
        if (Character.isLetterOrDigit(lPreviousChar)) {
            lCharArray[i] = Character.toLowerCase(lCharArray[i]);
        }
        lPreviousChar = lCharArray[i];
    }

    lString = new String(lCharArray);

    return lString;
}

From source file:com.anrisoftware.globalpom.reflection.annotations.AnnotationDiscoveryImpl.java

private String getFieldName(Method method) {
    StringBuilder str = new StringBuilder();
    String name = method.getName();
    int offset = getStartOffset(name);
    if (offset == -1) {
        throw log.methodNotGetter(this, bean, method);
    }/* ww  w  . j  ava  2 s.  c  om*/
    char nameChar = Character.toLowerCase(name.charAt(offset));
    str.append(nameChar);
    str.append(name.substring(offset + 1));
    return str.toString();
}

From source file:io.tilt.minka.utils.Defaulter.java

/**
 * Use delims as word beginner mark, remove it and proper case words
 * Take "HELLO_WORLD" and turn into "helloWorld" 
 * @param s/*from  w w  w. j ava2  s .  c om*/
 * @return
 */
private static String properCaseIt(final String s) {
    final StringBuilder sb = new StringBuilder();
    boolean capit = true;
    boolean first = true;
    for (char ch : s.toCharArray()) {
        ch = capit && !first ? Character.toUpperCase(ch) : Character.toLowerCase(ch);
        if (DELIMS.indexOf((char) ch) < 0) {
            sb.append(ch);
        }
        first = false;
        capit = (DELIMS.indexOf((int) ch) >= 0);
    }
    return sb.toString();
}

From source file:au.org.ala.bhl.WordLists.java

private static char substitute(char ch) {
    for (CharacterSubstitution s : ACCENTS) {
        for (String c : s.getTargets()) {
            if (Character.toLowerCase(ch) == c.charAt(0)) {
                return s.getSubstitue().charAt(0);
            }/*w w w .  j  a  va  2 s  . c om*/
        }
    }

    return ch;
}

From source file:org.eclipse.php.internal.ui.corext.util.Strings.java

/**
 * @deprecated use/*  w  ww .j  ava 2  s.  c  om*/
 *             org.apache.commons.lang3.StringUtils.startsWithIgnoreCase()
 */
public static boolean startsWithIgnoreCase(String text, String prefix) {
    int textLength = text.length();
    int prefixLength = prefix.length();
    if (textLength < prefixLength)
        return false;
    for (int i = prefixLength - 1; i >= 0; i--) {
        if (Character.toLowerCase(prefix.charAt(i)) != Character.toLowerCase(text.charAt(i)))
            return false;
    }
    return true;
}

From source file:CharArrayMap.java

/**
 * Add this key,val pair to the map. The char[] key is directly used, no
 * copy is made. If ignoreCase is true for this Map, the key array will be
 * directly modified. The user should never modify the key after calling
 * this method.//from  w  w  w  .j  a v  a  2  s. c o m
 */
public V put(char[] key, Object val) {
    if (ignoreCase)
        for (int i = 0; i < key.length; i++)
            key[i] = Character.toLowerCase(key[i]);
    int slot = getSlot(key, 0, key.length);
    if (keys[slot] == null)
        count++;
    Object prev = values[slot];
    keys[slot] = key;
    values[slot] = val;

    if (count + (count >> 2) >= keys.length) {
        rehash();
    }

    return (V) prev;
}

From source file:br.com.bropenmaps.util.Util.java

/**
 * Desfaz as alteraes feitas quando um termo precisa ser modificado ao ser utilizado como parmetro em requisies HTTP (decoder para o {@link URLEncoder})
 * @param s - termo a ser modificado /*from w  w  w .ja  v  a 2  s. c  om*/
 * @return Retorna o termo com as modificaes realizadas
 */
public static String decoder(String s) {
    if (s == null) {
        return s;
    }

    StringBuffer sbuf = new StringBuffer();
    int l = s.length();
    int ch = -1;
    int b, sumb = 0;
    for (int i = 0, more = -1; i < l; i++) {
        /* Get next byte b from URL segment s */
        switch (ch = s.charAt(i)) {
        case '%':
            ch = s.charAt(++i);
            int hb = (Character.isDigit((char) ch) ? ch - '0' : 10 + Character.toLowerCase((char) ch) - 'a')
                    & 0xF;
            ch = s.charAt(++i);
            int lb = (Character.isDigit((char) ch) ? ch - '0' : 10 + Character.toLowerCase((char) ch) - 'a')
                    & 0xF;
            b = (hb << 4) | lb;
            break;
        default:
            b = ch;
        }
        /* Decode byte b as UTF-8, sumb collects incomplete chars */
        if ((b & 0xc0) == 0x80) { // 10xxxxxx (continuation byte)
            sumb = (sumb << 6) | (b & 0x3f); // Add 6 bits to sumb
            if (--more == 0)
                sbuf.append((char) sumb); // Aarg0dd char to sbuf
        } else if ((b & 0x80) == 0x00) { // 0xxxxxxx (yields 7 bits)
            sbuf.append((char) b); // Store in sbuf
        } else if ((b & 0xe0) == 0xc0) { // 110xxxxx (yields 5 bits)
            sumb = b & 0x1f;
            more = 1; // Expect 1 more byte
        } else if ((b & 0xf0) == 0xe0) { // 1110xxxx (yields 4 bits)
            sumb = b & 0x0f;
            more = 2; // Expect 2 more bytes
        } else if ((b & 0xf8) == 0xf0) { // 11110xxx (yields 3 bits)
            sumb = b & 0x07;
            more = 3; // Expect 3 more bytes
        } else if ((b & 0xfc) == 0xf8) { // 111110xx (yields 2 bits)
            sumb = b & 0x03;
            more = 4; // Expect 4 more bytes
        } else /*if ((b & 0xfe) == 0xfc)*/ { // 1111110x (yields 1 bit)
            sumb = b & 0x01;
            more = 5; // Expect 5 more bytes
        }
        /* We don't test if the UTF-8 encoding is well-formed */
    }
    return sbuf.toString();
}

From source file:mrcg.utils.Utils.java

public static String pluralize(String s) {
    if (s.length() == 0)
        return s;
    char c = Character.toLowerCase(s.charAt(s.length() - 1));
    if (c == 'y') {
        if (StringUtils.endsWithAny(s.toLowerCase(), "day")) {
            return s + "s";
        } else {//  w ww  .j  a  v  a 2  s .com
            return s.substring(0, s.length() - 1) + "ies";
        }
    } else if (c == 's') {
        return s + "es";
    } else {
        return s + "s";
    }
}

From source file:com.planetmayo.debrief.satc_rcp.io.XStreamIO.java

private static void aliasFor(XStream xstream, Class<?> klass) {
    String simpleName = klass.getSimpleName();
    xstream.alias(Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1), klass);
}