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:com.krawler.spring.importFunctionality.ImportController.java

public ModelAndView importRecords(HttpServletRequest request, HttpServletResponse response) {
    JSONObject jobj = new JSONObject();
    String View = "jsonView";
    try {/*from ww w  .  j a  v  a 2  s  .co m*/
        String doAction = request.getParameter("do");
        System.out.println("A(( " + doAction + " start : " + new Date());
        String companyId = sessionHandlerImpl.getCompanyid(request);
        if (doAction.compareToIgnoreCase("import") == 0 || doAction.compareToIgnoreCase("validateData") == 0) {
            HashMap<String, Object> requestParams = ImportUtil.getImportRequestParams(request);
            String eParams = request.getParameter("extraParams");
            JSONObject extraParams = StringUtil.isNullOrEmpty(eParams) ? new JSONObject()
                    : new JSONObject(eParams);
            requestParams.put("extraParams", extraParams);
            requestParams.put("extraObj", null);
            requestParams.put("servletContext", this.getServletContext());
            if (doAction.compareToIgnoreCase("import") == 0) {
                System.out.println("A(( Import start : " + new Date());
                String exceededLimit = request.getParameter("exceededLimit");
                if (exceededLimit.equalsIgnoreCase("yes")) { //If file contains records more than 1500 then Import file in background using thread
                    String logId = ImportUtil.addPendingImportLog(requestParams, importDao);
                    requestParams.put("logId", logId);
                    importHandler.setRequestParams(requestParams);
                    importThreadExecutor.startThread(importHandler);
                    jobj.put("success", true);
                } else {
                    jobj = importHandler.importFileData(requestParams);
                }
                jobj.put("exceededLimit", exceededLimit);
                System.out.println("A(( Import end : " + new Date());
            } else if (doAction.compareToIgnoreCase("validateData") == 0) {
                jobj = importHandler.validateFileData(requestParams);
                jobj.put("success", true);
            }
        } else if (doAction.compareToIgnoreCase("getMapCSV") == 0) {
            jobj = ImportUtil.getMappingCSVHeader(request);
            View = "jsonView-ex";
            // Dump csv data in DB
            String filename = jobj.getString("name");
            //                String actualfilename = ImportLog.getActualFileName(filename);
            String tableName = importDao.getTableName(filename);
            if (tableName.length() > 64) { // To fixed Mysql ERROR 1103 (42000): Incorrect table name
                throw new DataInvalidateException("Filename is too long, use upto 28 characters.");
            }
            importDao.createFileTable(tableName, jobj.getInt("cols"));
            importHandler.dumpCSVFileData(filename, jobj.getString("delimiterType"), 0, importDao);
            //                importDao.makeUploadedFileEntry(filename, actualfilename, tableName, companyId);
        } else if (doAction.compareToIgnoreCase("getXLSData") == 0) {
            try {
                String filename = request.getParameter("filename");
                int sheetNo = Integer.parseInt(request.getParameter("index"));
                jobj = ImportUtil.parseXLS(filename, sheetNo);
            } catch (Exception e) {
                Logger.getLogger(ImportController.class.getName()).log(Level.SEVERE, null, e);
                try {
                    jobj.put("msg", e.getMessage());
                    jobj.put("lsuccess", false);
                    jobj.put("valid", true);
                } catch (JSONException ex) {
                }
            }
            View = "jsonView-ex";
        } else if (doAction.compareToIgnoreCase("dumpXLS") == 0) {
            int sheetNo = Integer.parseInt(request.getParameter("index"));
            int rowIndex = Integer.parseInt(request.getParameter("rowIndex"));
            int columns = Integer.parseInt(request.getParameter("totalColumns"));
            String filename = request.getParameter("onlyfilename");
            //                String actualfilename = ImportLog.getActualFileName(filename);
            String tableName = importDao.getTableName(filename);
            importDao.createFileTable(tableName, columns);
            importHandler.dumpXLSFileData(filename, sheetNo, rowIndex, importDao);
            //                importDao.makeUploadedFileEntry(filename, actualfilename, tableName, companyId);
            jobj.put("success", true);
        } else if (doAction.compareToIgnoreCase("getXLSXData") == 0) {
            try {
                String filename = request.getParameter("filename");
                int sheetNo = Integer.parseInt(request.getParameter("index"));
                jobj = ImportUtil.parseXLSX(filename, sheetNo);
            } catch (Exception e) {
                Logger.getLogger(ImportController.class.getName()).log(Level.SEVERE, null, e);
                try {
                    jobj.put("msg", e.getMessage());
                    jobj.put("lsuccess", false);
                    jobj.put("valid", true);
                } catch (JSONException ex) {
                }
            }
            View = "jsonView-ex";
        } else if (doAction.compareToIgnoreCase("dumpXLSX") == 0) {
            int sheetNo = Integer.parseInt(request.getParameter("index"));
            int rowIndex = Integer.parseInt(request.getParameter("rowIndex"));
            int columns = Integer.parseInt(request.getParameter("totalColumns"));
            String filename = request.getParameter("onlyfilename");
            //                String actualfilename = ImportLog.getActualFileName(filename);
            String tableName = importDao.getTableName(filename);
            importDao.createFileTable(tableName, columns);
            importHandler.dumpXLSXFileData(filename, sheetNo, rowIndex, importDao);
            //                importDao.makeUploadedFileEntry(filename, actualfilename, tableName, companyId);
            jobj.put("success", true);
        }
        System.out.println("A(( " + doAction + " end : " + new Date());
    } catch (Exception ex) {
        try {
            jobj.put("success", false);
            jobj.put("msg", "" + ex.getMessage());
        } catch (JSONException jex) {
            Logger.getLogger(ImportController.class.getName()).log(Level.SEVERE, null, jex);
        }
    }
    return new ModelAndView(View, "model", jobj.toString());
}

