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:de.blizzy.documentr.markdown.macro.GroovyMacroScanner.java

List<String> listMacros() {
    List<File> files = Lists.newArrayList(findGroovyMacroFiles());
    Function<File, String> function = new Function<File, String>() {
        @Override//from www . j a v  a  2  s. c o m
        public String apply(File file) {
            return StringUtils.substringBeforeLast(file.getName(), ".groovy"); //$NON-NLS-1$
        }
    };
    List<String> result = Lists.newArrayList(Lists.transform(files, function));
    Collections.sort(result, new Comparator<String>() {
        @Override
        public int compare(String name1, String name2) {
            return name1.compareToIgnoreCase(name2);
        }
    });
    return result;
}

From source file:org.arakhne.afc.ui.android.filechooser.AsyncFileLoader.java

/**
 * {@inheritDoc}/*from  w  w  w  .ja v a2 s . c  o m*/
 */
@Override
public List<File> loadInBackground() {
    File[] array;
    if (this.filter != null) {
        array = this.path.listFiles(this.filter);
    } else {
        array = this.path.listFiles();
    }
    List<File> list = new ArrayList<>(array.length);
    // Dichotomic insertion
    Comparator<File> comparator = new Comparator<File>() {
        @Override
        public int compare(File lhs, File rhs) {
            String ln = lhs.getName();
            String rn = rhs.getName();
            return ln.compareToIgnoreCase(rn);
        }
    };
    for (File file : array) {
        if (!isHiddenFile(file)) {
            ListUtil.add(list, comparator, file, false, true);
        }
    }
    return list;
}

From source file:org.coltram.nsd.communication.ProxyMessenger.java

private String tryToAvoidLocalHost(String s) {
    if (s.compareToIgnoreCase("localhost") == 0)
        return LocalHost.name;
    return s;//w w  w .j  ava  2 s  . c  om
}

From source file:org.openmrs.module.pmtct.web.view.chart.InfantPCRPieChartView.java

/**
 * @see org.openmrs.module.pmtct.web.view.chart.AbstractChartView#createChart(java.util.Map,
 *      javax.servlet.http.HttpServletRequest)
 *//*from   w w w.j  a  v  a2 s  . co m*/
