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:datavis.Gui.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

    //Initialize a copy of the current Pie chart on display and then create a pop-up containing it

    //Get the chart based on the Combobox item
    String sItem = jComboBox1.getSelectedItem().toString();
    sItem = sItem.replaceAll("\\s+", "");
    sItem = Character.toLowerCase(sItem.charAt(0)) + (sItem.length() > 1 ? sItem.substring(1) : "");

    JFreeChart popOut_PieChart = dataset.getPieChartChart(sItem);

    //Create the pop-up
    ChartFrame frame = new ChartFrame(dataset.getStationName() + "  (" + dataset.getStationID() + ")",
            popOut_PieChart);/*w ww  . j av  a2 s .  c o  m*/
    frame.setVisible(true);
    frame.setSize(450, 450);

}

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

public static String normalize(final String text) {
    final StringBuilder l = new StringBuilder();
    for (int i = 0; i < text.length(); i++) {
        final char c = text.charAt(i);
        if (Character.isLetterOrDigit(c)) {
            l.append(Character.toLowerCase(c));
        } else {/*from   w w w  . j  a  v  a  2  s  . c o  m*/
            if (l.length() > 0 && l.charAt(l.length() - 1) != ' ')
                l.append(' ');
        }
    }
    if (l.length() > 0 && l.charAt(l.length() - 1) == ' ')
        l.setLength(l.length() - 1);
    return l.toString();
}

From source file:net.bioclipse.ds.sdk.pdewizard.DSTemplate.java

protected String getFormattedPackageName(String id) {
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < id.length(); i++) {
        char ch = id.charAt(i);
        if (buffer.length() == 0) {
            if (Character.isJavaIdentifierStart(ch))
                buffer.append(Character.toLowerCase(ch));
        } else {/*  www .j  av  a 2  s  .c om*/
            if (Character.isJavaIdentifierPart(ch) || ch == '.')
                buffer.append(ch);
        }
    }
    return buffer.toString().toLowerCase(Locale.ENGLISH);
}

From source file:net.jawr.web.resource.bundle.factory.util.PathNormalizer.java

/**
 * This method can calculate the relative path between two pathes on a file
 * system. <br/>/*from  w  ww  .  ja  v a 2s.  c  o m*/
 * 
 * <pre>
 * PathUtils.getRelativeFilePath( null, null )                                   = ""
 * PathUtils.getRelativeFilePath( null, "/usr/local/java/bin" )                  = ""
 * PathUtils.getRelativeFilePath( "/usr/local", null )                           = ""
 * PathUtils.getRelativeFilePath( "/usr/local", "/usr/local/java/bin" )          = "java/bin"
 * PathUtils.getRelativeFilePath( "/usr/local", "/usr/local/java/bin/" )         = "java/bin"
 * PathUtils.getRelativeFilePath( "/usr/local/java/bin", "/usr/local/" )         = "../.."
 * PathUtils.getRelativeFilePath( "/usr/local/", "/usr/local/java/bin/java.sh" ) = "java/bin/java.sh"
 * PathUtils.getRelativeFilePath( "/usr/local/java/bin/java.sh", "/usr/local/" ) = "../../.."
 * PathUtils.getRelativeFilePath( "/usr/local/", "/bin" )                        = "../../bin"
 * PathUtils.getRelativeFilePath( "/bin", "/usr/local/" )                        = "../usr/local"
 * </pre>
 * 
 * Note: On Windows based system, the <code>/</code> character should be
 * replaced by <code>\</code> character.
 * 
 * @param oldPath
 * @param newPath
 * @return a relative file path from <code>oldPath</code>.
 */
public static final String getRelativeFilePath(final String oldPath, final String newPath) {
    if (StringUtils.isEmpty(oldPath) || StringUtils.isEmpty(newPath)) {
        return "";
    }

    // normalise the path delimiters
    String fromPath = new File(oldPath).getPath();
    String toPath = new File(newPath).getPath();

    // strip any leading slashes if its a windows path
    if (toPath.matches("^\\[a-zA-Z]:")) {
        toPath = toPath.substring(1);
    }
    if (fromPath.matches("^\\[a-zA-Z]:")) {
        fromPath = fromPath.substring(1);
    }

    // lowercase windows drive letters.
    if (fromPath.startsWith(":", 1)) {
        fromPath = Character.toLowerCase(fromPath.charAt(0)) + fromPath.substring(1);
    }
    if (toPath.startsWith(":", 1)) {
        toPath = Character.toLowerCase(toPath.charAt(0)) + toPath.substring(1);
    }

    // check for the presence of windows drives. No relative way of
    // traversing from one to the other.
    if ((toPath.startsWith(":", 1) && fromPath.startsWith(":", 1))
            && (!toPath.substring(0, 1).equals(fromPath.substring(0, 1)))) {
        // they both have drive path element but they dont match, no
        // relative path
        return null;
    }

    if ((toPath.startsWith(":", 1) && !fromPath.startsWith(":", 1))
            || (!toPath.startsWith(":", 1) && fromPath.startsWith(":", 1))) {
        // one has a drive path element and the other doesnt, no relative
        // path.
        return null;
    }

    String resultPath = buildRelativePath(toPath, fromPath, File.separatorChar);

    if (newPath.endsWith(File.separator) && !resultPath.endsWith(File.separator)) {
        return resultPath + File.separator;
    }

    return resultPath;
}