From source file:net.sourceforge.fenixedu.presentationTier.backBeans.person.OrganizationalStructureBackingBean.java

public Map<String, Set<Unit>> getAllInstitutionSubUnits() throws FenixServiceException {

    YearMonthDay currentDate = new YearMonthDay();

    Map<String, Set<Unit>> resultMap = new TreeMap<String, Set<Unit>>(new Comparator<String>() {
        @Override//from w  w w . j a  v  a 2  s .  c  om
        public int compare(String arg0, String arg1) {
            String firstString = StringNormalizer.normalize(BundleUtil.getString(Bundle.ENUMERATION, arg0));
            String secondString = StringNormalizer.normalize(BundleUtil.getString(Bundle.ENUMERATION, arg1));
            return firstString.compareToIgnoreCase(secondString);
        }
    });

    Unit istUnit = UnitUtils.readInstitutionUnit();
    if (istUnit == null) {
        return new HashMap<String, Set<Unit>>();
    }

    for (Unit subUnit : istUnit.getActiveSubUnits(currentDate,
            AccountabilityTypeEnum.ORGANIZATIONAL_STRUCTURE)) {
        if (subUnit.isAggregateUnit()) {
            for (Unit unit : getValidSubUnits(subUnit, currentDate)) {
                addUnitToMap(resultMap, unit);
            }
        } else {
            addUnitToMap(resultMap, subUnit);
        }
    }

    return resultMap;
}

From source file:org.apache.stanbol.enhancer.engine.disambiguation.mlt.DisambiguatorEngine.java

protected boolean intersectionCheck(List<Suggestion> matches, List<UriRef> subsumed, MGraph graph,
        String contentLangauge) {
    for (int i = 0; i < subsumed.size(); i++) {
        UriRef uri = subsumed.get(i);/*w ww .j  av a  2 s  .com*/

        UriRef uri1 = EnhancementEngineHelper.getReference(graph, uri,
                new UriRef(NamespaceEnum.fise + "entity-reference"));

        //JOptionPane.showMessageDialog(null, " Check= "+uri1.getUnicodeString());

        String selectedText = EnhancementEngineHelper.getString(graph, uri, ENHANCER_ENTITY_LABEL);

        if (selectedText == null) {
            continue;
        }

        for (int j = 0; j < matches.size(); j++) {
            Suggestion suggestion = matches.get(j);
            String suggestName = suggestion.getURI();
            //JOptionPane.showMessageDialog(null, " "+suggestion.getURI());
            if (suggestName.compareToIgnoreCase(uri1.getUnicodeString()) == 0)
                return true;
        }
    }
    return false;
}

