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:net.risesoft.soa.asf.web.controller.SystemController.java

private List<SysInfo> getVMInfo() {
    List list = new ArrayList();
    String group = "3. VM ?";
    RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
    list.add(new SysInfo("BootClassPath", rt.getBootClassPath(), group));
    list.add(new SysInfo("ClassPath", rt.getClassPath(), group));
    list.add(new SysInfo("LibraryPath", rt.getLibraryPath(), group));
    list.add(new SysInfo("ManagementSpecVersion", rt.getManagementSpecVersion(), group));
    list.add(new SysInfo("Name", rt.getName(), group));
    list.add(new SysInfo("SpecName", rt.getSpecName(), group));
    list.add(new SysInfo("SpecVendor", rt.getSpecVendor(), group));
    list.add(new SysInfo("SpecVersion", rt.getSpecVersion(), group));
    list.add(new SysInfo("VmName", rt.getVmName(), group));
    list.add(new SysInfo("VmVendor", rt.getVmVendor(), group));
    list.add(new SysInfo("VmVersion", rt.getVmVersion(), group));
    list.add(new SysInfo("StartTime", DateFormat.getDateTimeInstance().format(new Date(rt.getStartTime())),
            group));/*ww  w  .  j av a  2s .c o m*/

    list.add(new SysInfo("UpTime", this.helper.getUpTimeStr(rt.getUptime()), group));
    list.add(new SysInfo("InputArguments", rt.getInputArguments(), group));

    group = "6. ?";
    Map<String, String> sysProps = rt.getSystemProperties();
    for (Map.Entry entry : sysProps.entrySet()) {
        list.add(new SysInfo((String) entry.getKey(), entry.getValue(), group));
    }
    Collections.sort(list, new Comparator() {
        public int compare(SystemController.SysInfo o1, SystemController.SysInfo o2) {
            String key1 = o1.getKey();
            String key2 = o2.getKey();
            return key1.compareToIgnoreCase(key2);
        }
    });
    return list;
}

From source file:com.geminimobile.web.SearchController.java

