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.fhcrc.cpl.toolbox.datastructure.BoundMap.java

private String convertToPropertyName(String name) {
    if (1 == name.length())
        return name.toLowerCase();

    if (Character.isUpperCase(name.charAt(0)) && !Character.isUpperCase(name.charAt(1)))
        return Character.toLowerCase(name.charAt(0)) + name.substring(1);
    else/*w w w  .j ava  2  s  .  c om*/
        return name;
}

From source file:org.bonitasoft.engine.bdm.BDMQueryUtil.java

public static String createQueryContentForUniqueConstraint(final String businessObjectName,
        final UniqueConstraint uniqueConstraint) {
    if (businessObjectName == null) {
        throw new IllegalArgumentException("businessObjectName is null");
    }/*from   w  w w. ja va 2  s  .c  om*/
    if (businessObjectName.isEmpty()) {
        throw new IllegalArgumentException("businessObjectName is empty");
    }
    final String simpleName = getSimpleBusinessObjectName(businessObjectName);
    final char var = Character.toLowerCase(simpleName.charAt(0));
    final StringBuilder builder = new StringBuilder();
    builder.append(buildSelectFrom(simpleName, var));
    builder.append(buildWhereAnd(var, uniqueConstraint.getFieldNames()));
    return builder.toString();
}

From source file:com.easyjf.util.StringUtils.java

private static String changeFirstCharacterCase(String str, boolean capitalize) {
    if (str == null || str.length() == 0)
        return str;
    StringBuffer buf = new StringBuffer(str.length());
    if (capitalize)
        buf.append(Character.toUpperCase(str.charAt(0)));
    else/*w  ww . ja  va2  s.c  om*/
        buf.append(Character.toLowerCase(str.charAt(0)));
    buf.append(str.substring(1));
    return buf.toString();
}

From source file:org.eclipse.wb.android.internal.support.IdSupport.java

/**
 * Given a UI root node, returns the first available id that matches the pattern "prefix%d".
 * /*from w  w  w  .  j  a  v  a2s  .c om*/
 * For recursion purposes, a "context" is given. Since Java doesn't have in-out parameters in
 * methods and we're not going to do a dedicated type, we just use an object array which must
 * contain one initial item and several are built on the fly just for internal storage:
 * <ul>
 * <li>prefix(String): The prefix of the generated id, i.e. "widget". Cannot be null.
 * <li>index(Integer): The minimum index of the generated id. Must start with null.
 * <li>generated(String): The generated widget currently being searched. Must start with null.
 * <li>map(Set<String>): A set of the ids collected so far when walking through the widget
 * hierarchy. Must start with null.
 * </ul>
 * 
 * @param rootElement
 *          The Ui root node where to start searching recursively. For the initial call you want
 *          to pass the document root.
 * @param params
 *          An in-out context of parameters used during recursion, as explained above.
 * @return A suitable generated id
 */
@SuppressWarnings("unchecked")
private static String getFreeWidgetId(DocumentElement rootElement, Object[] params) {
    Set<String> map = (Set<String>) params[3];
    if (map == null) {
        params[3] = map = new HashSet<String>();
    }
    int num = params[1] == null ? 0 : ((Integer) params[1]).intValue();
    String generated = (String) params[2];
    String prefix = (String) params[0];
    if (generated == null) {
        int pos = prefix.indexOf('.');
        if (pos >= 0) {
            prefix = prefix.substring(pos + 1);
        }
        pos = prefix.indexOf('$');
        if (pos >= 0) {
            prefix = prefix.substring(pos + 1);
        }
        prefix = prefix.replaceAll("[^a-zA-Z]", ""); //$NON-NLS-1$ $NON-NLS-2$
        if (prefix.length() == 0) {
            prefix = DEFAULT_WIDGET_PREFIX;
        } else {
            // Lowercase initial character
            prefix = Character.toLowerCase(prefix.charAt(0)) + prefix.substring(1);
        }
        do {
            num++;
            generated = String.format("%1$s%2$d", prefix, num); //$NON-NLS-1$
        } while (map.contains(generated.toLowerCase()));
        params[0] = prefix;
        params[1] = num;
        params[2] = generated;
    }
    String id = rootElement.getAttribute("android:" + ATTR_ID);
    if (id != null) {
        id = id.replace(NEW_ID_PREFIX, ""); //$NON-NLS-1$
        id = id.replace(ID_PREFIX, ""); //$NON-NLS-1$
        if (map.add(id.toLowerCase()) && map.contains(generated.toLowerCase())) {
            do {
                num++;
                generated = String.format("%1$s%2$d", prefix, num); //$NON-NLS-1$
            } while (map.contains(generated.toLowerCase()));
            params[1] = num;
            params[2] = generated;
        }
    }
    for (DocumentElement child : rootElement.getChildren()) {
        getFreeWidgetId(child, params);
    }
    // Note: return params[2] (not "generated") since it could have changed during recursion.
    return (String) params[2];
}