From source file:org.b3log.symphony.service.UserQueryService.java

/**
 * Loads all usernames from database./*from w  w  w .j av  a2  s.c om*/
 */
public void loadUserNames() {
    userNames.clear();

    final Query query = new Query().setPageCount(1)
            .setFilter(new PropertyFilter(User.USER_NAME, FilterOperator.NOT_EQUAL, UserExt.NULL_USER_NAME))
            .addProjection(User.USER_NAME, String.class).addProjection(User.USER_EMAIL, String.class)
            .addProjection(UserExt.USER_REAL_NAME, String.class)
            .addProjection(UserExt.USER_AVATAR_URL, String.class);

    try {
        final JSONObject result = userRepository.get(query); // XXX: Performance Issue
        final JSONArray array = result.optJSONArray(Keys.RESULTS);
        for (int i = 0; i < array.length(); i++) {
            final JSONObject user = array.optJSONObject(i);

            final JSONObject u = new JSONObject();
            u.put(User.USER_NAME, user.optString(User.USER_NAME));
            u.put(UserExt.USER_REAL_NAME, user.optString(UserExt.USER_REAL_NAME));
            u.put(User.USER_EMAIL, user.optString(User.USER_EMAIL));

            String avatar = user.optString(UserExt.USER_AVATAR_URL);
            if (StringUtils.isBlank(avatar)) {
                avatar = AvatarQueryService.DEFAULT_AVATAR_URL;
            }
            u.put(UserExt.USER_AVATAR_URL, avatar);

            userNames.add(u);
        }

        Collections.sort(userNames, new Comparator<JSONObject>() {
            @Override
            public int compare(final JSONObject u1, final JSONObject u2) {
                final String u1Name = u1.optString(User.USER_EMAIL);
                final String u2Name = u2.optString(User.USER_EMAIL);

                return u1Name.compareToIgnoreCase(u2Name);
            }
        });
    } catch (final RepositoryException e) {
        LOGGER.log(Level.ERROR, "Loads usernames error", e);
    }
}

From source file:org.martin.ftp.util.SearchComparator.java

@Override
public int compare(FileFiltering o1, FileFiltering o2) {

    FTPFile fileO1 = o1.getFile();/* w  ww  .ja va 2  s  .c o m*/
    FTPFile fileO2 = o2.getFile();

    if (null != option)
        switch (option) {
        case DATE:
            if (order == SortOption.UPWARD)
                return (int) (fileO1.getTimestamp().getTimeInMillis()
                        - fileO2.getTimestamp().getTimeInMillis());

            else
                return (int) (fileO2.getTimestamp().getTimeInMillis()
                        - fileO1.getTimestamp().getTimeInMillis());

        case FORMAT:
            String file1Format = Utilities.getFormat(fileO1.getName());
            String file2Format = Utilities.getFormat(fileO2.getName());
            if (order == SortOption.UPWARD)
                if (fileO1.isDirectory() || fileO2.isDirectory()) {
                    if (fileO1.isDirectory() && fileO2.isDirectory())
                        return idDirectory - idDirectory;
                    else if (fileO1.isDirectory() && !fileO2.isDirectory())
                        return idDirectory - idFile;
                    else
                        return idFile - idDirectory;
                } else
                    return file1Format.compareToIgnoreCase(file2Format);
            else if (fileO1.isDirectory() || fileO2.isDirectory()) {
                if (fileO1.isDirectory() && fileO2.isDirectory())
                    return idDirectory - idDirectory;
                else if (fileO1.isDirectory() && !fileO2.isDirectory())
                    return idFile - idDirectory;
                else
                    return idDirectory - idFile;
            } else
                return file2Format.compareToIgnoreCase(file1Format);

        case NAME:
            if (order == SortOption.UPWARD)
                return fileO1.getName().compareToIgnoreCase(fileO2.getName());
            else
                return fileO2.getName().compareToIgnoreCase(fileO1.getName());

        case SIZE:
            if (order == SortOption.UPWARD)
                return (int) (fileO1.getSize() - fileO2.getSize());
            else
                return (int) (fileO2.getSize() - fileO1.getSize());

        case TYPE:
            if ((fileO1.isDirectory() && fileO2.isDirectory())
                    || (!fileO1.isDirectory() && !fileO2.isDirectory()))
                return idDirectory - idDirectory;

            if (order == SortOption.UPWARD)
                if (fileO1.isDirectory() && !fileO2.isDirectory())
                    return idDirectory - idFile;

                else
                    return idFile - idDirectory;
            else if (fileO1.isDirectory() && !fileO2.isDirectory())
                return idFile - idDirectory;

            else
                return idDirectory - idFile;
        default:
            return 0;
        }

    return 0;
}