@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException arg3) throws Exception {
    SearchCommand cmd = (SearchCommand) command;
    ModelAndView mav = new ModelAndView(getSuccessView());

    CDRDataAccess cdrAccess = new CDRDataAccess();

    Date toDate = SearchCommand.m_sdf.parse(cmd.getToDate());
    long maxTimestamp = toDate.getTime();

    Date fromDate = SearchCommand.m_sdf.parse(cmd.getFromDate());
    long minTimestamp = fromDate.getTime();

    String msisdn = cmd.getMsisdn();
    String action = cmd.getAction();
    Vector<CDREntry> cdrs;//from w ww  .j  av  a 2s  .c  om

    if (action.compareToIgnoreCase("downloadcsv") == 0) {

        if (msisdn != null && msisdn.length() > 0) {
            cdrs = cdrAccess.getCDRsByMSISDN(cmd.getMsisdn(), minTimestamp, maxTimestamp, cmd.getMarket(),
                    cmd.getMessageType(), 100000); // 100,000 entries max
        } else {
            cdrs = cdrAccess.getCDRsByHour(minTimestamp, maxTimestamp, cmd.getMarket(), cmd.getMessageType(),
                    MAX_ENTRIES_PER_PAGE);
        }
        StringBuffer sb = new StringBuffer();

        // Write column headers 
        sb.append("Date/Time,Market,Type,MSISDN,MO IP address,MT IP Address,Sender Domain,Recipient Domain\n");

        for (CDREntry entry : cdrs) {
            sb.append(entry.getDisplayTimestamp() + "," + entry.getMarket() + "," + entry.getType() + ","
                    + entry.getMsisdn() + "," + entry.getMoIPAddress() + "," + entry.getMtIPAddress() + ","
                    + entry.getSenderDomain() + "," + entry.getRecipientDomain() + "\n");
        }

        String csvString = sb.toString();

        response.setBufferSize(sb.length());
        response.setContentLength(sb.length());
        response.setContentType("text/plain; charset=UTF-8");
        //response.setContentType( "text/csv" );
        //response.setContentType("application/ms-excel");
        //response.setHeader("Content-disposition", "attachment;filename=cdrResults.csv");
        response.setHeader("Content-Disposition", "attachment; filename=" + "cdrResults.csv" + ";");
        ServletOutputStream os = response.getOutputStream();

        os.write(csvString.getBytes());

        os.flush();
        os.close();

        return null;

    } else if (action.compareToIgnoreCase("graph") == 0) {
        cmd.setGraph(true);
        List<ChartSeries> chartData;
        if (msisdn != null && msisdn.length() > 0) {
            chartData = cdrAccess.getChartDataByMSISDN(cmd.getMsisdn(), minTimestamp, maxTimestamp,
                    cmd.getMarket(), cmd.getMessageType(), 100000);
        } else {
            chartData = cdrAccess.getChartDataByHour(minTimestamp, maxTimestamp, cmd.getMarket(),
                    cmd.getMessageType(), 100000);
        }

        request.getSession().setAttribute("chartData", chartData);

    } else if (action.compareToIgnoreCase("getmore") == 0) {
        cdrs = (Vector<CDREntry>) request.getSession().getAttribute("currentcdrs");
        int numCDRs = cdrs.size();
        CDREntry lastCDR = cdrs.get(numCDRs - 1);
        long lastCDRTime = Long.parseLong(lastCDR.getTimestamp());

        if (msisdn != null && msisdn.length() > 0) {
            Vector<CDREntry> moreCDRs = cdrAccess.getCDRsByMSISDN(cmd.getMsisdn(), lastCDRTime, maxTimestamp,
                    cmd.getMarket(), cmd.getMessageType(), MAX_ENTRIES_PER_PAGE);
            cdrs.addAll(moreCDRs);
        } else {
            Vector<CDREntry> moreCDRs = cdrAccess.getCDRsByHour(lastCDRTime, maxTimestamp, cmd.getMarket(),
                    cmd.getMessageType(), MAX_ENTRIES_PER_PAGE);
            cdrs.addAll(moreCDRs);
        }

        request.getSession().setAttribute("currentcdrs", cdrs);
        mav.addObject("cdrs", cdrs);
    } else {
        // Normal search            
        if (msisdn != null && msisdn.length() > 0) {
            cdrs = cdrAccess.getCDRsByMSISDN(cmd.getMsisdn(), minTimestamp, maxTimestamp, cmd.getMarket(),
                    cmd.getMessageType(), MAX_ENTRIES_PER_PAGE);
        } else {
            cdrs = cdrAccess.getCDRsByHour(minTimestamp, maxTimestamp, cmd.getMarket(), cmd.getMessageType(),
                    MAX_ENTRIES_PER_PAGE);
        }

        request.getSession().setAttribute("currentcdrs", cdrs);
        mav.addObject("cdrs", cdrs);
    }

    mav.addObject("searchCmd", cmd);

    List<Option> msgOptions = getMessageOptions();
    mav.addObject("msgTypes", msgOptions);
    List<Option> marketOptions = getMarketOptions();
    mav.addObject("marketTypes", marketOptions);

    return mav;
}

From source file:org.eclipse.emf.teneo.annotations.parser.EAnnotationParserImporter.java

/** Processes EAnnotations */
private ArrayList<NamedParserNode> process(EAnnotation ea, ENamedElement ene) {
    final ArrayList<NamedParserNode> result = new ArrayList<NamedParserNode>();

    if (!isValidSource(ea.getSource())) {
        return result;
    }/* ww  w . j  ava 2  s  .  c  o m*/

    log.debug("Processing annotations ");
    for (Map.Entry<String, String> pAnnotationDetails : ea.getDetails().entrySet()) {
        final String fName = pAnnotationDetails.getKey();
        // todo externalize
        if (fName.compareToIgnoreCase("appinfo") == 0 || fName.compareToIgnoreCase("value") == 0) {
            log.debug("Annotation content: \n " + pAnnotationDetails.getValue());
            final String content = removeCommentLines(pAnnotationDetails.getValue());
            result.addAll(annotationParser.parse(ene, content));
        }
    }
    return result;
}

From source file:com.sfs.whichdoctor.analysis.TrainingSummaryAnalysisDAOImpl.java

/**
 * Perform a training analysis search./*from w  ww .ja v  a 2 s.co  m*/
 *
 * @param trainingSummary the existing training summary search
 *
 * @return the training summary bean
 *
 * @throws WhichDoctorAnalysisDaoException the which doctor analysis dao
 *             exception
 */
