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.sentaroh.android.SMBSync2.SyncTaskUtility.java

static public void sortSyncTaskList(ArrayList<SyncTaskItem> items) {
    Collections.sort(items, new Comparator<SyncTaskItem>() {
        @Override/*from w ww .  java 2  s. co m*/
        public int compare(SyncTaskItem l_item, SyncTaskItem r_item) {

            if (l_item.getSyncTaskPosition() == r_item.getSyncTaskPosition())
                return l_item.getSyncTaskName().compareToIgnoreCase(r_item.getSyncTaskName());
            else {
                String l_key = String.format("%3d", l_item.getSyncTaskPosition()) + l_item.getSyncTaskName();
                String r_key = String.format("%3d", r_item.getSyncTaskPosition()) + r_item.getSyncTaskName();
                return l_key.compareToIgnoreCase(r_key);
            }
        }
    });
    for (int i = 0; i < items.size(); i++)
        items.get(i).setSyncTaskPosition(i);
}

From source file:com.sfs.whichdoctor.search.TagSearchDAOImpl.java

/**
 * Perform a search for tags./*from ww w  .jav a  2 s.  c o  m*/
 *
 * @param objecttype the objecttype
 * @param order Order options are: alpha (alphabetical), count (tag count)
 * @param user the user
 *
 * @return the map< string, collection< tag bean>>
 *
 * @throws WhichDoctorSearchDaoException the which doctor search dao
 *             exception
 */
