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:edu.ucuenca.authorsdisambiguation.nwd.NWD.java

public double NGD(String a, String b) throws IOException, SQLException {

    a = a.trim();/*from w w  w.j  a  va  2 s. c  o m*/
    b = b.trim();

    if (a.compareToIgnoreCase(b) == 0) {
        return 0;
    }

    //double n0 = getResultsCount(""+a+"");
    //double n1 = getResultsCount(""+b+"");
    //String c = ""+a+" "+b+"";
    String _a = "\"" + a + "\"~10";
    String _b = "\"" + b + "\"~10";
    String c = "\"" + a + " " + b + "\"~50";
    if (Cache.getInstance().config.get("relaxMode").getAsBoolean().value()) {
        _a = "" + a;
        _b = "" + b;
        c = a + " " + b;
    }

    double n0 = getResultsCount(_a);
    double n1 = getResultsCount(_b);
    double n2 = 0;

    if (n0 == 0 || n1 == 0) {
        n2 = 0;
    } else {
        n2 = getResultsCount(c);
    }

    //double m = 5026040.0 * 590;
    double m = getResultsCount("the");

    double distance = 0;

    int Measure = 0;

    double l1 = Math.max(Math.log10(n0), Math.log10(n1)) - Math.log10(n2);
    double l2 = Math.log10(m) - Math.min(Math.log10(n0), Math.log10(n1));

    if (Measure == 0) {
        distance = l1 / l2;
    }

    if (Measure == 1) {
        distance = 1 - (Math.log10(n2) / Math.log10(n0 + n1 - n2));
    }

    if (n0 == 0 || n1 == 0 || n2 == 0) {
        distance = 1;
    }

    //System.out.println("n0="+n0);
    //System.out.println("n1="+n1);
    //System.out.println("n2="+n2);
    //System.out.println(a + "," + b + "=" + distance2);
    return distance;
}

From source file:org.wso2.carbon.inbound.endpoint.protocol.http2.common.InboundMessageHandler.java

private org.apache.axis2.context.MessageContext updateMessageContext(
        org.apache.axis2.context.MessageContext msgContext, Http2SourceRequest request) {
    Map excessHeaders = request.getExcessHeaders();
    if (msgContext == null) {
        msgContext = new org.apache.axis2.context.MessageContext();
    }/*from   w  w w . j av a 2  s  .  c om*/

    if (request.getScheme() != null && (request.getScheme().equalsIgnoreCase("https")
            || request.getScheme().equalsIgnoreCase("https2"))) {
        msgContext.setTransportOut(
                msgContext.getConfigurationContext().getAxisConfiguration().getTransportOut("https"));
        msgContext.setTransportIn(
                msgContext.getConfigurationContext().getAxisConfiguration().getTransportIn("https"));
    } else {
        msgContext.setTransportOut(
                msgContext.getConfigurationContext().getAxisConfiguration().getTransportOut("http"));
        msgContext.setTransportIn(
                msgContext.getConfigurationContext().getAxisConfiguration().getTransportIn("http"));

    }

    msgContext.setProperty("OutTransportInfo", this);
    msgContext.setServerSide(true);
    msgContext.setProperty("TransportInURL", request.getUri());
    TreeMap<String, String> headers1 = new TreeMap<String, String>(new Comparator<String>() {
        public int compare(String o1, String o2) {
            return o1.compareToIgnoreCase(o2);
        }
    });
    Set entries = request.getHeaders().entrySet();
    Iterator netConn = entries.iterator();

    while (netConn.hasNext()) {
        Map.Entry remoteAddress = (Map.Entry) netConn.next();
        headers1.put(remoteAddress.getKey().toString(), remoteAddress.getValue().toString());
    }

    msgContext.setProperty("TRANSPORT_HEADERS", headers1);
    msgContext.setProperty("EXCESS_TRANSPORT_HEADERS", excessHeaders);
    msgContext.setProperty("RequestResponseTransportControl", new HttpCoreRequestResponseTransport(msgContext));
    return msgContext;
}

From source file:org.eclipse.ecr.runtime.osgi.OSGiRuntimeService.java