public final TrainingSummaryBean search(final TrainingSummaryBean trainingSummary)
        throws WhichDoctorAnalysisDaoException {

    TrainingSummaryBean search = trainingSummary.clone();

    if (search == null) {
        throw new NullPointerException("The training summary cannot be null");
    }

    /* Clear any existing results or people */
    search.clearResults();

    // Perform a PersonSearchDAO based on the array
    // of people GUIDs in the search object

    Collection<Object> peopleGUIDs = new ArrayList<Object>();

    if (search.getPeople() != null) {
        for (String name : search.getPeople().keySet()) {
            PersonBean person = search.getPeople().get(name);
            peopleGUIDs.add(person.getGUID());
        }
    }

    // Load the people who are part of this rotation summary
    SearchBean findPeople = this.searchDAO.initiate("person", new UserBean());
    findPeople.setLimit(0);
    findPeople.setSearchArray(peopleGUIDs, "People in training summary set");

    BuilderBean personDetails = new BuilderBean();
    // Set search to load training summary details
    for (String type : search.getTrainingTypes()) {
        if (type.compareToIgnoreCase("Basic Training") == 0) {
            personDetails.setParameter("TRAINING_BASIC", true);
        }
        if (type.compareToIgnoreCase("Advanced Training") == 0) {
            personDetails.setParameter("TRAINING_ADVANCED", true);
        }
        if (type.compareToIgnoreCase("Post-FRACP Training") == 0) {
            personDetails.setParameter("TRAINING_POSTFRACP", true);
        }
    }
    personDetails.setParameter("MEMBERSHIP", true);
    personDetails.setParameter("SPECIALTY", true);

    try {
        SearchResultsBean personResults = this.searchDAO.search(findPeople, personDetails);

        // Set the training summary people
        if (personResults != null) {
            Collection<PersonBean> people = new ArrayList<PersonBean>();
            for (Object result : personResults.getSearchResults()) {
                people.add((PersonBean) result);
            }
            search.setLoadedPeople(people);
        }
    } catch (Exception e) {
        dataLogger.error("Error performing person search: " + e.getMessage());
        throw new WhichDoctorAnalysisDaoException("Error performing person search: " + e.getMessage());
    }

    /**
     * Iterate through all the loaded people Put them into the relevant
     * specialty committee groups Depending on specialty status - training
     */
    for (Integer guid : search.getLoadedPeople().keySet()) {
        PersonBean person = search.getLoadedPeople().get(guid);
        if (person.getSpecialtyList() != null) {
            for (SpecialtyBean specialty : person.getSpecialtyList()) {
                if (StringUtils.equalsIgnoreCase(specialty.getStatus(), "Training for specialty")) {
                    search = addPersonToCommittee(search, specialty.getTrainingProgram(), person);
                }
            }
        }
    }

    SearchBean findRotations = this.searchDAO.initiate("rotation", new UserBean());
    findRotations.setLimit(0);

    // Set the search criteria to be the list of people GUIDs
    RotationBean rotationCriteria = (RotationBean) findRotations.getSearchCriteria();
    RotationBean rotationConstraint = (RotationBean) findRotations.getSearchConstraints();

    dataLogger.info("Setting " + peopleGUIDs.size() + " people GUID values");
    Collection<Integer> people = new ArrayList<Integer>();
    for (Object guid : peopleGUIDs) {
        people.add((Integer) guid);
    }
    rotationCriteria.setPeopleGUIDs(people);
    rotationCriteria.setSummaryTypes(search.getTrainingTypes());

    /* Set the start date for the rotations */
    rotationCriteria.setStartDate(search.getStartDate());
    rotationConstraint.setStartDate(DataFilter.parseDate("31/12/2037", false));
    /* Set the end date for the rotations */
    rotationCriteria.setEndDate(search.getEndDate());
    rotationConstraint.setEndDate(DataFilter.parseDate("1/1/1900", false));

    findRotations.setSearchCriteria(rotationCriteria);
    findRotations.setSearchConstraints(rotationConstraint);

    BuilderBean rotationDetails = new BuilderBean();
    rotationDetails.setParameter("ASSESSMENTS", true);
    rotationDetails.setParameter("SUPERVISORS", true);

    try {
        SearchResultsBean rotationResults = this.searchDAO.search(findRotations, rotationDetails);

        if (rotationResults != null) {
            Collection<RotationBean> rotations = new ArrayList<RotationBean>();
            if (rotationResults.getSearchResults() != null) {
                for (Object result : rotationResults.getSearchResults()) {
                    rotations.add((RotationBean) result);
                }
            }
            /* Set the training summary rotations */
            search.setResults(rotations);
        }

    } catch (Exception e) {
        dataLogger.error("Error performing rotation search: " + e.getMessage());
        throw new WhichDoctorAnalysisDaoException("Error performing rotation search: " + e.getMessage());
    }

    return search;
}