From source file:org.ballerinalang.net.http.HttpUtil.java

private static String lowerCaseTheFirstLetter(String payload) {
    if (!payload.isEmpty()) {
        char[] characters = payload.toCharArray();
        characters[0] = Character.toLowerCase(characters[0]);
        payload = new String(characters);
    }//from  ww  w . j  a v  a 2s  .  co m
    return payload;
}

From source file:datavis.Gui.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

    //Initialize a copy of the current Line chart on display and then create a pop-up containing it

    //Get the chart based on the Combobox item
    String sItem = jComboBox2.getSelectedItem().toString();
    sItem = sItem.replaceAll("\\s+", "");
    sItem = Character.toLowerCase(sItem.charAt(0)) + (sItem.length() > 1 ? sItem.substring(1) : "");

    //Create the pop-up
    JFreeChart popOut_PieChart = dataset.getLineGraphChart(sItem);
    ChartFrame frame = new ChartFrame(dataset.getStationName() + "  (" + dataset.getStationID() + ")",
            popOut_PieChart);//from w  w w .  j  av  a 2s . c o m
    frame.setVisible(true);
    frame.setSize(450, 450);

}

From source file:nl.strohalm.cyclos.dao.accounts.AccountDAOImpl.java

@Override
public Iterator<MemberTransactionDetailsReportData> membersTransactionsDetailsReport(
        final MembersTransactionsReportParameters params) {
    final StringBuilder sql = new StringBuilder();
    final Map<String, Object> parameters = new HashMap<String, Object>();

    // Find the transfer types ids
    Set<Long> ttIds = null;
    if (CollectionUtils.isNotEmpty(params.getPaymentFilters())) {
        ttIds = new HashSet<Long>();
        for (PaymentFilter pf : params.getPaymentFilters()) {
            pf = getFetchDao().fetch(pf, PaymentFilter.Relationships.TRANSFER_TYPES);
            final Long[] ids = EntityHelper.toIds(pf.getTransferTypes());
            CollectionUtils.addAll(ttIds, ids);
        }//ww w . j av  a  2s  .  c  om
    }

    // Get the member group ids
    Set<Long> groupIds = null;
    if (CollectionUtils.isNotEmpty(params.getMemberGroups())) {
        groupIds = new HashSet<Long>();
        CollectionUtils.addAll(groupIds, EntityHelper.toIds(params.getMemberGroups()));
    }

    // Get the period
    final Period period = params.getPeriod();
    final QueryParameter beginParameter = HibernateHelper.getBeginParameter(period);
    final QueryParameter endParameter = HibernateHelper.getEndParameter(period);

    // Set the parameters
    final boolean useTT = CollectionUtils.isNotEmpty(ttIds);
    if (useTT) {
        parameters.put("ttIds", ttIds);
    }
    if (beginParameter != null) {
        parameters.put("beginDate", beginParameter.getValue());
    }
    if (endParameter != null) {
        parameters.put("endDate", endParameter.getValue());
    }
    parameters.put("processed", Payment.Status.PROCESSED.getValue());

    // Build the sql string
    sql.append(
            " select u.username, m.name, bu.username broker_username, b.name broker_name, h.account_type_name, h.date, h.amount, h.description, h.related_username, h.related_name, h.transfer_type_name, h.transaction_number");
    sql.append(
            " from members m inner join users u on m.id = u.id left join members b on m.member_broker_id = b.id left join users bu on b.id = bu.id,");
    sql.append(" (");
    if (params.isCredits()) {
        appendMembersTransactionsDetailsReportSqlPart(sql, useTT, beginParameter, endParameter, true, true);
        sql.append(" union");
        appendMembersTransactionsDetailsReportSqlPart(sql, useTT, beginParameter, endParameter, true, false);
        if (params.isDebits()) {
            sql.append(" union");
        }
    }
    if (params.isDebits()) {
        appendMembersTransactionsDetailsReportSqlPart(sql, useTT, beginParameter, endParameter, false, true);
        sql.append(" union");
        appendMembersTransactionsDetailsReportSqlPart(sql, useTT, beginParameter, endParameter, false, false);
    }
    sql.append(" ) h");
    sql.append(" where m.id = h.member_id");
    if (groupIds != null) {
        parameters.put("groupIds", groupIds);
        sql.append(" and m.group_id in (:groupIds)");
    }
    sql.append(" order by m.name, u.username, h.account_type_name, h.date desc, h.transfer_id desc");

    // Prepare the query
    final SQLQuery query = getSession().createSQLQuery(sql.toString());
    final Map<String, Type> columns = new LinkedHashMap<String, Type>();
    columns.put("username", StandardBasicTypes.STRING);
    columns.put("name", StandardBasicTypes.STRING);
    columns.put("broker_username", StandardBasicTypes.STRING);
    columns.put("broker_name", StandardBasicTypes.STRING);
    columns.put("account_type_name", StandardBasicTypes.STRING);
    columns.put("date", StandardBasicTypes.CALENDAR);
    columns.put("amount", StandardBasicTypes.BIG_DECIMAL);
    columns.put("description", StandardBasicTypes.STRING);
    columns.put("related_username", StandardBasicTypes.STRING);
    columns.put("related_name", StandardBasicTypes.STRING);
    columns.put("transfer_type_name", StandardBasicTypes.STRING);
    columns.put("transaction_number", StandardBasicTypes.STRING);
    for (final Map.Entry<String, Type> entry : columns.entrySet()) {
        query.addScalar(entry.getKey(), entry.getValue());
    }
    getHibernateQueryHandler().setQueryParameters(query, parameters);

    // Create a transformer, which will read rows as Object[] and transform them to MemberTransactionDetailsReportData
    final Transformer<Object[], MemberTransactionDetailsReportData> transformer = new Transformer<Object[], MemberTransactionDetailsReportData>() {
        @Override
        public MemberTransactionDetailsReportData transform(final Object[] input) {
            final MemberTransactionDetailsReportData data = new MemberTransactionDetailsReportData();
            int i = 0;
            for (final Map.Entry<String, Type> entry : columns.entrySet()) {
                final String columnName = entry.getKey();
                // Column names are transfer_type_name, property is transferTypeName
                String propertyName = WordUtils.capitalize(columnName, COLUMN_DELIMITERS);
                propertyName = Character.toLowerCase(propertyName.charAt(0)) + propertyName.substring(1);
                propertyName = StringUtils.replace(propertyName, "_", "");
                PropertyHelper.set(data, propertyName, input[i]);
                i++;
            }
            return data;
        }
    };

    return new ScrollableResultsIterator<MemberTransactionDetailsReportData>(query, transformer);
}