@Override
protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) {
    UserContext userContext = Context.getUserContext();
    ApplicationContext appContext = ContextProvider.getApplicationContext();
    PMTCTModuleTag tag = new PMTCTModuleTag();

    List<Object> res = new ArrayList<Object>();

    DefaultPieDataset pieDataset = new DefaultPieDataset();
    String title = "", descriptionTitle = "", dateInterval = "";
    Concept concept = null;
    SimpleDateFormat df = Context.getDateFormat();

    //            Date myDate1 = new Date("1/1/" + ((new Date()).getYear() + 1900));
    //            String startDate1 = df.format(myDate1);

    Date today = new Date();
    Date oneYearFromNow = new Date(new Date().getTime() - PMTCTConstants.YEAR_IN_MILLISECONDS);

    String endDate1 = df.format(today);
    String startDate1 = df.format(oneYearFromNow);

    dateInterval = "(" + new SimpleDateFormat("dd-MMM-yyyy").format(oneYearFromNow) + " - "
            + new SimpleDateFormat("dd-MMM-yyyy").format(today) + ")";

    try {

        PmtctService pmtct;
        pmtct = Context.getService(PmtctService.class);
        try {
            res = pmtct.getGeneralStatForInfantTests_Charting_PCR(startDate1, endDate1);
        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        List<String> hivTestResultOptions = new ArrayList<String>();

        List<Integer> pcr_hivTestResultValues = new ArrayList<Integer>();

        Collection<ConceptAnswer> answers = Context.getConceptService()
                .getConcept(PMTCTConstants.RESULT_OF_HIV_TEST).getAnswers();
        for (ConceptAnswer str : answers) {
            hivTestResultOptions.add(str.getAnswerConcept().getName().getName());

            pcr_hivTestResultValues.add(0);
        }
        hivTestResultOptions.add("Others");
        pcr_hivTestResultValues.add(0);

        for (Object ob : res) {
            int val = 0;
            String temp = "", pcr_hivTestResult = "";

            temp = "" + ((Object[]) ob)[2];
            val = (temp.compareTo("") == 0) ? 0 : Integer.parseInt(temp);
            if (val > 0)
                pcr_hivTestResult = tag.getConceptNameById(temp);

            int i = 0;
            boolean pcr_found = false;
            for (String s : hivTestResultOptions) {
                if ((s.compareToIgnoreCase(pcr_hivTestResult)) == 0) {
                    pcr_hivTestResultValues.set(i, pcr_hivTestResultValues.get(i) + 1);
                    pcr_found = true;
                }
                i++;
            }

            if (!pcr_found) {
                pcr_hivTestResultValues.set(pcr_hivTestResultValues.size() - 1,
                        pcr_hivTestResultValues.get(pcr_hivTestResultValues.size() - 1) + 1);
            }
        }

        int i = 0;
        for (String s : hivTestResultOptions) {
            if (pcr_hivTestResultValues.get(i) > 0) {
                Float percentage = new Float(100 * pcr_hivTestResultValues.get(i) / res.size());
                pieDataset.setValue(s + " (" + pcr_hivTestResultValues.get(i) + " , " + percentage + "%)",
                        percentage);
            }
            i++;
        }

        title = appContext.getMessage("pmtct.menu.infantTest", null, userContext.getLocale());
        concept = null;
        descriptionTitle = Context.getEncounterService()
                .getEncounterType(PMTCTConfigurationUtils.getPCRTestEncounterTypeId()).getName();
        descriptionTitle += dateInterval;
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    JFreeChart chart = ChartFactory.createPieChart(title + " : "
            + ((null != concept) ? concept.getPreferredName(userContext.getLocale()) : descriptionTitle),
            pieDataset, true, true, false);

    return chart;
}

From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.SubjectsActivity.java

public void onClickChart(View v) {
    String sTag = (String) v.getTag();

    if (sTag.compareToIgnoreCase(getString(R.string.linechart)) == 0) {
        LineChart chart = new LineChart();
        Intent intent = null;/*  w w w .  jav  a 2  s  . c  o  m*/
        intent = chart.execute(this);
        startActivity(intent);

    } else if (sTag.compareToIgnoreCase(getString(R.string.stackedchart)) == 0) {

        CombiLineChart barChart = new CombiLineChart();
        //SocialStackedBarChart barChart = new SocialStackedBarChart();
        Intent intent = null;
        intent = barChart.execute(this);
        startActivity(intent);

        //         if(Session.getSingleInstance().getUserType() == Constants.USER_TYPE_SOCIAL){
        //            // Social treatment
        //            SocialLineChart barChart = new SocialLineChart();
        //            //SocialStackedBarChart barChart = new SocialStackedBarChart();
        //            Intent intent = null;
        //            intent = barChart.execute(this);
        //            startActivity(intent);            
        //         }else{
        //            // Yardstick treatment
        //            YardLineChart barChart = new YardLineChart();
        //            //StackedBarChart barChart = new StackedBarChart();
        //            Intent intent = null;
        //            intent = barChart.execute(this);
        //            startActivity(intent);                        
        //         }

    } else if (sTag.compareToIgnoreCase(getString(R.string.piechart)) == 0) {
        Intent intent = new Intent(this, PieChartActivity.class);
        startActivity(intent);

    } else if (sTag.compareToIgnoreCase(getString(R.string.doughnutchart)) == 0) {
        DoughnutChart doughnutChart = new DoughnutChart();
        Intent intent = null;
        intent = doughnutChart.execute(this);
        startActivity(intent);

    } else if (sTag.compareToIgnoreCase(getString(R.string.scatterchart)) == 0) {
        ScatterChart chart = new ScatterChart();
        Intent intent = null;
        intent = chart.execute(this);
        startActivity(intent);

    } else if (sTag.compareToIgnoreCase(getString(R.string.socialchart)) == 0) {
        SocialStackedBarChart barChart = new SocialStackedBarChart();
        Intent intent = null;
        intent = barChart.execute(this);
        startActivity(intent);

    }

}

From source file:br.bireme.prvtrm.PreviousTermServlet.java

/**
 * Processes requests for both HTTP/*from ww  w  .j  a  v  a 2 s  .c o m*/
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/json; charset=UTF-8");
    final PrintWriter out = response.getWriter();

    try {
        final String init = request.getParameter("init");
        if (init == null) {
            throw new ServletException("missing 'init' parameter");
        }

        int maxSize = previous.getMaxSize();
        String maxTerms = request.getParameter("maxTerms");
        if (maxTerms != null) {
            maxSize = Integer.parseInt(maxTerms);
        }

        List<String> fields = previous.getFields();
        String fldsParam = request.getParameter("fields");
        if (fldsParam != null) {
            fields = Arrays.asList(fldsParam.split("[,;\\-]"));
        }

        final List<String> terms;
        String direction = request.getParameter("direction");
        if ((direction == null) || (direction.compareToIgnoreCase("next") == 0)) {
            terms = previous.getNextTerms(init, fields, maxSize);
            direction = "next";
        } else {
            terms = previous.getPreviousTerms(init, fields, maxSize);
            direction = "previous";
        }

        final JSONObject jobj = new JSONObject();
        final JSONArray jlistTerms = new JSONArray();
        final JSONArray jlistFields = new JSONArray();

        jlistTerms.addAll(terms);
        jlistFields.addAll(fields);
        jobj.put("init", init);
        jobj.put("direction", direction);
        jobj.put("maxTerms", maxSize);
        jobj.put("fields", jlistFields);
        jobj.put("terms", jlistTerms);

        out.println(jobj.toJSONString());
    } finally {
        out.close();
    }
}

From source file:org.polymap.rhei.um.ui.UsersTableViewer.java

public UsersTableViewer(Composite parent, final Iterable<User> content, int style) {
    super(parent, SWT.VIRTUAL /*| SWT.V_SCROLL | SWT.FULL_SELECTION |*/ | style);
    this.repo = UserRepository.instance();
    this.content = content;

    ColumnViewerToolTipSupport.enableFor(this);
    getTable().setLinesVisible(true);/*from   w ww.  j  a v a2 s . c o m*/
    getTable().setHeaderVisible(true);
    getTable().setLayout(new TableLayout());

    TableViewerColumn vcolumn = new TableViewerColumn(this, SWT.CENTER);
    vcolumn.getColumn().setResizable(true);
    vcolumn.getColumn().setText("Name");
    final ColumnLabelProvider nameLabelProvider = new ColumnLabelProvider() {
        public String getText(Object elm) {
            User user = (User) elm;
            String firstname = user.firstname().get();
            return firstname != null && firstname.length() > 0 ? user.name().get() + ", " + firstname
                    : user.name().get();
        }
    };
    vcolumn.setLabelProvider(nameLabelProvider);
    ((TableLayout) getTable().getLayout()).addColumnData(new ColumnWeightData(2, 100, true));
    setComparator(new ViewerComparator() {
        public int compare(Viewer viewer, Object e1, Object e2) {
            String name1 = nameLabelProvider.getText(e1);
            String name2 = nameLabelProvider.getText(e2);
            return name1.compareToIgnoreCase(name2);
        }
    });
    getTable().setSortColumn(vcolumn.getColumn());
    getTable().setSortDirection(SWT.UP);

    vcolumn = new TableViewerColumn(this, SWT.LEFT);
    vcolumn.getColumn().setResizable(true);
    vcolumn.getColumn().setText("Adresse");
    vcolumn.setLabelProvider(new ColumnLabelProvider() {
        public String getText(Object elm) {
            Address address = ((User) elm).address().get();
            return Joiner.on(' ').skipNulls().join(address.postalCode().get(), address.city().get());
        }
    });
    ((TableLayout) getTable().getLayout()).addColumnData(new ColumnWeightData(2, 100, true));

    setContentProvider(new ArrayContentProvider());
    setInput(Iterables.toArray(content, User.class));

    //        setContentProvider( new DeferredContentProvider( new Comparator<User>() {
    //            public int compare( User left, User right ) {
    //                return left.name().get().compareToIgnoreCase( right.name().get() );
    //            }
    //        }));
    //        setInput( model = new SetModel() );
    //        
    //        // content loader
    //        new UIJob( "Nutzer laden" ) {
    //            protected void runWithException( IProgressMonitor monitor ) throws Exception {
    //                for (User user : content) {
    //                    Thread.sleep( 1000 );
    //                    model.addAll( new Object[] { user } );
    //                }
    //            }
    //        }.schedule();
    //        model.addAll( ImmutableList.copyOf( content ) );
}

From source file:org.thingml.loadbalancer.CloudNode.java

public void makeTestDir(File workingDir, File ressourcesDir, File compiler, File testJar, File testSrc)
        throws IOException {
    File testDir = new File(workingDir, name + testDirPostfix);
    if (testDir.exists()) {
        testDir.delete();/*from  w  w  w. j a  v a2s .co m*/
    }

    //Compiler
    testDir.mkdir();
    File cDir = new File(testDir, "compilers");
    cDir.mkdir();
    File regDir = new File(cDir, "registry");
    regDir.mkdir();
    File tarDir = new File(regDir, "target");
    tarDir.mkdir();
    File compLink = new File(tarDir, "compilers.registry-0.7.0-SNAPSHOT-jar-with-dependencies.jar");
    Files.createSymbolicLink(compLink.toPath(), compiler.toPath());

    //Plugins
    /*File pluginDir = new File(cDir, "official-network-plugins");
    pluginDir.mkdir();
    File targetDir = new File(pluginDir, "target");
    targetDir.mkdir();
    File pluginLink = new File(targetDir, "official-network-plugins-0.7.0-SNAPSHOT.jar");
    File pluginJar = new File(compiler.getParentFile().getParentFile().getPath() + "/official-network-plugins/target/official-network-plugins-0.7.0-SNAPSHOT.jar");
    Files.createSymbolicLink(pluginLink.toPath(), pluginJar.toPath());*/

    //Test Framework
    File tjDir = new File(testDir, "testJar");
    tjDir.mkdir();
    File tjtarDir = new File(tjDir, "target");
    tjtarDir.mkdir();
    File tJarLink = new File(tjtarDir, "testJar-0.7.0-SNAPSHOT-jar-with-dependencies.jar");
    Files.createSymbolicLink(tJarLink.toPath(), testJar.toPath());
    writeConfigFile(tjDir);

    File srcDir = new File(tjDir, "src");
    srcDir.mkdir();
    File mainDir = new File(srcDir, "main");
    mainDir.mkdir();
    File resourcesDir = new File(mainDir, "resources");
    resourcesDir.mkdir();
    File testSrcDir = new File(resourcesDir, "tests");
    testSrcDir.mkdir();

    for (File f : testSrc.listFiles()) {
        if (f.isDirectory() && (f.getName().compareTo("core") != 0)) {
            File dirCopy = new File(testSrcDir, f.getName());
            dirCopy.mkdir();
        }
    }

    File importLink = new File(testSrcDir, "Import/import");
    File importDir = new File(testSrc, "Import/import");
    Files.createSymbolicLink(importLink.toPath(), importDir.toPath());

    boolean found = false;
    for (String l : languages) {
        if (l.compareToIgnoreCase("arduino") == 0) {
            found = true;
            break;
        }
    }
    if (found) {
        File testArduinoLink = new File(resourcesDir, "testArduino.sh");
        File testArduino = new File(ressourcesDir, "testArduino.sh");
        Files.createSymbolicLink(testArduinoLink.toPath(), testArduino.toPath());
    }

    for (File t : tests) {
        File tLink = new File(testSrcDir, t.getParentFile().getName() + "/" + t.getName());
        Files.createSymbolicLink(tLink.toPath(), t.toPath());
    }

    File coreLink = new File(testSrcDir, "core");
    File coreDir = new File(testSrc, "core");
    Files.createSymbolicLink(coreLink.toPath(), coreDir.toPath());

    File dtLink = new File(testSrcDir, "datatypes.thingml");
    File dt = new File(testSrc, "datatypes.thingml");
    Files.createSymbolicLink(dtLink.toPath(), dt.toPath());

    File tmlLink = new File(testSrcDir, "thingml.thingml");
    File tml = new File(testSrc, "thingml.thingml");
    Files.createSymbolicLink(tmlLink.toPath(), tml.toPath());

}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_profile_page, container, false);
    //TextView textView = (TextView) rootView.findViewById(R.id.section_label);
    //textView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));
    RatingBar ratingBar = (RatingBar) rootView.findViewById(R.id.ratingBar);
    Button playStore = (Button) rootView.findViewById(R.id.btnGooglePlay);

    {/*from   w  w w  . ja  v  a2s  . c  o  m*/
        SharedPreferences store = getActivity().getSharedPreferences("RapidMathPref", 0);
        SharedPreferences.Editor editor = store.edit();
        String strProfileName = store.getString("strStarRating", "NotFound");

        if (strProfileName.compareToIgnoreCase("NotFound") == 0) {
            ratingBar.setVisibility(View.VISIBLE);
            playStore.setVisibility(View.GONE);

        } else {
            ratingBar.setVisibility(View.GONE);
            playStore.setVisibility(View.VISIBLE);

            playStore.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Uri uri = Uri.parse("market://details?id=com.mycodehurts.rapidmath.app");
                    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
                    try {
                        startActivity(goToMarket);
                    } catch (ActivityNotFoundException e) {
                        //Toast.makeText(this, "Could not launch Play store", Toast.LENGTH_LONG).show();
                    }
                }
            });

        }
        String strProfileNam = store.getString("strProfileName", "NotFound");

        if (strProfileNam.compareToIgnoreCase("NotFound") != 0) {
            TextView txtView = (TextView) rootView.findViewById(R.id.txtWelcomeName);
            txtView.setText("Welcome " + strProfileNam);

        }
    }

    //if rating value is changed,
    //display the current rating value in the result (textview) automatically
    ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
        public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {

            ((RMApplication) getActivity().getApplication()).getTracker(RMApplication.TrackerName.APP_TRACKER)
                    .send(new HitBuilders.EventBuilder().setCategory("Rating").setAction("StarRating")
                            .setValue((long) rating).build());

            Log.i("JS:", "Rating" + rating);

            ratingBar.setVisibility(View.GONE);
            Button playStore = (Button) getActivity().findViewById(R.id.btnGooglePlay);

            playStore.setVisibility(View.VISIBLE);

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

            if (strProfileName.compareToIgnoreCase("NotFound") == 0) {

                editor.putString("strStarRating", " " + rating);
                editor.commit();

            }

        }
    });
    Button gplus = (Button) rootView.findViewById(R.id.btnFB);

    gplus.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent shareIntent = new PlusShare.Builder(getActivity()).setType("text/plain").setText(
                    "RapidMath is a collection of techniques that help improve basic math skills. Download from here - \n"
                            + "https://play.google.com/store/apps/details?id=com.mycodehurts.rapidmath.app\n")
                    .setContentUrl(Uri.parse("https://developers.google.com/+/")).getIntent();

            startActivityForResult(shareIntent, 0);
        }
    });

    return rootView;
}