From source file:net.mypapit.mobile.myrepeater.DisplayMap.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_display_map);
    overridePendingTransition(R.anim.activity_open_translate, R.anim.activity_close_scale);

    hashMap = new HashMap<Marker, MapInfoObject>();

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }/*from   w w  w.j  av  a2s .  c  om*/

    map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

    if (map == null) {

        // Log.e("Map NULL", "MAP NULL");
        Toast.makeText(this, "Unable to display Map", Toast.LENGTH_SHORT).show();

    } else {

        LatLng latlng = (LatLng) getIntent().getExtras().get("LatLong");

        Repeater xlocation = new Repeater("", new Double[] { latlng.latitude, latlng.longitude });

        rl = RepeaterListActivity.loadData(R.raw.repeaterdata5, this);
        xlocation.calcDistanceAll(rl);
        rl.sort();

        map.setMyLocationEnabled(true);
        map.setOnInfoWindowClickListener(this);
        map.getUiSettings().setZoomControlsEnabled(true);

        AdView mAdView = (AdView) findViewById(R.id.adViewMap);
        mAdView.loadAd(new AdRequest.Builder().build());

        // counter i, for mapping marker with integer
        int i = 0;

        for (Repeater repeater : rl) {

            MarkerOptions marking = new MarkerOptions();
            marking.position(new LatLng(repeater.getLatitude(), repeater.getLongitude()));
            marking.title(repeater.getCallsign() + " - " + repeater.getDownlink() + "MHz (" + repeater.getClub()
                    + ")");

            marking.snippet("Tone: " + repeater.getTone() + " Shift: " + repeater.getShift());

            RepeaterMapInfo rmi = new RepeaterMapInfo(repeater);
            rmi.setIndex(i);

            hashMap.put(map.addMarker(marking), rmi);

            i++;

        }

        // Marker RKG = map.addMarker(new MarkerOptions().position(new
        // LatLng(6.1,100.3)).title("9M4RKG"));

        map.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 10));
        map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

        cache = this.getSharedPreferences(CACHE_PREFS, 0);

        Date cachedate = new Date(cache.getLong(CACHE_TIME, new Date(20000).getTime()));

        long secs = (new Date().getTime() - cachedate.getTime()) / 1000;
        long hours = secs / 3600L;
        secs = secs % 3600L;
        long mins = secs / 60L;

        if (mins < 5) {
            String jsoncache = cache.getString(CACHE_JSON, "none");
            if (jsoncache.compareToIgnoreCase("none") == 0) {
                new GetUserInfo(latlng, this).execute();

            } else {

                loadfromCache(jsoncache);
                // Toast.makeText(this, "Loaded from cache: " + mins +
                // " mins", Toast.LENGTH_SHORT).show();
            }

        } else {

            new GetUserInfo(latlng, this).execute();

        }

        map.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {

            @Override
            public View getInfoWindow(Marker marker) {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public View getInfoContents(Marker marker) {
                Context context = getApplicationContext(); // or
                // getActivity(),
                // YourActivity.this,
                // etc.

                LinearLayout info = new LinearLayout(context);
                info.setOrientation(LinearLayout.VERTICAL);

                TextView title = new TextView(context);
                title.setTextColor(Color.BLACK);
                title.setGravity(Gravity.CENTER);
                title.setTypeface(null, Typeface.BOLD);
                title.setText(marker.getTitle());

                TextView snippet = new TextView(context);
                snippet.setTextColor(Color.GRAY);
                snippet.setText(marker.getSnippet());

                info.addView(title);
                info.addView(snippet);

                return info;
            }
        });

    }

}

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

