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:fr.paris.lutece.portal.service.portal.ThemesService.java

/**
 * Get the theme code depending of the different priorities. The priorities are :
 * <ol>/* w ww.  ja  va2  s  . co m*/
 * <li>the theme of test (in case you want to test a page with a specific theme)</li>
 * <li>the theme choosen by the user</li>
 * <li>the global theme : the one choosen in the back office for the whole site</li>
 * <li>the page theme : a theme specified for a page</li>
 * </ol>
 *
 * @param data The PageData object
 * @param request The HttpServletRequest
 * @return the theme
 */
public static Theme getTheme(PageData data, HttpServletRequest request) {
    String strTheme = StringUtils.EMPTY;

    // The code_theme of the page
    String strPageTheme = data.getTheme();

    if ((strPageTheme != null) && (strPageTheme.compareToIgnoreCase(GLOBAL_THEME) != 0)) {
        strTheme = strPageTheme;
    }

    // The theme of the user
    String strUserTheme = getUserTheme(request);

    if (strUserTheme != null) {
        strTheme = strUserTheme;
    }

    // the test theme (choosen for a page to test the different theme from the backoffice theme section)
    String themeTest = request.getParameter(THEME_TEST);

    if (themeTest != null) {
        strTheme = themeTest;
    }

    Theme theme = getGlobalTheme(strTheme);

    return theme;
}

From source file:com.highcharts.export.controller.ExportController.java

private static String sanitize(String parameter) {
    if (parameter == null || parameter.trim().isEmpty() || parameter.compareToIgnoreCase("undefined") == 0
            || parameter.compareTo("null") == 0 || parameter.compareTo("{}") == 0) {
        return null;
    }/*from w w  w .j  av  a2 s.  c o m*/
    return parameter.trim();
}

From source file:ca.uqac.info.trace.execution.BabelTrace.java

/**
 * Gets the proper instance of the {@link Execution} class, based
 * on a string representing the target tool. Currently the following
 * tools are supported://from   w ww  . j  a  va2 s  . c o m
 * <ul>
 * <li>BeepBeep</li>
 * <li>Filter</li>
 * <li>ltlfo2mon</li>
 * <li>Maude</li>
 * <li>Monpoly</li>
 * <li>MySQL</li>
 * <li>NuSMV</li>
 * <li>PromLTL</li>
 * <li>Saxon</li>
 * <li>Spin</li>
 * </ul> 
 * @param type The name of the tool to execute
 * @return The Execution, null if tool is unrecognized
 */
private static Execution getExecution(String type) {
    Execution tr = null;
    if (type.compareToIgnoreCase("maude") == 0)
        tr = new MaudeExecution();
    else if (type.compareToIgnoreCase("beepbeep") == 0)
        tr = new BeepBeepExecution();
    else if (type.compareToIgnoreCase("filter") == 0)
        tr = new FilterExecution();
    else if (type.compareToIgnoreCase("mysql") == 0)
        tr = new MySQLExecution();
    else if (type.compareToIgnoreCase("mysql-innodb") == 0)
        tr = new MySQLExecution();
    else if (type.compareToIgnoreCase("mysql-memory") == 0)
        tr = new MySQLExecution();
    else if (type.compareToIgnoreCase("mysql-opt") == 0)
        tr = new MySQLExecution();
    else if (type.compareToIgnoreCase("nusmv") == 0)
        tr = new NuSmvExecution();
    else if (type.compareToIgnoreCase("saxon") == 0)
        tr = new SaxonExecution();
    else if (type.compareToIgnoreCase("spin") == 0)
        tr = new SpinExecution();
    else if (type.compareToIgnoreCase("monpoly") == 0)
        tr = new MonpolyExecution();
    else if (type.compareToIgnoreCase("promltl") == 0)
        tr = new PromLTLExecution();
    else if (type.compareToIgnoreCase("ltlfo2mon") == 0)
        tr = new Ltlfo2monExecution();
    else if (type.compareToIgnoreCase("newbeepbeep") == 0)
        tr = new NewBeepBeepExecution();
    return tr;
}