protected void loadConfig() throws Exception {
    Environment env = Environment.getDefault();
    if (env != null) {
        log.info("Configuration: host application: " + env.getHostApplicationName());
    } else {/*w  w  w .  j  a va2 s .  c o m*/
        log.warn("Configuration: no host application");
    }

    File blacklistFile = new File(env.getConfig(), "blacklist");
    if (blacklistFile.isFile()) {
        List<String> lines = FileUtils.readLines(blacklistFile);
        Set<String> blacklist = new HashSet<String>();
        for (String line : lines) {
            line = line.trim();
            if (line.length() > 0) {
                blacklist.add(line);
            }
        }
        manager.setBlacklist(new HashSet<String>(lines));
    }

    if (loadConfigurationFromProvider()) {
        return;
    }

    String configDir = bundleContext.getProperty(PROP_CONFIG_DIR);
    if (configDir != null && configDir.contains(":/")) { // an url of a
        // config file
        log.debug("Configuration: " + configDir);
        URL url = new URL(configDir);
        log.debug("Configuration:   loading properties url: " + configDir);
        loadProperties(url);
        return;
    }

    if (env == null) {
        return;
    }

    // TODO: in JBoss there is a deployer that will deploy nuxeo
    // configuration files ..
    boolean isNotJBoss4 = !isJBoss4(env);

    File dir = env.getConfig();
    // File dir = new File(configDir);
    String[] names = dir.list();
    if (names != null) {
        Arrays.sort(names, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.compareToIgnoreCase(o2);
            }
        });
        for (String name : names) {
            if (name.endsWith("-config.xml") || name.endsWith("-bundle.xml")) {
                // TODO
                // because of some dep bugs (regarding the deployment of
                // demo-ds.xml)
                // we cannot let the runtime deploy config dir at
                // beginning...
                // until fixing this we deploy config dir from
                // NuxeoDeployer
                if (isNotJBoss4) {
                    File file = new File(dir, name);
                    log.debug("Configuration: deploy config component: " + name);
                    context.deploy(file.toURI().toURL());
                }
            } else if (name.endsWith(".config") || name.endsWith(".ini") || name.endsWith(".properties")) {
                File file = new File(dir, name);
                log.debug("Configuration: loading properties: " + name);
                loadProperties(file);
            } else {
                log.debug("Configuration: ignoring: " + name);
            }
        }
    } else if (dir.isFile()) { // a file - load it
        log.debug("Configuration: loading properties: " + dir);
        loadProperties(dir);
    } else {
        log.debug("Configuration: no configuration file found");
    }

    loadDefaultConfig();
}

From source file:org.jdal.util.comparator.AlphaNumericComparator.java

/**
 * {@inheritDoc}/*from  w w  w .jav  a2 s .  c om*/
 */
public int compare(String o1, String o2) {
    try {
        Pattern pattern = Pattern.compile("([0-9]+)");
        Matcher matcher1 = pattern.matcher(o1);
        Matcher matcher2 = pattern.matcher(o2);

        if ((matcher1.find() && matcher2.find()) && o1.startsWith(o2.substring(0, matcher2.start()))) {
            // two strings have numbers, and same prefix.
            // use numeric comparation
            Integer n1 = Integer.valueOf(matcher1.group());
            Integer n2 = Integer.valueOf(matcher2.group());
            return n1.compareTo(n2);
        }
        // else return string comparation
        return o1.compareToIgnoreCase(o2);
    } catch (Exception e) {
        log.error(e);
    }
    return 0; // On Exception object are equals
}

From source file:org.carewebframework.vista.ui.esig.ESigViewer.java

/**
 * Locates or creates the group for the specified esig item.
 * //w ww  .  j  a  v  a2s.com
 * @param item The signature item.
 * @return The associated group.
 */
private Group findGroup(ESigItem item) {
    String label = item.getESigType().getESigTypeGroupHeader();

    if (!StringUtils.isEmpty(item.getSubGroupName())) {
        label += " - " + item.getSubGroupName();
    }

    Group group = null;

    while ((group = nextGroup(group)) != null) {
        String lbl = (String) group.getValue();
        int i = label.compareToIgnoreCase(lbl);

        if (i == 0) {
            return group;
        }

        if (i < 0) {
            break;
        }
    }

    Row insertBefore = group;
    group = new Group();
    grid.addRow(group, insertBefore);
    group.setValue(label);
    ((HtmlBasedComponent) group.getFirstChild()).setStyle("float:left");
    group.appendChild(new Label(label));
    return group;
}

From source file:org.ebayopensource.turmeric.repository.wso2.assets.SchemaManager.java

/**
 * Finds all schema artifacts on the registry.
 * //from   w  w  w  .java  2s.  co m
 * @return all schema artifacts on the registry.
 * @throws GovernanceException
 *            if the operation failed.
 */
public Schema[] getAllSchemas() throws GovernanceException {
    List<String> schemaPaths = Arrays
            .asList(GovernanceUtils.getResultPaths(registry, GovernanceConstants.SCHEMA_MEDIA_TYPE));
    Collections.sort(schemaPaths, new Comparator<String>() {
        @Override
        public int compare(String o1, String o2) {
            // First order by name
            int result = RegistryUtils.getResourceName(o1)
                    .compareToIgnoreCase(RegistryUtils.getResourceName(o2));
            if (result != 0) {
                return result;
            }
            // Then order by namespace
            return o1.compareToIgnoreCase(o2);
        }
    });
    List<Schema> schemas = new ArrayList<Schema>();
    for (String schemaPath : schemaPaths) {
        GovernanceArtifact artifact = GovernanceUtils.retrieveGovernanceArtifactByPath(registry, schemaPath);
        schemas.add((Schema) artifact);
    }
    return schemas.toArray(new Schema[schemas.size()]);
}

