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:net.certiv.antlr.project.util.Strings.java

public static String camelCase(String in) {
    StringBuilder sb = new StringBuilder(in);
    for (int idx = sb.length() - 1; idx >= 0; idx--) {
        char c = sb.charAt(idx);
        if (c == '_') {
            sb.deleteCharAt(idx);//from ww w . ja  v  a  2s  .  c  om
            sb.setCharAt(idx, Character.toUpperCase(sb.charAt(idx)));
        } else if (Character.isUpperCase(c)) {
            sb.setCharAt(idx, Character.toLowerCase(c));
        }
    }
    sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
    return sb.toString();
}

From source file:com.bfd.harpc.main.ConfigHelper.java

/**
 * ??//from  w  ww.  j  av a2  s.c  om
 * <p>
 * 
 * @param configObject
 *            ?
 * @param configPrefix
 *            ??
 * @param configuration
 *            {@link PropertiesConfiguration}
 * @throws RpcException
 */
public static void initConfig(Object configObject, String configPrefix, PropertiesConfiguration configuration)
        throws RpcException {
    Method[] methods = configObject.getClass().getMethods();
    for (Method method : methods) {
        if (method.getName().length() > 3 && method.getName().startsWith("set")
                && method.getParameterTypes().length == 1) {
            String attribute = method.getName().substring(3);
            char ch = attribute.charAt(0);
            attribute = Character.toLowerCase(ch) + attribute.substring(1);
            String value = configuration.getProperty(configPrefix + attribute, "");

            try {
                if (StringUtils.isNotEmpty(value)) {
                    Type type = method.getParameterTypes()[0];
                    if (type == boolean.class) {
                        method.invoke(configObject, Boolean.valueOf(value));
                    } else if (type == int.class) {
                        method.invoke(configObject, Integer.valueOf(value));
                    } else if (type == long.class) {
                        method.invoke(configObject, Long.valueOf(value));
                    } else {
                        method.invoke(configObject, value);
                    }
                }
            } catch (Exception e) {
                LOGGER.error("Init config error", e);
                throw new RpcException(RpcException.CONFIG_EXCEPTION, e);
            }
        }
    }
}

From source file:Main.java

/**
 * It decodes the given string/*from ww w  . j  a  va2  s .c  o  m*/
 * 
 * @param encodedURI
 * @return decoded string
 */
public static String decodeURIComponent(final String encodedURI) {
    char actualChar;

    StringBuffer buffer = new StringBuffer();

    int bytePattern, sumb = 0;

    for (int i = 0, more = -1; i < encodedURI.length(); i++) {
        actualChar = encodedURI.charAt(i);

        switch (actualChar) {
        case '%': {
            actualChar = encodedURI.charAt(++i);
            int hb = (Character.isDigit(actualChar) ? actualChar - '0'
                    : 10 + Character.toLowerCase(actualChar) - 'a') & 0xF;
            actualChar = encodedURI.charAt(++i);
            int lb = (Character.isDigit(actualChar) ? actualChar - '0'
                    : 10 + Character.toLowerCase(actualChar) - 'a') & 0xF;
            bytePattern = (hb << 4) | lb;
            break;
        }
        case '+': {
            bytePattern = ' ';
            break;
        }
        default: {
            bytePattern = actualChar;
        }
        }

        if ((bytePattern & 0xc0) == 0x80) { // 10xxxxxx
            sumb = (sumb << 6) | (bytePattern & 0x3f);
            if (--more == 0) {
                buffer.append((char) sumb);
            }
        } else if ((bytePattern & 0x80) == 0x00) { // 0xxxxxxx
            buffer.append((char) bytePattern);
        } else if ((bytePattern & 0xe0) == 0xc0) { // 110xxxxx
            sumb = bytePattern & 0x1f;
            more = 1;
        } else if ((bytePattern & 0xf0) == 0xe0) { // 1110xxxx
            sumb = bytePattern & 0x0f;
            more = 2;
        } else if ((bytePattern & 0xf8) == 0xf0) { // 11110xxx
            sumb = bytePattern & 0x07;
            more = 3;
        } else if ((bytePattern & 0xfc) == 0xf8) { // 111110xx
            sumb = bytePattern & 0x03;
            more = 4;
        } else { // 1111110x
            sumb = bytePattern & 0x01;
            more = 5;
        }
    }
    return buffer.toString();
}