private void parseDocument(Document document) {
    Element element = document.getDocumentElement();

    NodeList updates = element.getElementsByTagName("entry");
    if (updates != null && updates.getLength() > 0) {
        for (int index = 0; index < updates.getLength(); index++) {
            Element item = (Element) updates.item(index);

            try {
                /* /* ww w  .  ja v  a  2s .  c om*/
                Example
                -------
                <entry>
                   <action>none</action>
                   <identity>generated</identity>
                   <user>john.doe@somedomain.com</user>
                   <description>Twitter Status Updates</description>
                   <channelType>twitter</channelType>
                   <feedURL>https://api.twitter.com/1/statuses/friends_timeline.atom</feedURL>
                   <fullText></fullText>
                   <feedGroup></feedGroup>
                </entry>
                */
                String action = XMLUtils.getValue(item, "action");
                String identity = XMLUtils.getValue(item, "identity");
                String user = XMLUtils.getValue(item, "user");
                String description = XMLUtils.getValue(item, "description");
                String channelType = XMLUtils.getValue(item, "channelType");
                String feedURL = XMLUtils.getValue(item, "feedURL");
                String fullText = XMLUtils.getValue(item, "fullText");
                String feedGroup = XMLUtils.getValue(item, "feedGroup");

                if (identity.compareToIgnoreCase(SubscriptionManager.GENERATED) == 0) {
                    identity = SecurityUtils.makeHash(description);
                }

                SubscriptionEntry entry = new SubscriptionEntry(action, channelType, description, identity,
                        user, feedURL, fullText, feedGroup);
                if (action.compareToIgnoreCase("none") == 0) {
                    entry.setEnabled(false);
                }

                addUserSubscription(entry);
            } catch (Exception e) {
                logger.error("Exception while extracting subscriptions : " + e.getMessage());
            }
        }
    }

    processEntries(true);
}

From source file:com.qspin.qtaste.ui.testcampaign.TestCampaignMainPanel.java

/**
 * Add a test campaign to the test campaigns combobox.
 *
 * @param campaignName test campaign name
 * @return index of the added test campaign in the combobox or -1 if not added
 *///from w  w w .  jav  a  2 s  .com
public int addTestCampaign(String campaignName) {
    // add the campaign in the list, keeping sorted order
    int index = 0;
    while (index < metaCampaignComboBox.getItemCount()) {
        String elementCampaignName = ((MetaCampaignFile) metaCampaignComboBox.getItemAt(index))
                .getCampaignName();
        int comparison = campaignName.compareToIgnoreCase(elementCampaignName);
        if (comparison < 0) {
            // insert new campaign at this index
            break;
        } else if (comparison == 0) {
            // error: a campaign with the same name already exists
            JOptionPane.showMessageDialog(null,
                    "A test campaign named '" + elementCampaignName + "' already exists!", "Error",
                    JOptionPane.ERROR_MESSAGE);
            index = -1;
            break;
        }
        index++;
    }
    if (index >= 0) {
        MetaCampaignFile newItem = new MetaCampaignFile(campaignName);
        metaCampaignComboBox.insertItemAt(newItem, index);
    }
    return index;
}

From source file:org.parosproxy.paros.core.scanner.plugin.TestMiscExternalRedirect.java