From source file:org.wso2.carbon.governance.api.schema.SchemaManager.java

/**
 * Finds all schema artifacts on the registry.
 * /*from   w ww  .j  a v a 2 s.c  o  m*/
 * @return all schema artifacts on the registry.
 * @throws GovernanceException if the operation failed.
 */
public Schema[] getAllSchemas() throws GovernanceException {
    List<String> schemaPaths = Arrays
            .asList(GovernanceUtils.getResultPaths(registry, GovernanceConstants.SCHEMA_MEDIA_TYPE));
    Collections.sort(schemaPaths, new Comparator<String>() {
        public int compare(String o1, String o2) {
            // First order by name
            int result = RegistryUtils.getResourceName(o1)
                    .compareToIgnoreCase(RegistryUtils.getResourceName(o2));
            if (result != 0) {
                return result;
            }
            // Then order by namespace
            return o1.compareToIgnoreCase(o2);
        }
    });
    List<Schema> schemas = new ArrayList<Schema>();
    for (String schemaPath : schemaPaths) {
        GovernanceArtifact artifact = GovernanceUtils.retrieveGovernanceArtifactByPath(registry, schemaPath);
        schemas.add((Schema) artifact);
    }
    return schemas.toArray(new Schema[schemas.size()]);
}

From source file:immf.ServerMain.java

private void folderProc(Integer fid, List<String> mailIdList) {
    String lastId = this.status.getLastMailId();
    log.info("FolderID " + fid + "  ?ID?:" + mailIdList.size() + "  lastId:" + lastId);

    String newestId = "";

    if (StringUtils.isBlank(lastId)) {
        if (!mailIdList.isEmpty()) {
            // ???????????
            if (newestId.compareToIgnoreCase(mailIdList.get(0)) < 0) {
                return;
            }/* w  w w. ja va 2s  . co m*/
        } else {
            // ???????
            return;
        }
    } else {
        List<String> forwardIdList = new LinkedList<String>();
        for (String id : mailIdList) {
            if (lastId.compareToIgnoreCase(id) < 0) {
                // ?????
                forwardIdList.add(0, id);
            }
        }
        log.info("??ID? " + forwardIdList.size());
        appNotifications.pushPrepare(fid, forwardIdList.size());
        for (String id : forwardIdList) {
            this.forward(fid, id);
        }
    }
}

From source file:com.Candy.ota.CandyOTA.java

private void setDeviceInfoContainer() {
    try {//from   w  w  w .ja v a 2s .c  o m
        FileInputStream fstream = new FileInputStream("/system/build.prop");
        DataInputStream in = new DataInputStream(fstream);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String strLine;
        while ((strLine = br.readLine()) != null) {
            String[] line = strLine.split("=");
            if (line[0].equalsIgnoreCase("ro.candy.device")) {
                mStrCodename = line[1];
            } else if (line[0].equalsIgnoreCase("candy.ota.version")) {
                mStrCurVer = line[1];
            } else if (line[0].equalsIgnoreCase("ro.candy.model")) {
                mStrDevice = line[1];
            } else if (line[0].equalsIgnoreCase("ro.modversion")) {
                mStrCurFile = line[1];
            }
        }
        in.close();
    } catch (Exception e) {
        Toast.makeText(getView().getContext(), getString(R.string.system_prop_error), Toast.LENGTH_LONG).show();
        e.printStackTrace();
    }

    mDeviceOut.setText(getString(R.string.device_name_title) + " " + mStrDevice);
    mCodenameOut.setText(getString(R.string.codename_title) + " " + mStrCodename);
    mCurVerOut.setText(getString(R.string.version_title) + " " + mStrCurVer);
    mCurFileOut.setText(getString(R.string.file_name_title) + " " + mStrCurFile);

    SharedPreferences prefs = this.getActivity().getSharedPreferences("UpdateChecker", 0);
    String updateFile = prefs.getString("Filename", "");

    mUpdateFile.setTextColor(Color.RED);

    if (!UpdateChecker.connectivityAvailable(getActivity())) {
        mStrUpToDate = getString(R.string.no_data_title);
        mStatusIcon.setImageResource(R.drawable.ic_no_data);
    } else if (updateFile.equals("")) {
        mStrUpToDate = getString(R.string.error_reading_title);
        mStatusIcon.setImageResource(R.drawable.ic_no_data);
    } else if (updateFile.compareToIgnoreCase(mStrCurVer) <= 0) {
        mUpdateFile.setTextColor(Color.GREEN);
        mStrUpToDate = getString(R.string.up_to_date_title);
        mStatusIcon.setImageResource(R.drawable.ic_uptodate);
    } else {
        mStatusIcon.setImageResource(R.drawable.ic_need_update);
        mStrUpToDate = updateFile;
    }

    mUpdateFile.setText(" " + mStrUpToDate);
}