Example usage for java.lang String compareToIgnoreCase

List of usage examples for java.lang String compareToIgnoreCase

Introduction

In this page you can find the example usage for java.lang String compareToIgnoreCase.

Prototype

public int compareToIgnoreCase(String str) 

Source Link

Document

Compares two strings lexicographically, ignoring case differences.

Usage

From source file:org.kalypso.afgui.internal.handlers.ScenarioData.java

/**
 * Returns names of all sub scenarios that already exist. The names cannot be used for a new scenario.
 *//*ww w  . j av  a 2 s.  c o m*/
public Set<String> getExistingNames() {
    final Comparator<String> ignoreCaseComparator = new Comparator<String>() {
        @Override
        public int compare(final String o1, final String o2) {
            return o1.compareToIgnoreCase(o2);
        }
    };

    final Set<String> names = new TreeSet<>(ignoreCaseComparator);

    final IScenarioList derivedScenarios = m_parentScenario.getDerivedScenarios();

    final List<IScenario> scenarios = derivedScenarios.getScenarios();
    for (final IScenario scenario : scenarios)
        names.add(scenario.getName());

    return Collections.unmodifiableSet(names);
}

From source file:org.rdkit.knime.wizards.RDKitNodesWizardsPage.java

/**
 * Determines for a sorted list and an object, what index the string
 * could be inserted. Note: This method just returns the index, but does not
 * insert the string./*from www . j a v a 2  s  . c o  m*/
 *
 * @param listSorted
 *            Sorted string list. Can be <code>null</code>.
 * @param item
 *            String to be inserted. Can be <code>null</code>.
 *
 * @return Index for string insertion.
 */
private static int getIndexForSortedInsert(final List<String> listSorted, final String item) {
    if (listSorted == null || item == null) {
        return 0;
    }

    int low = 0;
    int high = listSorted.size() - 1;

    while (low <= high) {
        int mid = (low + high) >>> 1;
        String midVal = listSorted.get(mid);
        int cmp = midVal.compareToIgnoreCase(item);

        if (cmp < 0) {
            low = mid + 1;
        } else if (cmp > 0) {
            high = mid - 1;
        } else {
            return mid; // key found
        }
    }

    return low; // key not found.
}

From source file:org.voltdb.compilereport.ReportMaker.java

/**
 * Get some embeddable HTML of some generic catalog/application stats
 * that is drawn on the first page of the report.
 *//*from   w w w  .j  a v  a  2  s  .co  m*/
static String getStatsHTML(Database db, ArrayList<Feedback> warnings) {
    StringBuilder sb = new StringBuilder();
    sb.append("<table class='table table-condensed'>\n");

    // count things
    int indexes = 0, views = 0, statements = 0;
    int partitionedTables = 0, replicatedTables = 0;
    int partitionedProcs = 0, replicatedProcs = 0;
    int readProcs = 0, writeProcs = 0;
    for (Table t : db.getTables()) {
        if (t.getMaterializer() != null) {
            views++;
        } else {
            if (t.getIsreplicated()) {
                replicatedTables++;
            } else {
                partitionedTables++;
            }
        }

        indexes += t.getIndexes().size();
    }
    for (Procedure p : db.getProcedures()) {
        // skip auto-generated crud procs
        if (p.getDefaultproc()) {
            continue;
        }

        if (p.getSinglepartition()) {
            partitionedProcs++;
        } else {
            replicatedProcs++;
        }

        if (p.getReadonly()) {
            readProcs++;
        } else {
            writeProcs++;
        }

        statements += p.getStatements().size();
    }

    // version
    sb.append("<tr><td>Compiled by VoltDB Version</td><td>");
    sb.append(VoltDB.instance().getVersionString()).append("</td></tr>\n");

    // timestamp
    sb.append("<tr><td>Compiled on</td><td>");
    SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z");
    sb.append(sdf.format(m_timestamp)).append("</td></tr>\n");

    // tables
    sb.append("<tr><td>Table Count</td><td>");
    sb.append(String.format("%d (%d partitioned / %d replicated)", partitionedTables + replicatedTables,
            partitionedTables, replicatedTables));
    sb.append("</td></tr>\n");

    // views
    sb.append("<tr><td>Materialized View Count</td><td>").append(views).append("</td></tr>\n");

    // indexes
    sb.append("<tr><td>Index Count</td><td>").append(indexes).append("</td></tr>\n");

    // procedures
    sb.append("<tr><td>Procedure Count</td><td>");
    sb.append(String.format("%d (%d partitioned / %d replicated) (%d read-only / %d read-write)",
            partitionedProcs + replicatedProcs, partitionedProcs, replicatedProcs, readProcs, writeProcs));
    sb.append("</td></tr>\n");

    // statements
    sb.append("<tr><td>SQL Statement Count</td><td>").append(statements).append("</td></tr>\n");
    sb.append("</table>\n\n");

    // warnings, add warning section if any
    if (warnings.size() > 0) {
        sb.append("<h4>Warnings</h4>");
        sb.append("<table class='table table-condensed'>\n");
        for (Feedback warning : warnings) {
            String procName = warning.getFileName().replace(".class", "");
            String nameLink = "";
            // not a warning during compiling procedures, must from the schema
            if (procName.compareToIgnoreCase("null") == 0) {
                String schemaName = "";
                String warningMsg = warning.getMessage().toLowerCase();
                if (warningMsg.contains("table ")) {
                    int begin = warningMsg.indexOf("table ") + 6;
                    int end = (warningMsg.substring(begin)).indexOf(" ");
                    schemaName = warningMsg.substring(begin, begin + end);
                }
                nameLink = "<a href='#s-" + schemaName + "'>" + schemaName.toUpperCase() + "</a>";
            } else {
                nameLink = "<a href='#p-" + procName.toLowerCase() + "'>" + procName + "</a>";
            }
            sb.append("<tr><td>").append(nameLink).append("</td><td>").append(escapeHtml4(warning.getMessage()))
                    .append("</td></tr>\n");
        }
        sb.append("").append("</table>\n").append("</td></tr>\n");
    }

    return sb.toString();
}