From source file:ca.uqac.info.trace.execution.BabelTrace.java

/**
 * Gets the proper instance of the {@link TraceTranslator} class, based
 * on a string representing the target tool. Currently the following
 * tools are supported:/*from  w  w  w .jav  a  2s .c  om*/
 * <ul>
 * <li>BeepBeep (0.9 and 1.5)</li>
 * <li>Filter</li>
 * <li>ltlfo2mon</li>
 * <li>Maude</li>
 * <li>Monpoly</li>
 * <li>MySQL</li>
 * <li>NuSMV</li>
 * <li>PromLTL</li>
 * <li>Saxon</li>
 * <li>Spin</li>
 * </ul> 
 * @param type The name of the target tool
 * @return The translator, null if tool is unrecognized
 */
private static Translator getTraceTranslator(String type) {
    Translator tr = null;
    if (type.compareToIgnoreCase("maude") == 0)
        tr = new MaudeTranslator();
    else if (type.compareToIgnoreCase("beepbeep") == 0)
        tr = new BeepBeepTranslator();
    else if (type.compareToIgnoreCase("filter") == 0)
        tr = new FilterTranslator();
    else if (type.compareToIgnoreCase("mysql-opt") == 0)
        tr = new MySQLTranslatorOptimized();
    else if (type.compareToIgnoreCase("mysql") == 0)
        tr = new MySQLTranslator();
    else if (type.compareToIgnoreCase("mysql-innodb") == 0) {
        MySQLTranslator mtr = new MySQLTranslator();
        mtr.setEngine("InnoDB");
        tr = mtr;
    } else if (type.compareToIgnoreCase("mysql-memory") == 0) {
        MySQLTranslator mtr = new MySQLTranslator();
        mtr.setEngine("MEMORY");
        tr = mtr;
    } else if (type.compareToIgnoreCase("nusmv") == 0)
        tr = new SmvTranslator();
    else if (type.compareToIgnoreCase("saxon") == 0)
        tr = new SaxonTranslator();
    else if (type.compareToIgnoreCase("spin") == 0)
        tr = new PromelaTranslator();
    else if (type.compareToIgnoreCase("monpoly") == 0)
        tr = new MonpolyTranslator();
    else if (type.compareToIgnoreCase("promltl") == 0)
        tr = new XesTranslator();
    else if (type.compareToIgnoreCase("ltlfo2mon") == 0)
        tr = new Ltlfo2monTranslator();
    else if (type.compareToIgnoreCase("newbeepbeep") == 0)
        tr = new NewBeepBeepTranslator();
    return tr;
}

From source file:com.krawler.esp.portalmsg.forummsgcomm.java

public static String getPostTitle(Connection conn, String topicId, String flag) {
    String postDetails = "";
    String ptext = "";
    String query = "";
    JSONObject jobj = new JSONObject();
    DbResults rs = null;//  w  ww  .  j a  va2 s  . c  o m
    try {
        if (flag.compareToIgnoreCase("forum") == 0) {
            query = "SELECT post_text FROM krawlerforum_topics where topic_id=?";
            rs = DbUtil.executeQuery(conn, query, topicId);

            if (rs.next()) {
                com.krawler.utils.json.base.JSONObject jtemp = new com.krawler.utils.json.base.JSONObject();
                ptext = java.net.URLEncoder.encode(rs.getString(1));
                jtemp.put("Details", ptext);
                jtemp.put("ID", topicId);
                jtemp.put("flag", "Forum");
                jobj.append("data", jtemp);

            } else {

                query = "SELECT post_text FROM krawlerforum_posts where post_id=?";
                rs = DbUtil.executeQuery(conn, query, topicId);

                if (rs.next()) {
                    com.krawler.utils.json.base.JSONObject jtemp = new com.krawler.utils.json.base.JSONObject();
                    ptext = java.net.URLEncoder.encode(rs.getString(1));
                    jtemp.put("Details", ptext);
                    jtemp.put("ID", topicId);
                    jtemp.put("flag", "Forum");
                    jobj.append("data", jtemp);
                }
            }
        }

    } catch (JSONException e) {
        DbPool.quietRollback(conn);

    } catch (ServiceException e) {
        DbPool.quietRollback(conn);

    } finally {
        DbPool.quietClose(conn);
    }
    return postDetails;
}