From source file:org.kuali.rice.location.framework.country.AbstractCountryValuesFinderBase.java

@Override
public List<KeyValue> getKeyValues() {
    Country defaultCountry = getDefaultCountry();
    List<Country> countries = new ArrayList<Country>(retrieveCountriesForValuesFinder());

    List<KeyValue> values = new ArrayList<KeyValue>(countries.size() + 1);
    values.add(new ConcreteKeyValue("", ""));
    if (defaultCountry != null) {
        values.add(new ConcreteKeyValue(defaultCountry.getCode(), defaultCountry.getName()));
    }// w  w w  .j av  a  2s .c o m

    Collections.sort(countries, new Comparator<Country>() {
        @Override
        public int compare(Country country1, Country country2) {
            // some institutions may prefix the country name with an asterisk if the country no longer exists
            // the country names will be compared without the asterisk
            String sortValue1 = StringUtils.trim(StringUtils.removeStart(country1.getName(), "*"));
            String sortValue2 = StringUtils.trim(StringUtils.removeStart(country2.getName(), "*"));
            return sortValue1.compareToIgnoreCase(sortValue2);
        }

    });

    // the default country may show up twice, but that's fine
    for (Country country : countries) {
        if (country.isActive()) {
            values.add(new ConcreteKeyValue(country.getCode(), country.getName()));
        }
    }
    return values;
}