From source file:com.mycodehurts.rapidmath.app.ProfilePage.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences store = getSharedPreferences(PREFS_NAME, 0);
    SharedPreferences.Editor editor = store.edit();
    String strProfileName = store.getString("strProfileName", "NotFound");

    if (strProfileName.compareToIgnoreCase("NotFound") == 0) {
        Intent intent = new Intent(this, HomeActivity.class);
        startActivity(intent);/*from w  w w  .  j a v a  2s. c  o m*/
    }

    setContentView(R.layout.activity_profile_page);

    mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager()
            .findFragmentById(R.id.navigation_drawer);
    mTitle = getTitle();

    // Set up the drawer.
    mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));
    ((RMApplication) getApplication()).getTracker(RMApplication.TrackerName.APP_TRACKER);

}

From source file:org.apache.hadoop.chukwa.database.TestDatabaseWebJson.java

protected String getDatabaseQuery(String tableName, JSONObject jo) {
    ArrayList<String> keys = (ArrayList<String>) testTables.get(tableName);
    ArrayList<String> criterias = new ArrayList<String>();
    Iterator i = keys.iterator();
    while (i.hasNext()) {
        String key = (String) i.next();
        try {//from  ww w.  jav  a2  s.  c  o m
            String value = (String) jo.get(key);
            if (key.compareToIgnoreCase("timestamp") == 0) {
                value = DatabaseWriter.formatTimeStamp(Long.parseLong(value));
            }
            String c = key + "=\"" + value + "\"";
            criterias.add(c);
        } catch (Exception e) {
            System.out.println("Cannot get value for key: " + key);
        }
    }
    String criteria = join(" and ", criterias);

    String query = "select * from [" + tableName + "] where " + criteria;
    return query;
}

From source file:net.olejon.spotcommander.PlaylistsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Allow landscape?
    if (!mTools.allowLandscape())
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    // Intent/*from  ww w  .ja va2  s. c om*/
    final Intent intent = getIntent();

    // Computer
    final long computerId = mTools.getSharedPreferencesLong(
            "WIDGET_" + intent.getStringExtra(WidgetLarge.WIDGET_LARGE_INTENT_EXTRA) + "_COMPUTER_ID");

    final String[] computer = mTools.getComputer(computerId);

    // Layout
    setContentView(R.layout.activity_playlists);

    // Toolbar
    final Toolbar toolbar = (Toolbar) findViewById(R.id.playlists_toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_close_white_24dp);
    toolbar.setTitle(getString(R.string.playlists_title));

    setSupportActionBar(toolbar);

    // Progress bar
    mProgressBar = (ProgressBar) findViewById(R.id.playlists_progressbar);
    mProgressBar.setVisibility(View.VISIBLE);

    // Listview
    mListView = (ListView) findViewById(R.id.playlists_list);

    // Get playlists
    final Cache cache = new DiskBasedCache(getCacheDir(), 0);

    final Network network = new BasicNetwork(new HurlStack());

    final RequestQueue requestQueue = new RequestQueue(cache, network);

    requestQueue.start();

    final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET,
            computer[0] + "/playlists.php?get_playlists_as_json", null, new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    requestQueue.stop();

                    try {
                        final ArrayList<String> playlistNames = new ArrayList<>();

                        final Iterator<?> iterator = response.keys();

                        while (iterator.hasNext()) {
                            String key = (String) iterator.next();

                            playlistNames.add(key);
                        }

                        Collections.sort(playlistNames, new Comparator<String>() {
                            @Override
                            public int compare(String string1, String string2) {
                                return string1.compareToIgnoreCase(string2);
                            }
                        });

                        for (String playlistName : playlistNames) {
                            mPlaylistUris.add(response.getString(playlistName));
                        }

                        final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(mContext,
                                R.layout.activity_playlists_list_item, playlistNames);

                        mProgressBar.setVisibility(View.GONE);

                        mListView.setAdapter(arrayAdapter);
                        mListView.setVisibility(View.VISIBLE);

                        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                mTools.remoteControl(computerId, "shuffle_play_uri",
                                        mPlaylistUris.get(position));

                                finish();
                            }
                        });
                    } catch (Exception e) {
                        mProgressBar.setVisibility(View.GONE);

                        final TextView textView = (TextView) findViewById(R.id.playlists_error);
                        textView.setVisibility(View.VISIBLE);
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    requestQueue.stop();

                    mProgressBar.setVisibility(View.GONE);

                    final TextView textView = (TextView) findViewById(R.id.playlists_error);
                    textView.setVisibility(View.VISIBLE);
                }
            }) {
        @Override
        public HashMap<String, String> getHeaders() {
            final HashMap<String, String> hashMap = new HashMap<>();

            if (!computer[1].equals("") && !computer[2].equals(""))
                hashMap.put("Authorization", "Basic "
                        + Base64.encodeToString((computer[1] + ":" + computer[2]).getBytes(), Base64.NO_WRAP));

            return hashMap;
        }
    };

    jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(2500, 0, 0));

    requestQueue.add(jsonObjectRequest);
}

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