From source file:psiprobe.controllers.datasources.ListAllJdbcResourceGroups.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    List<DataSourceInfoGroup> dataSourceGroups = new ArrayList<>();
    List<DataSourceInfo> dataSources = new ArrayList<>();

    List<ApplicationResource> privateResources = getContainerWrapper().getPrivateDataSources();
    List<ApplicationResource> globalResources = getContainerWrapper().getGlobalDataSources();

    // filter out anything that is not a datasource
    // and use only those datasources that are properly configured
    // as aggregated totals would not make any sense otherwise
    filterValidDataSources(privateResources, dataSources);
    filterValidDataSources(globalResources, dataSources);

    // sort datasources by JDBC URL
    Collections.sort(dataSources, new Comparator<DataSourceInfo>() {
        @Override/*  w ww. j  a  v a  2 s  .co  m*/
        public int compare(DataSourceInfo ds1, DataSourceInfo ds2) {
            String jdbcUrl1 = ds1.getJdbcUrl();
            String jdbcUrl2 = ds2.getJdbcUrl();

            // here we rely on the the filter not to add any datasources with a null jdbcUrl to the list

            return jdbcUrl1.compareToIgnoreCase(jdbcUrl2);
        }
    });

    // group datasources by JDBC URL and calculate aggregated totals
    DataSourceInfoGroup dsGroup = null;
    for (DataSourceInfo ds : dataSources) {
        if (dsGroup == null || !dsGroup.getJdbcUrl().equalsIgnoreCase(ds.getJdbcUrl())) {
            dsGroup = new DataSourceInfoGroup(ds);
            dataSourceGroups.add(dsGroup);
        } else {
            dsGroup.addDataSourceInfo(ds);
        }
    }

    return new ModelAndView(getViewName(), "dataSourceGroups", dataSourceGroups);
}

From source file:com.aliyun.datahub.flume.sink.DatahubSink.java

private OdpsEventSerializer createSerializer(String serializerType) {
    if (serializerType.compareToIgnoreCase(OdpsDelimitedTextSerializer.ALIAS) == 0
            || serializerType.compareTo(OdpsDelimitedTextSerializer.class.getName()) == 0) {
        return new OdpsDelimitedTextSerializer();
    } else if (serializerType.compareToIgnoreCase(OdpsRegexEventSerializer.ALIAS) == 0
            || serializerType.compareTo(OdpsRegexEventSerializer.class.getName()) == 0) {
        return new OdpsRegexEventSerializer();
    }/*from  ww w .ja v  a2s .  c  o  m*/

    try {
        return (OdpsEventSerializer) Class.forName(serializerType).newInstance();
    } catch (Exception e) {
        throw new IllegalArgumentException(
                "Unable to instantiate serializer: " + serializerType + " on sink: " + getName(), e);
    }
}

