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:com.xie.javacase.json.XMLTokener.java

/**
 * Return the next entity. These entities are translated to Characters:
 *     <code>&amp;  &apos;  &gt;  &lt;  &quot;</code>.
 * @param a An ampersand character./*  w  ww  .ja  v a  2 s  . c o m*/
 * @return  A Character or an entity String if the entity is not recognized.
 * @throws org.json.JSONException If missing ';' in XML entity.
 */
public Object nextEntity(char a) throws JSONException {
    StringBuffer sb = new StringBuffer();
    for (;;) {
        char c = next();
        if (Character.isLetterOrDigit(c) || c == '#') {
            sb.append(Character.toLowerCase(c));
        } else if (c == ';') {
            break;
        } else {
            throw syntaxError("Missing ';' in XML entity: &" + sb);
        }
    }
    String s = sb.toString();
    Object e = entity.get(s);
    return e != null ? e : a + s + ";";
}

From source file:com.android.dialer.omni.clients.OsmApi.java

/**
 * Fetches and returns a list of named Places around the provided latitude and
 * longitude parameters. The bounding box is calculated from lat-distance, lon-distance
 * to lat+distance, lon+distance./* www. j  a  v  a 2 s .c o m*/
 * This method is NOT asynchronous. Run it in a thread.
 *
 * @param name Name to search
 * @param lat Latitude of the point to search around
 * @param lon Longitude of the point to search around
 * @param distance Max distance (polar coordinates)
 * @return the list of matching places
 */
@Override
public List<Place> getNamedPlacesAround(String name, double lat, double lon, double distance) {
    List<Place> places;

    if (DEBUG)
        Log.d(TAG, "Getting places named " + name);

    double latStart = lat - distance / 2.0;
    double latEnd = lat + distance / 2.0;
    double lonStart = lon - distance / 2.0;
    double lonEnd = lon + distance / 2.0;

    // The OSM API doesn't support case-insentive searches, but does support RegEx. So
    // we hack around a bit.
    String finalName = "";
    for (int i = 0; i < name.length(); i++) {
        char c = name.charAt(i);
        finalName = finalName + "[" + Character.toUpperCase(c) + Character.toLowerCase(c) + "]";
    }

    // Build request data
    String request = "[out:json];node[\"name\"~\"" + finalName + "\"][\"phone\"]" + "(" + latStart + ","
            + lonStart + "," + latEnd + "," + lonEnd + ");out body;";

    try {
        places = getPlaces(request);
    } catch (Exception e) {
        Log.e(TAG, "Unable to get named places around", e);
        places = new ArrayList<Place>();
    }

    if (DEBUG)
        Log.d(TAG, "Returning " + places.size() + " places");

    return places;
}

From source file:com.khubla.simpleioc.impl.DefaultIOCBeanRegistry.java

/**
 * scan the packages for annotated registry objects. this adds bean definitions for each bean found.
 *//*from   w  w  w  .  j a  v  a 2  s.c  o  m*/
private void scanPackages() throws IOCException {
    try {
        /*
         * global beans (collect them up)
         */
        ArrayList<Bean> globalBeans = new ArrayList<Bean>();
        /*
         * message
         */
        final List<Class<?>> beanClasses = ClassLibrary.getInstance().getClasses();
        for (final Class<?> cls : beanClasses) {
            final RegistryBean registryBeanAnnotation = cls.getAnnotation(RegistryBean.class);
            if (null != registryBeanAnnotation) {
                /*
                 * bean name
                 */
                String beanName = registryBeanAnnotation.name();
                if (beanName.length() == 0) {
                    /*
                     * use the class name
                     */
                    beanName = cls.getSimpleName();
                    beanName = Character.toLowerCase(beanName.charAt(0)) + beanName.substring(1);
                }
                /*
                 * iterate the profiles
                 */
                for (final String profileName : registryBeanAnnotation.profiles()) {
                    /*
                     * check if we already have a bean with that name
                     */
                    Profile profile = profiles.get(profileName);
                    if ((null != profile) && (profile.hasBeanDefinition(beanName))) {
                        /*
                         * log a message
                         */
                        log.info("Cannot add bean of type '" + cls.getName() + "'.  Bean with name '" + beanName
                                + "' already exists and is of type '"
                                + profile.getBeanDefinition(beanName).getClassName() + "'");
                        /*
                         * explode
                         */
                        throw new IOCException("Cannot add bean of type '" + cls.getName()
                                + "'.  Bean with name '" + beanName + "' already exists and is of type '"
                                + profile.getBeanDefinition(beanName).getClassName() + "'");
                    } else {
                        /*
                         * log
                         */
                        log.info("adding bean definition '" + cls.getName() + "' with name '" + beanName
                                + "' to profile '" + profileName + "'");
                        /*
                         * add it
                         */
                        final Bean bean = new Bean();
                        bean.setClazz(cls);
                        bean.setClassName(cls.getName());
                        bean.setName(beanName);
                        bean.setProfile(profileName);
                        bean.setAutocreate(registryBeanAnnotation.autocreate());
                        bean.setCache(registryBeanAnnotation.cached());
                        bean.setThreadlocal(registryBeanAnnotation.threadlocal());
                        bean.setGlobal(registryBeanAnnotation.global());
                        if (null == profile) {
                            profile = new Profile(profileName);
                            profiles.put(profileName, profile);
                        }
                        profile.addBeanDefinition(bean);
                        if (bean.isGlobal()) {
                            globalBeans.add(bean);
                        }
                    }
                }
            }
        }
        /*
         * add the global beans to all profiles
         */
        for (Bean bean : globalBeans) {
            for (Profile profile : this.profiles.values()) {
                if (false == profile.hasBeanDefinition(bean.getName())) {
                    profile.addBeanDefinition(bean);
                }
            }
        }
        /*
         * filters
         */
        for (final Class<?> cls : beanClasses) {
            final RegistryFilter registryFilterAnnotation = cls.getAnnotation(RegistryFilter.class);
            if (null != registryFilterAnnotation) {
                /*
                 * create
                 */
                final IOCInstantiationFilter iocInstantiationFilter = (IOCInstantiationFilter) ConstructorUtils
                        .invokeConstructor(cls, null);
                /*
                 * iterate the profiles
                 */
                for (final String profileName : registryFilterAnnotation.profiles()) {
                    /*
                     * log
                     */
                    log.info("adding filter '" + cls.getName() + "' to profile '" + profileName + "'");
                    /*
                     * add it
                     */
                    Profile profile = profiles.get(profileName);
                    if (null == profile) {
                        profile = new Profile(profileName);
                        profiles.put(profileName, profile);
                    }
                    profile.addFilter(iocInstantiationFilter);
                }
            }
        }
    } catch (final Exception e) {
        throw new IOCException("Exception in scanPackage", e);
    }
}