From source file:org.codehaus.groovy.grails.web.pages.GroovyPageParser.java

private static boolean match(CharSequence pat, CharSequence text, int start) {
    int ix = start, ixz = text.length(), ixy = start + pat.length();
    if (ixz > ixy) {
        ixz = ixy;/*from w w  w  .j a v  a2s  .c  om*/
    }
    if (pat.length() > ixz - start) {
        return false;
    }

    for (; ix < ixz; ix++) {
        if (Character.toLowerCase(text.charAt(ix)) != Character.toLowerCase(pat.charAt(ix - start))) {
            return false;
        }
    }
    return true;
}

From source file:datavis.Gui.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

    //Initialize a copy of the current Bar chart on display and then create a pop-up containing it

    //Get the chart based on the Combobox item

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

    //Create the pop-up
    JFreeChart popOut_PieChart = dataset.getBarGraphChart(sItem);
    ChartFrame frame = new ChartFrame(dataset.getStationName() + "  (" + dataset.getStationID() + ")",
            popOut_PieChart);//from w  w  w  . j  a va  2s .c  o m
    frame.setVisible(true);
    frame.setSize(450, 450);

}

From source file:lucee.commons.lang.StringUtil.java

public static int indexOfIgnoreCase(String haystack, String needle) {
    if (StringUtil.isEmpty(haystack) || StringUtil.isEmpty(needle))
        return -1;
    needle = needle.toLowerCase();//from  ww w. j  a va2 s . c  om

    int lenHaystack = haystack.length();
    int lenNeedle = needle.length();

    char lastNeedle = needle.charAt(lenNeedle - 1);
    char c;
    outer: for (int i = lenNeedle - 1; i < lenHaystack; i++) {
        c = Character.toLowerCase(haystack.charAt(i));
        if (c == lastNeedle) {
            for (int y = 0; y < lenNeedle - 1; y++) {
                if (needle.charAt(y) != Character.toLowerCase(haystack.charAt(i - (lenNeedle - 1) + y)))
                    continue outer;
            }
            return i - (lenNeedle - 1);
        }
    }

    return -1;
}