From source file:com.qingstor.sdk.utils.QSJSONUtil.java

public static List sortJSONArray(JSONArray array) {
    LinkedList llist = new LinkedList();
    try {/*from   ww w .j  a  v a  2 s .  c o m*/
        for (int i = 0, c = array.length(); i < c; i++) {
            llist.add(array.getString(i));
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    Collections.sort((List<String>) llist, new Comparator<String>() {
        @Override
        public int compare(String s1, String s2) {
            return s2.compareToIgnoreCase(s1);
        }
    });
    return llist;
}

From source file:net.sf.jabref.gui.ContentSelectorDialog2.java

private static int findPos(DefaultListModel<String> lm, String item) {
    for (int i = 0; i < lm.size(); i++) {
        String s = lm.get(i);/* w  ww  . ja  va  2s .com*/
        if (item.compareToIgnoreCase(s) < 0) { // item precedes s
            return i;
        }
    }
    return lm.size();
}

From source file:org.toobsframework.util.string.StringResource.java

/**
 * Extends a string to HTML, but also takes care that the string can be placed as javascript
 * @param s is the string to be converted
 * @param strUseJS to be converted for javascript
 * @return the converted string/*w  w w. j  ava 2s.  c o m*/
 */
public static String extendedAsHTML(String s, String strUseJS) {
    StringBuffer str = new StringBuffer();
    int len = (s != null) ? s.length() : 0;

    // In the case where the useJS flag is one, we cannot turn special chars into #format
    // And we have to escape and double single quotes
    if (strUseJS.compareToIgnoreCase("TRUE") == 0) {
        for (int i = 0; i < len; i++) {
            char ch = s.charAt(i);

            if (ch == '\'') {
                str.append('\\');
                str.append('\'');
            } else if (ch == '"') {
                str.append('\\');
            }
            str.append(ch);
        }
    } else {
        for (int i = 0; i < len; i++) {
            char ch = s.charAt(i);

            if (ch == '\'') {
                str.append('\'');
            }

            //if (Character.UnicodeBlock.of(ch).equals(Character.UnicodeBlock.BASIC_LATIN)) {
            str.append(ch);
            //} else {
            //  str.append("&#");
            //  str.append(Integer.toString((int) ch));
            //  str.append(';');
            //}
        }
    }

    return str.toString();
}

From source file:com.sfs.Formatter.java

/**
 * Convert boolean./* w  w w. j av  a2s  .co m*/
 *
 * @param value the value
 *
 * @return the string
 */
public static String convertBoolean(final String value) {
    if (value != null) {
        if (value.compareToIgnoreCase("true") == 0) {
            return "Yes";
        }
    }
    return "No";
}

From source file:org.openmrs.module.laboratory.web.util.LaboratoryUtil.java

private static List<Obs> getOrderedObs(Encounter encounter) {
    List<Obs> obs = new ArrayList<Obs>();
    obs.addAll(encounter.getAllObs());//from w ww .  jav  a2 s. co m
    Collections.sort(obs, new Comparator<Obs>() {

        public int compare(Obs o1, Obs o2) {
            String o1n = o1.getConcept().getName().getName();
            String o2n = o2.getConcept().getName().getName();
            return o1n.compareToIgnoreCase(o2n);
        }
    });
    return obs;
}