From source file:org.debux.webmotion.server.tools.ReflectionUtils.java

/**
 * Uncapitalizes a full qualified class name.
 * Example://from www  .ja  v  a  2s  .  c om
 * <code>WebMotionUtils.unCapitalizeClass("org.webmotion.Myclass")</code> will return 
 * <code>"org.webmotion.myclass"</code>
 * @param className The class name to uncapitalize.
 * @return A uncapitalized representation for the given <code>className</code> class name.
 */
public static String unCapitalizeClass(String className) {
    StringBuilder builder = new StringBuilder(className.length());

    // Search the class name in package
    int packageIndex = className.lastIndexOf(".");
    if (packageIndex != -1) {
        builder.append(className.substring(0, packageIndex + 1));
    }

    builder.append(Character.toLowerCase(className.charAt(packageIndex + 1)));
    builder.append(className.substring(packageIndex + 2));

    className = builder.toString();
    return className;
}

From source file:com.redhat.rhn.common.util.StringUtil.java

/**
 * Convert the passed in bean style string to a underscore separated string.
 *
 * For example: someFieldName -> some_field_name
 *
 * @param strIn The string to convert//w  w  w  . j a va  2 s .c  o  m
 * @return The converted string
 */
public static String debeanify(String strIn) {
    String str = strIn.trim();
    StringBuilder result = new StringBuilder(str.length());

    for (int i = 0; i < str.length(); i++) {
        char c = str.charAt(i);
        if (Character.isUpperCase(c)) {
            result.append("_");
        }
        result.append(Character.toLowerCase(c));
    }
    return result.toString();
}

From source file:com.haulmont.cuba.desktop.sys.vcl.DatePicker.DatePicker.java

protected String getMask(String format) {
    StringBuilder mask = new StringBuilder(format);
    for (int i = 0; i < mask.length(); i++) {
        char current = mask.charAt(i);
        current = Character.toLowerCase(current);
        if (current == 'd' || current == 'm' || current == 'y') {
            mask.setCharAt(i, PLACE_HOLDER);
        }/*from   w  w w  . j  av  a  2 s  .  co m*/
    }
    return mask.toString();
}

From source file:MD5.java

private static int intFromChar(char c) {
    char clower = Character.toLowerCase(c);
    for (int i = 0; i < carr.length; i++) {
        if (clower == carr[i]) {
            return i;
        }//from   www . j ava2  s. co  m
    }

    return 0;
}

From source file:org.diorite.chat.ChatColor.java

public static String removeColorCodesInString(final char altColorChar, final String textToTranslate) {
    final char[] b = textToTranslate.toCharArray();
    for (int i = 0; i < (b.length - 1); i++) {
        if ((b[i] == COLOR_CHAR) && ("0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[(i + 1)]) > -1)) {
            b[i] = altColorChar;//from ww w.  j a v  a 2 s .c  o m
            b[(i + 1)] = Character.toLowerCase(b[(i + 1)]);
        }
    }
    return new String(b);
}

From source file:datavis.Gui.java

private void updateGraphs_barGraph(DataList dataset, boolean load) {
    String sItem = "default";

    if (load) {/*  w w  w . j  a  v  a  2s  . c  o  m*/
        sItem = "default";
    } else {
        sItem = jComboBox2.getSelectedItem().toString();
    }

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

    jPanel2.removeAll();
    jPanel2.revalidate();
    JFreeChart chart = dataset.getLineGraphChart(sItem);
    chart.removeLegend();
    javax.swing.JPanel chartPanel = new ChartPanel(chart);
    chartPanel.setSize(jPanel2.getSize());

    jPanel2.add(chartPanel);
    jPanel2.repaint();

}

From source file:org.cgiar.ccafs.marlo.utils.Clone.java

public static String miniscula(String nome) {
    char c[] = nome.toCharArray();
    c[0] = Character.toLowerCase(c[0]);
    nome = new String(c);
    return nome;/*from   w w w  . j a  va2  s.c  o m*/
}