From source file:io.github.prison.util.ChatColor.java

/**
 * Translates a string using an alternate color code character into a
 * string that uses the internal ChatColor.COLOR_CODE color code
 * character. The alternate color code character will only be replaced if
 * it is immediately followed by 0-9, A-F, a-f, K-O, k-o, R or r.
 *
 * @param altColorChar    The alternate color code character to replace. Ex: {@literal &}
 * @param textToTranslate Text containing the alternate color code character.
 * @return Text containing the ChatColor.COLOR_CODE color code character.
 *//*from   w w w.  ja  va  2  s .c om*/
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) {
    char[] b = textToTranslate.toCharArray();
    for (int i = 0; i < b.length - 1; i++) {
        if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) {
            b[i] = ChatColor.COLOR_CHAR;
            b[i + 1] = Character.toLowerCase(b[i + 1]);
        }
    }
    return new String(b);
}

From source file:datavis.Gui.java

private void updateGraphs_lineGraph(DataList dataset, boolean load) {
    String sItem = "default";
    if (load) {/*from   w w  w.j  a va 2s. c om*/
        sItem = "default";
    } else {
        sItem = jComboBox3.getSelectedItem().toString();
    }

    sItem = sItem.replaceAll("\\s+", "");
    sItem = Character.toLowerCase(sItem.charAt(0)) + (sItem.length() > 1 ? sItem.substring(1) : "");

    jPanel3.removeAll();
    jPanel3.revalidate();

    JFreeChart chart = dataset.getBarGraphChart(sItem);
    chart.removeLegend();
    javax.swing.JPanel chartPanel = new ChartPanel(chart);
    chartPanel.setSize(jPanel3.getSize());

    jPanel3.add(chartPanel);
    jPanel3.repaint();
}

From source file:com.stimulus.archiva.language.NGramProfile.java

/**
 * Analyze a piece of text/*from w  w  w  .ja va2s .c  o  m*/
 * 
 * @param text the text to be analyzed
 */
public void analyze(StringBuffer text) {

    if (ngrams != null) {
        ngrams.clear();
        sorted = null;
        ngramcounts = null;
    }

    word.clear().append(SEPARATOR);
    for (int i = 0; i < text.length(); i++) {
        char c = Character.toLowerCase(text.charAt(i));

        if (Character.isLetter(c)) {
            add(word.append(c));
        } else {
            //found word boundary
            if (word.length() > 1) {
                //we have a word!
                add(word.append(SEPARATOR));
                word.clear().append(SEPARATOR);
            }
        }
    }

    if (word.length() > 1) {
        //we have a word!
        add(word.append(SEPARATOR));
    }
    normalize();
}

From source file:net.metanotion.json.StreamingParser.java

private Lexeme maybeNumber(final Reader in, int firstChar) throws IOException {
    // this might be a number, if it is, lex it and return the token, otherwise throw an exception.
    final String integer = lexInt(in, firstChar);
    in.mark(MAX_BUFFER);//from   w ww  .  ja  v a  2  s. c  o m
    final int c = in.read();
    if (c == '.') {
        final String decimal = integer + lexFraction(in);
        return new Lexeme(Token.FLOAT, Double.valueOf(decimal));
    } else if (Character.toLowerCase(c) == 'e') {
        in.reset();
        final String decimal = integer + lexExp(in);
        return new Lexeme(Token.FLOAT, Double.valueOf(decimal));
    } else {
        in.reset();
        return new Lexeme(Token.INT, Long.valueOf(integer));
    }
}