From source file:nz.co.senanque.schemabuilder.NameHandler.java

private static String initialLowerCase(String str) {
    if (str == null) {
        return str;
    }//from ww w. ja v a  2 s.  com
    if (str.length() < 2) {
        return StringUtils.lowerCase(str);
    }
    return Character.toLowerCase(str.charAt(0)) + str.substring(1);
}

From source file:com.github.thesmartenergy.sparql.generate.jena.engine.TestBase.java

static void setUpClass(Class clazz) throws Exception {
    LOG = Logger.getLogger(clazz);
    LOG.debug(clazz.getName());//from   w w w  . ja  v  a  2 s  .  c om
    String dir = clazz.getSimpleName();
    dir = Character.toLowerCase(dir.charAt(0)) + (dir.length() > 1 ? dir.substring(1) : "");
    examplePath = clazz.getResource("/" + dir);

    exampleDir = new File(examplePath.toURI());

    // read location-mapping
    URI confUri = exampleDir.toURI().resolve("configuration.ttl");
    Model conf = RDFDataMgr.loadModel(confUri.toString());

    // initialize file manager
    fileManager = FileManager.makeGlobal();
    Locator loc = new LocatorFile(exampleDir.toURI().getPath());
    LocationMapper mapper = new LocationMapper(conf);
    fileManager.addLocator(loc);
    fileManager.setLocationMapper(mapper);
}

From source file:com.qualogy.qafe.util.StyleDomUtil.java

/**
 * convert for example backgrounColor to background-color
 * @param style//ww w.j ava  2 s . co  m
 * @return
 */
public static String deCamelCaseStyle(String style) {

    String property = "";
    for (int j = 0; j < style.length(); j++) {
        char character = style.charAt(j);
        if (Character.isUpperCase(character)) {
            property += "-" + Character.toLowerCase(character);
        } else {
            property += character;
        }
    }
    return property;
}

From source file:eu.delving.metadata.OptRole.java

private OptRole() {
    String caps = WordUtils.capitalizeFully(toString(), new char[] { '_' }).replaceAll("_", "");
    this.fieldName = Character.toLowerCase(caps.charAt(0)) + caps.substring(1);
}

From source file:barrysw19.calculon.notation.FENUtils.java

public static String generateEnPassant(BitBoard board) {

    if (!board.isEnPassant()) {
        return "-";
    }//from ww  w  .  ja v a  2s . c  o m

    StringBuilder fen = new StringBuilder();
    fen.append(Character.toLowerCase(EngineUtils.FILES.charAt(board.getEnPassantFile())));
    fen.append(EngineUtils.RANKS.charAt(board.getEnPassantRank()));

    return fen.toString();
}

From source file:com.yahoo.semsearch.fastlinking.utils.Normalize.java

License:asdf

/**
 * Normalizes and returns a span array//from w w  w.  j a v a 2  s . c  o m
 * @param args string to normalize
 * @return processed span array with (normalized) string chunks
 */
public static Span[] normalizeWithSpans(String args) {
    final StringBuilder t = new StringBuilder();
    final int length = args.length();
    List<Span> res = new ArrayList<Span>();
    int pi = -1;
    for (int i = 0; i < length; i++) {
        char charAt = args.charAt(i);
        if (Character.isLetterOrDigit(charAt) && !Character.isWhitespace(charAt)) {
            if (pi < 0)
                pi = i;
            t.append(Character.toLowerCase(charAt));
        } else {
            if (t.length() > 0) {
                res.add(new Span(t.toString(), pi, i));
                pi = -1;
                t.setLength(0);
            }
        }
    }
    if (t.length() > 0)
        res.add(new Span(t.toString(), pi, length));
    return res.toArray(new Span[0]);
}

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// ww w. j a  v a2 s  .  co  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);
    }
    int index1 = thisStart;
    int index2 = start;
    int tmpLen = length;

    while (tmpLen-- > 0) {
        final char c1 = cs.charAt(index1++);
        final 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;
}