/**
 * Gets manuals by the specified command prefix.
 *
 * @param cmdPrefix the specified comman prefix
 * @return a list of manuals, for example, <pre>
 * [//ww  w .  j a  va2 s .c o m
 *     {
 *         "manCmd": "find",
 *         "manHTML": "...."
 *     }, ....
 * ]
 * </pre>, returns an empty list if not found
 */
public List<JSONObject> getMansByCmdPrefix(final String cmdPrefix) {
    final JSONObject toSearch = new JSONObject();
    toSearch.put(Common.MAN_CMD, cmdPrefix);

    final int index = Collections.binarySearch(CMD_MANS, toSearch, (o1, o2) -> {
        String c1 = o1.optString(Common.MAN_CMD);
        final String c2 = o2.optString(Common.MAN_CMD);

        if (c1.length() < c2.length()) {
            return c1.compareToIgnoreCase(c2);
        }

        c1 = c1.substring(0, c2.length());

        return c1.compareToIgnoreCase(c2);
    });

    final List<JSONObject> ret = new ArrayList<>();

    if (index < 0) {
        return ret;
    }

    int start = index;
    int end = index;

    while (start > -1 && CMD_MANS.get(start).optString(Common.MAN_CMD).startsWith(cmdPrefix.toLowerCase())) {
        start--;
    }

    start++;

    final int WINDOW_SIZE = 8;

    if (start < index - WINDOW_SIZE) {
        end = start + WINDOW_SIZE;
    } else {
        while (end < CMD_MANS.size() && end < index + 5
                && CMD_MANS.get(end).optString(Common.MAN_CMD).startsWith(cmdPrefix.toLowerCase())) {
            end++;

            if (end >= start + WINDOW_SIZE) {
                break;
            }
        }
    }

    return CMD_MANS.subList(start, end);
}

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

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    List dataSourceGroups = new ArrayList();
    List dataSources = new ArrayList();

    List privateResources = getContainerWrapper().getPrivateDataSources();
    List 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() {
        public int compare(Object o1, Object o2) {
            String jdbcURL1 = ((DataSourceInfo) o1).getJdbcURL();
            String jdbcURL2 = ((DataSourceInfo) o2).getJdbcURL();

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

            return jdbcURL1.compareToIgnoreCase(jdbcURL2);
        }/* ww w .  j  ava 2s .c  o  m*/
    });

    // group datasources by JDBC URL and calculate aggregated totals
    DataSourceInfoGroup dsGroup = null;
    for (Iterator i = dataSources.iterator(); i.hasNext();) {
        DataSourceInfo ds = (DataSourceInfo) i.next();

        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:org.kalypso.model.wspm.pdb.internal.wspm.DocumentPictureComparator.java

/**
 * Sorts by extension, than by filename.
 *//*from ww  w. j a va  2  s. com*/
private int compareByFilename(final Document o1, final Document o2) {
    final String filename1 = o1.getFilename();
    final String filename2 = o2.getFilename();

    final String ext1 = FilenameUtils.getExtension(filename1);
    final String ext2 = FilenameUtils.getExtension(filename2);

    if (ObjectUtils.equals(ext1, ext2))
        return filename1.compareToIgnoreCase(filename2);

    return ext1.compareTo(ext2);
}