From source file:com.flipkart.polyguice.dropwiz.DropConfigProvider.java

private String getNameFromMethod(Method method) {
    if (method.getParameterCount() > 0) {
        return null;
    }// w w w.ja v a  2 s .c  om
    if (method.getReturnType().equals(Void.TYPE)) {
        return null;
    }

    String mthdName = method.getName();
    if (mthdName.startsWith("get")) {
        if (mthdName.length() <= 3) {
            return null;
        }
        if (method.getReturnType().equals(Boolean.class) || method.getReturnType().equals(Boolean.TYPE)) {
            return null;
        }
        StringBuffer buffer = new StringBuffer(StringUtils.removeStart(mthdName, "get"));
        buffer.setCharAt(0, Character.toLowerCase(buffer.charAt(0)));
        return buffer.toString();
    } else if (!mthdName.startsWith("is")) {
        if (mthdName.length() <= 2) {
            return null;
        }
        if (!method.getReturnType().equals(Boolean.class) && !method.getReturnType().equals(Boolean.TYPE)) {
            return null;
        }
        StringBuffer buffer = new StringBuffer(StringUtils.removeStart(mthdName, "is"));
        buffer.setCharAt(0, Character.toLowerCase(buffer.charAt(0)));
        return buffer.toString();
    }
    return null;
}

From source file:io.stallion.reflection.PropertyUtils.java

/**
 * Build a map of direct javabeans properties of the target object. Only read/write properties (ie: those who have
 * both a getter and a setter) are returned.
 * @param target the target object from which to get properties names.
 * @return a Map of String with properties names as key and their values
 * @throws PropertyException if an error happened while trying to get a property.
 *///from w w w  .j  a  v  a 2s . c  o m
public static Map<String, Object> getProperties(Object target,
        Class<? extends Annotation>... excludeAnnotations) throws PropertyException {
    Map<String, Object> properties = new HashMap<String, Object>();
    Class clazz = target.getClass();
    Method[] methods = clazz.getMethods();
    for (int i = 0; i < methods.length; i++) {
        Method method = methods[i];
        String name = method.getName();
        Boolean hasExcludeAnno = false;
        if (excludeAnnotations.length > 0) {
            for (Class<? extends Annotation> anno : excludeAnnotations) {
                if (method.isAnnotationPresent(anno)) {
                    hasExcludeAnno = true;
                }
            }
        }
        if (hasExcludeAnno) {
            continue;
        }
        if (method.getModifiers() == Modifier.PUBLIC && method.getParameterTypes().length == 0
                && (name.startsWith("get") || name.startsWith("is"))
                && containsSetterForGetter(clazz, method)) {
            String propertyName;
            if (name.startsWith("get"))
                propertyName = Character.toLowerCase(name.charAt(3)) + name.substring(4);
            else if (name.startsWith("is"))
                propertyName = Character.toLowerCase(name.charAt(2)) + name.substring(3);
            else
                throw new PropertyException(
                        "method '" + name + "' is not a getter, thereof no setter can be found");

            try {
                Object propertyValue = method.invoke(target, (Object[]) null); // casting to (Object[]) b/c of javac 1.5 warning
                if (propertyValue != null && propertyValue instanceof Properties) {
                    Map propertiesContent = getNestedProperties(propertyName, (Properties) propertyValue);
                    properties.putAll(propertiesContent);
                } else {
                    properties.put(propertyName, propertyValue);
                }
            } catch (IllegalAccessException ex) {
                throw new PropertyException("cannot set property '" + propertyName + "' - '" + name
                        + "' is null and cannot be auto-filled", ex);
            } catch (InvocationTargetException ex) {
                throw new PropertyException("cannot set property '" + propertyName + "' - '" + name
                        + "' is null and cannot be auto-filled", ex);
            }

        } // if
    } // for

    return properties;
}