From source file:org.onesun.atomator.core.SubscriptionManager.java

private void processEntries(boolean persist) {
    logger.info("Listing subscripton information");

    for (String user : userSubscriptions.keySet()) {
        Subscriptions subscriptions = userSubscriptions.get(user);

        if (subscriptions != null) {
            for (String key : subscriptions.keySet()) {
                SubscriptionEntry entry = subscriptions.get(key);
                String action = entry.getAction();

                if (action.compareToIgnoreCase(AUTHORIZE) == 0) {
                    removeByIdentity(user, key);
                    action = SUBSCRIBE;/*from  w w  w.j av a 2 s . co m*/
                }

                if (action.compareToIgnoreCase(SUBSCRIBE) == 0) {
                    Channel channel = newSubscription(entry, persist);
                    subscriptions.add(channel);
                } else if (action.compareToIgnoreCase(UNSUBSCRIBE) == 0) {
                    removeByIdentity(user, key);
                }

                logger.info(key + " >>> " + entry);
            }
        }
    }
}

From source file:com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigurationTest.java

/**
 * Test of alphabetical order./*from   w ww  . j  av  a 2s.  c  o  m*/
 */
@Test
public void lexicographicOrder() {
    String lastClassName = null;
    for (final Class<?> c : JavaScriptConfiguration.CLASSES_) {
        final String name = c.getSimpleName();
        if (lastClassName != null && name.compareToIgnoreCase(lastClassName) < 0) {
            fail("JavaScriptConfiguration.CLASSES_: '" + name + "' should be before '" + lastClassName + "'");
        }
        lastClassName = name;
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.SubclassTemplateModel.java

@Override
public int compareTo(SubclassTemplateModel other) {

    if (other == null) {
        return -1;
    }/* ww w  . j  av  a  2s  .co m*/

    VClass vclassOther = other.getVClass();
    if (vclass == null) {
        return vclassOther == null ? 0 : 1;
    }
    if (vclassOther == null) {
        return -1;
    }

    int rank = vclass.getDisplayRank();
    int rankOther = vclassOther.getDisplayRank();

    int intCompare = 0;
    // Values < 1 are undefined and go at end, not beginning
    if (rank < 1) {
        intCompare = rankOther < 1 ? 0 : 1;
    } else if (rankOther < 1) {
        intCompare = -1;
    } else {
        intCompare = ((Integer) rank).compareTo(rankOther);
    }

    if (intCompare != 0) {
        return intCompare;
    }

    // If display ranks are equal, sort by name     
    String name = getName();
    String nameOther = vclassOther.getName();

    if (name == null) {
        return nameOther == null ? 0 : 1;
    }
    if (nameOther == null) {
        return -1;
    }
    return name.compareToIgnoreCase(nameOther);

}

From source file:org.eclipse.emf.teneo.test.stores.BaseTestDatabaseAdapter.java

public void dropDatabase() {
    try {/* w w w .  ja v  a2  s .com*/
        final Driver driver = (Driver) Class.forName(dbDriver).newInstance();
        Properties info = new Properties();
        info.put("user", dbUser);
        info.put("password", dbPwd);
        Connection conn = null;
        Statement stmt = null;
        try {
            conn = driver.connect(dbUrl, info);
            final ResultSet rs = conn.getMetaData().getCatalogs();
            boolean exists = false;
            while (rs.next()) {
                final String existingDb = rs.getString(1);
                exists |= existingDb.compareToIgnoreCase(dbName) == 0;
            }
            rs.close();

            if (exists) {
                stmt = conn.createStatement();
                conn.setAutoCommit(true);
                log.info("Dropping database: " + logInfo);
                stmt.execute("DROP DATABASE " + dbName + ";");
            } else {
                log.info("Database does not exist, not dropped, " + logInfo);
            }
        } finally {
            if (stmt != null) {
                stmt.close();
            }
            if (conn != null) {
                conn.close();
            }
        }
    } catch (Exception e) {
        throw new StoreTestException("Exception while dropping database: " + logInfo, e);
    }
}

From source file:org.codehaus.mojo.javascript.TitaniumSettings.java

private boolean getFromXPathAsBoolean(Document doc, XPath xpath, String query) throws XPathExpressionException {
    String result = getFromXPath(doc, xpath, query);
    if (result != null && result.compareToIgnoreCase("true") == 0) {
        return true;
    } else {//from w w  w.  j  ava 2  s . c om
        return false;
    }
}