public void scan(HttpMessage msg, String param, String value) {

    String locationHeader = null;
    String locationHeader2 = null;
    String redirect = "";

    URI uri = null;/*  w  w  w .  jav  a 2  s  .c  o  m*/

    msg = getNewMsg();
    try {
        sendAndReceive(msg, false);
        if (msg.getResponseHeader().getStatusCode() != HttpStatusCode.MOVED_PERMANENTLY
                && msg.getResponseHeader().getStatusCode() != HttpStatusCode.FOUND) {
            // not redirect page, return;
            return;
        }

        locationHeader = msg.getResponseHeader().getHeader(HttpHeader.LOCATION);
        if (locationHeader == null) {
            return;
        }

        if (locationHeader.compareToIgnoreCase(value) == 0) {
            // URI found in param
            redirect = redirect1;
        } else if (locationHeader.compareToIgnoreCase(getURLDecode(value)) == 0) {
            redirect = getURLEncode(redirect1);
        }

        if (redirect != null) {
            uri = new URI(locationHeader, true);
            locationHeader2 = uri.getPathQuery();
            if (locationHeader2.compareToIgnoreCase(value) == 0) {
                // path and query found in param
                redirect = redirect2;
            } else if (locationHeader2.compareToIgnoreCase(getURLDecode(value)) == 0) {
                redirect = getURLEncode(redirect2);
            }
        }

        if (redirect == null) {
            return;
        }

    } catch (Exception e) {

    }

    msg = getNewMsg();
    setParameter(msg, param, redirect);
    try {
        sendAndReceive(msg, false);
        if (checkResult(msg, param + "=" + redirect)) {
            return;
        }

    } catch (Exception e) {

    }

}

From source file:com.krawler.spring.crm.common.ImportRecordAdvisor.java

private void AfterGetRefModuleData(MethodInvocation mi, Object result) throws DataInvalidateException {
    if (result != null) {
        List masterList = (List) result;
        if (masterList.size() == 0) {
            Object arguments[] = mi.getArguments();
            String module = (String) arguments[1];
            if (ImportHandler.isMasterTable(module)) { //Check for referencing to master
                try {
                    HashMap<String, Object> requestParams = (HashMap<String, Object>) arguments[0];
                    if (requestParams.containsKey("companyid") && requestParams.containsKey("doAction")
                            && requestParams.containsKey("masterPreference")) {
                        String companyid = requestParams.get("companyid").toString();
                        String doAction = requestParams.get("doAction").toString();
                        String pref = (String) requestParams.get("masterPreference"); //0:Skip Record, 1:Skip Column, 2:Add new
                        //                        String addMissingMaster = (String) requestParams.get("addMissingMaster");
                        if (doAction.compareToIgnoreCase("import") == 0 && pref != null
                                && pref.compareToIgnoreCase("2") == 0) {
                            String comboConfigid = (String) arguments[3];
                            ArrayList<Object> filterValues = (ArrayList<Object>) arguments[5];

                            if (module.equalsIgnoreCase("DefaultMasterItem")
                                    || module.equalsIgnoreCase("com.krawler.common.admin.DefaultMasterItem")) {
                                String configid = (String) arguments[3];
                                String masterName = filterValues.get(0) != null ? filterValues.get(0).toString()
                                        : "";
                                masterName = masterName.length() > 50 ? masterName.substring(0, 50)
                                        : masterName; //Maxlength for value is 50 so truncate extra string
                                HashMap<String, Object> addParams = new HashMap<String, Object>();
                                addParams.put("companyid", companyid);
                                addParams.put("name", masterName);
                                addParams.put("configid", comboConfigid);

                                KwlReturnObject kmsg = crmManagerDAOObj.addMasterData(addParams);

                                JSONObject jResultObj = new JSONObject(kmsg.getEntityList().get(0).toString());
                                if (jResultObj.has("data")) {
                                    if (jResultObj.getJSONObject("data").has("id"))
                                        masterList.add(jResultObj.getJSONObject("data").getString("id"));
                                }//from   w  w w  .  j  a  v  a  2 s  .co  m
                            }
                        }
                    }
                } catch (Exception e) {
                    logger.warn(e.getMessage(), e);
                }
            }
        }
    }
}