@SuppressWarnings("unchecked")
public final Map<String, Collection<TagBean>> search(final String objecttype, final String order,
        final UserBean user) throws WhichDoctorSearchDaoException {

    if (objecttype == null) {
        throw new WhichDoctorSearchDaoException("An object type must be " + "specified for a tag search");
    }

    Map<String, Collection<TagBean>> results = new HashMap<String, Collection<TagBean>>();

    // Holds a running total of the maximum tag count for each tag type
    HashMap<String, Integer> maxTagCount = new HashMap<String, Integer>();

    String searchSQL = this.getSQL().getValue("tag/search");

    /* Default order is alphabetical */
    if (StringUtils.equalsIgnoreCase(order, "count")) {
        searchSQL += " ORDER BY TagCount DESC";
    } else {
        searchSQL += " ORDER BY TagName ASC";
    }

    dataLogger.info("Performing tag search");

    Collection<TagBean> tagResults = new ArrayList<TagBean>();

    try {
        tagResults = this.getJdbcTemplateReader().query(searchSQL,
                new Object[] { objecttype, "Private", "Private", user.getDN() }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        TagBean tag = new TagBean();
                        tag.setTagName(rs.getString("TagName"));
                        tag.setTagType(rs.getString("TagType"));
                        tag.setTagCount(rs.getInt("TagCount"));

                        return tag;
                    }
                });
    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for search: " + ie.getMessage());
    }

    for (TagBean tag : tagResults) {
        Collection<TagBean> tags = new ArrayList<TagBean>();
        if (results.containsKey(tag.getTagType())) {
            // Get existing array from
            tags = results.get(tag.getTagType());
        }

        if (maxTagCount.containsKey(tag.getTagType())) {
            Integer maxCount = maxTagCount.get(tag.getTagType());
            if (tag.getTagCount() > maxCount) {
                maxTagCount.put(tag.getTagType(), tag.getTagCount());
            }
        } else {
            maxTagCount.put(tag.getTagType(), new Integer(tag.getTagCount()));
        }
        tags.add(tag);

        results.put(tag.getTagType(), tags);
    }

    /* Iterate through results setting max tag count */
    for (String key : results.keySet()) {
        Integer maxCount = maxTagCount.get(key);

        Collection<TagBean> tempTags = results.get(key);
        Collection<TagBean> tags = new ArrayList<TagBean>();

        for (TagBean tag : tempTags) {
            tag.setMaxCount(maxCount);
            tags.add(tag);
        }
        results.put(key, tags);
    }

    /* Load all tags */
    String searchAllSQL = getSQL().getValue("tag/searchAll");

    if (order.compareToIgnoreCase("count") == 0) {
        searchAllSQL += " ORDER BY TagCount DESC";
    } else {
        searchAllSQL += " ORDER BY TagName ASC";
    }

    Collection<TagBean> allTagResults = new ArrayList<TagBean>();
    try {
        allTagResults = this.getJdbcTemplateReader().query(searchAllSQL,
                new Object[] { objecttype, "Private", "Private", user.getDN() }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        TagBean tag = new TagBean();
                        tag.setTagName(rs.getString("TagName"));
                        tag.setTagType("All");
                        tag.setTagCount(rs.getInt("TagCount"));

                        return tag;
                    }
                });
    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for search: " + ie.getMessage());
    }

    int maxAllTagCount = 0;
    for (TagBean tag : allTagResults) {
        if (tag.getTagCount() > maxAllTagCount) {
            maxAllTagCount = tag.getTagCount();
        }
    }

    Collection<TagBean> allTags = new ArrayList<TagBean>();

    for (TagBean tag : allTagResults) {
        tag.setMaxCount(maxAllTagCount);
        allTags.add(tag);
    }

    if (allTags.size() > 0) {
        // At least one tag has been found, add it to results
        results.put("All", allTags);
    }
    return results;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static boolean isNull(String value) {
    if (value == null || value.compareToIgnoreCase("null") == 0)
        return true;
    return false;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static boolean isNullOrBlank(String value) {
    if (value == null || value.compareToIgnoreCase("null") == 0 || value.compareTo("") == 0)
        return true;
    return false;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static String getCodingSchemeURIAndVersion(String codingSchemeName, String ltag) {
    if (codingSchemeName == null)
        return null;
    try {/* w  w  w .j  a  va2  s. co  m*/
        LexBIGService lbSvc = RemoteServerUtil.createLexBIGService();
        CodingSchemeRenderingList lcsrl = lbSvc.getSupportedCodingSchemes();
        CodingSchemeRendering[] csra = lcsrl.getCodingSchemeRendering();
        for (int i = 0; i < csra.length; i++) {
            CodingSchemeRendering csr = csra[i];
            CodingSchemeSummary css = csr.getCodingSchemeSummary();
            if (css.getFormalName().compareTo(codingSchemeName) == 0
                    || css.getLocalName().compareTo(codingSchemeName) == 0) {
                if (ltag == null)
                    return css.getCodingSchemeURI() + "|" + css.getRepresentsVersion();
                RenderingDetail rd = csr.getRenderingDetail();
                CodingSchemeTagList cstl = rd.getVersionTags();
                java.lang.String[] tags = cstl.getTag();
                for (int j = 0; j < tags.length; j++) {
                    String version_tag = (String) tags[j];
                    if (version_tag.compareToIgnoreCase(ltag) == 0) {
                        return css.getCodingSchemeURI() + "|" + css.getRepresentsVersion();
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static String getVocabularyVersionByTag(String codingSchemeName, String ltag) {

    if (codingSchemeName == null)
        return null;
    String version = null;//w  ww  . j  ava 2  s.  c o  m
    int knt = 0;
    try {
        LexBIGService lbSvc = RemoteServerUtil.createLexBIGService();
        CodingSchemeRenderingList lcsrl = lbSvc.getSupportedCodingSchemes();
        CodingSchemeRendering[] csra = lcsrl.getCodingSchemeRendering();
        for (int i = 0; i < csra.length; i++) {
            CodingSchemeRendering csr = csra[i];
            CodingSchemeSummary css = csr.getCodingSchemeSummary();
            if (css.getFormalName().compareTo(codingSchemeName) == 0
                    || css.getLocalName().compareTo(codingSchemeName) == 0) {
                version = css.getRepresentsVersion();
                knt++;

                if (ltag == null)
                    return version;
                RenderingDetail rd = csr.getRenderingDetail();
                CodingSchemeTagList cstl = rd.getVersionTags();
                java.lang.String[] tags = cstl.getTag();
                // KLO, 102409
                /*
                if (tags == null)
                return version;
                */

                if (tags != null && tags.length > 0) {
                    for (int j = 0; j < tags.length; j++) {
                        String version_tag = (String) tags[j];
                        if (version_tag.compareToIgnoreCase(ltag) == 0) {
                            return version;
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        // e.printStackTrace();
    }

    if (ltag != null && ltag.compareToIgnoreCase("PRODUCTION") == 0 & knt == 1) {
        _logger.debug("\tUse " + version + " as default.");
        return version;
    }
    return null;
}

From source file:io.manasobi.utils.StringUtils.java

/**
 * ?  ?     ?.<br><br>//  ww w.  j  av  a 2 s.c  o  m
 *
 * StringUtils.compareToIgnoreCase("anyframe java test", "Anyframe Java Test") = 0
 *
 * @param sourceStr 1
 * @param anotherStr 2
 * @return ?  ?  0
 *         1? 2 ?  0 
 *         1? 2 ?  0 
 * @see String#compareToIgnoreCase(String)
 */
public static int compareToIgnoreCase(String sourceStr, String anotherStr) {
    if (sourceStr == null || anotherStr == null) {
        return -1;
    }
    return sourceStr.compareToIgnoreCase(anotherStr);
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static Vector getPropertyNamesByType(Entity concept, String property_type) {
    Vector v = new Vector();
    org.LexGrid.commonTypes.Property[] properties = null;

    if (property_type.compareToIgnoreCase("GENERIC") == 0) {
        properties = concept.getProperty();
    } else if (property_type.compareToIgnoreCase("PRESENTATION") == 0) {
        properties = concept.getPresentation();
    } else if (property_type.compareToIgnoreCase("COMMENT") == 0) {
        properties = concept.getComment();
    } else if (property_type.compareToIgnoreCase("DEFINITION") == 0) {
        properties = concept.getDefinition();
    }/*ww w . j av a 2s .com*/

    if (properties == null || properties.length == 0)
        return v;
    HashSet hset = new HashSet();
    for (int i = 0; i < properties.length; i++) {
        Property p = (Property) properties[i];
        String nm = p.getPropertyName();
        if (!hset.contains(nm)) {
            hset.add(nm);
            v.add(p.getPropertyName());
        }
    }
    hset.clear();
    return v;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

private static String getSourceQualifierValue(Property p) {
    if (p == null)
        return null;
    PropertyQualifier[] qualifiers = p.getPropertyQualifier();
    if (qualifiers != null && qualifiers.length > 0) {
        for (int j = 0; j < qualifiers.length; j++) {
            PropertyQualifier q = qualifiers[j];
            String qualifier_name = q.getPropertyQualifierName();
            String qualifier_value = q.getValue().getContent();

            if (qualifier_name.compareToIgnoreCase("source") == 0) {
                return qualifier_value;
            }/*from w  w w .j  a  v  a2 s  .c  om*/
        }
    }
    return null;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static void sortArray(ArrayList list) {
    String tmp;/* w w  w.  j  a  va  2 s. c om*/
    if (list.size() <= 1)
        return;
    for (int i = 0; i < list.size(); i++) {
        String s1 = (String) list.get(i);
        for (int j = i + 1; j < list.size(); j++) {
            String s2 = (String) list.get(j);
            if (s1.compareToIgnoreCase(s2) > 0) {
                tmp = s1;
                list.set(i, s2);
                list.set(j, tmp);
            }
        }
    }
}