Example usage for java.lang String CASE_INSENSITIVE_ORDER

List of usage examples for java.lang String CASE_INSENSITIVE_ORDER

Introduction

In this page you can find the example usage for java.lang String CASE_INSENSITIVE_ORDER.

Prototype

Comparator CASE_INSENSITIVE_ORDER

To view the source code for java.lang String CASE_INSENSITIVE_ORDER.

Click Source Link

Document

A Comparator that orders String objects as by compareToIgnoreCase .

Usage

From source file:com.xpn.xwiki.plugin.tag.TagQueryUtils.java

/**
 * Get cardinality map of tags matching a parameterized hql query.
 *
 * @param fromHql the <code>from</code> fragment of the hql query
 * @param whereHql the <code>where</code> fragment of the hql query
 * @param parameterValues list of parameter values for the query
 * @param context XWiki context.//from  w  ww  .  j a  v  a2s.  com
 * @return map of tags (alphabetical order) with their occurrences counts.
 * @throws XWikiException if search query fails (possible failures: DB access problems, etc).
 * @since 1.18
 * @see TagPluginApi#getTagCountForQuery(String, String, java.util.List)
 */
public static Map<String, Integer> getTagCountForQuery(String fromHql, String whereHql, List<?> parameterValues,
        XWikiContext context) throws XWikiException {
    List<String> results = null;
    Map<String, Integer> tagCount = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);

    String from = "select elements(prop.list) from XWikiDocument as doc, BaseObject as tagobject, "
            + "DBStringListProperty as prop";
    String where = " where tagobject.name=doc.fullName and tagobject.className='XWiki.TagClass' and "
            + "tagobject.id=prop.id.id and prop.id.name='tags'";

    // If at least one of the fragments is passed, the query should be matching XWiki documents
    if (!StringUtils.isBlank(fromHql) || !StringUtils.isBlank(whereHql)) {
        from += fromHql;
    }
    if (!StringUtils.isBlank(whereHql)) {
        where += " and " + whereHql;
    }

    List<?> params = parameterValues;
    if (params == null) {
        params = new ArrayList<String>();
    }
    String hql = from + where;

    try {
        Query query = context.getWiki().getStore().getQueryManager().createQuery(hql, Query.HQL);
        query.bindValues((List<Object>) params);
        query.addFilter(Utils.<QueryFilter>getComponent(QueryFilter.class, HiddenDocumentFilter.HINT));
        results = query.execute();
    } catch (QueryException e) {
        throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_UNKNOWN, String
                .format("Failed to get tag count for query [%s], with parameters [%s]", hql, params.toString()),
                e);
    }

    Collections.sort(results, String.CASE_INSENSITIVE_ORDER);
    Map<String, String> processedTags = new HashMap<String, String>();

    // We have to manually build a cardinality map since we have to ignore tags case.
    for (String result : results) {
        // This key allows to keep track of the case variants we've encountered.
        String lowerTag = result.toLowerCase();

        // We store the first case variant to reuse it in the final result set.
        if (!processedTags.containsKey(lowerTag)) {
            processedTags.put(lowerTag, result);
        }

        String tagCountKey = processedTags.get(lowerTag);
        int tagCountForTag = 0;
        if (tagCount.get(tagCountKey) != null) {
            tagCountForTag = tagCount.get(tagCountKey);
        }
        tagCount.put(tagCountKey, tagCountForTag + 1);
    }

    return tagCount;
}

From source file:org.graylog2.streams.StreamListFingerprint.java

private int comparisonResult(String id1, String id2) {
    return ComparisonChain.start().compare(id1, id2, String.CASE_INSENSITIVE_ORDER).compare(id1, id2).result();
}

From source file:com.evolveum.midpoint.web.component.assignment.AssignmentDto.java

@Override
public int compareTo(AssignmentDto other) {
    Validate.notNull(other, "Can't compare assignment editor dto with null.");

    String name1 = "";//getName() != null ? getName() : "";
    String name2 = "";//other.getName() != null ? other.getName() : "";

    return String.CASE_INSENSITIVE_ORDER.compare(name1, name2);
}

From source file:de.erdesignerng.dialect.DialectFactory.java

/**
 * /*from ww  w.  j  a v a2  s  .c o  m*/
 *<br />
 *@date 20161116 ?5:33:19
 *@author <a href="bentengwu@163.com">thender</a>
 *@return The Dialect supoorted in tool
 */
public List<Dialect> getSupportedDialects() {
    List<Dialect> theDialects = new ArrayList<>();
    theDialects.addAll(knownDialects.values());
    Collections.sort(theDialects, new BeanComparator("uniqueName", String.CASE_INSENSITIVE_ORDER));
    return theDialects;
}

From source file:it.unibz.instasearch.InstaSearchPlugin.java

/**
 * Array of working set names//ww  w  . j  a v a2 s.  c om
 * @return WorkingSets
 */
public static List<String> getWorkingSets() {
    ArrayList<String> workingSets = new ArrayList<String>();

    IWorkingSetManager wsManager = getDefault().getWorkbench().getWorkingSetManager();
    if (wsManager == null)
        return workingSets;

    for (IWorkingSet ws : wsManager.getWorkingSets()) {
        workingSets.add(ws.getName());
    }

    Collections.sort(workingSets, String.CASE_INSENSITIVE_ORDER);

    return workingSets;
}

From source file:edu.jhuapl.dorset.agents.StockAgent.java

/**
 * Stock agent/*w  w  w.ja v a 2  s  . com*/
 *
 * The Quandl API provides stock information for various companies world
 * wide. The StockAgent uses said API to scrape historical closing prices of
 * NASDAQ and NYSE companies.
 *
 * @param client An http client object
 * @param apiKey A Quandl API key
 */
public StockAgent(HttpClient client, String apiKey) {
    this.client = client;
    this.apiKey = apiKey;

    this.stockSymbolMap = new TreeMap<String, CompanyInfo>(String.CASE_INSENSITIVE_ORDER);
    readCsvFile("stockagent/NASDAQ_Companies.csv");
    readCsvFile("stockagent/NYSE_Companies.csv");

    this.setDescription(new Description("stock ticker", SUMMARY, EXAMPLE));

}

From source file:org.sakaiproject.nakamura.jcr.webconsole.ContentReloaderWebConsolePlugin.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String[] bundleNames = req.getParameterValues(PARAM_BUNDLE_NAMES);
    List<String> bundlesReloaded = contentReloader.reloadContent(bundleNames);
    Collections.sort(bundlesReloaded, String.CASE_INSENSITIVE_ORDER);

    DefaultVariableResolver vars = ((DefaultVariableResolver) WebConsoleUtil.getVariableResolver(req));

    String status = "Bundles reloaded!<ul><li>" + StringUtils.join(bundlesReloaded, "</li><li>") + "</li></ul>";
    req.getSession().setAttribute("status", status);

    resp.sendRedirect("/system/console/" + getLabel());
}

From source file:org.hedgewars.hedgeroid.SettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_settings, container, false);
    themeIcon = (ImageView) v.findViewById(R.id.imgTheme);

    try {// w w w . j ava2  s  . co  m
        styles = FrontendDataUtils.getGameStyles(getActivity());
        schemes = Schemes.loadAllSchemes(getActivity());
        weaponsets = Weaponsets.loadAllWeaponsets(getActivity());
        themes = FrontendDataUtils.getThemes(getActivity());
    } catch (IOException e) {
        Toast.makeText(getActivity().getApplicationContext(), R.string.error_missing_sdcard_or_files,
                Toast.LENGTH_LONG).show();
        getActivity().finish();
        return null;
    }

    Collections.sort(styles, String.CASE_INSENSITIVE_ORDER);
    Collections.sort(schemes, Scheme.NAME_ORDER);
    Collections.sort(weaponsets, Weaponset.NAME_ORDER);
    Collections.sort(themes, String.CASE_INSENSITIVE_ORDER);

    styleSpinner = prepareSpinner(v, R.id.spinGameplay, styles, styleSelectedListener);
    schemeSpinner = prepareSpinner(v, R.id.spinGamescheme, Schemes.toNameList(schemes), schemeSelectedListener);
    weaponsetSpinner = prepareSpinner(v, R.id.spinweapons, Weaponsets.toNameList(weaponsets),
            weaponsetSelectedListener);
    themeSpinner = prepareSpinner(v, R.id.spinTheme, themes, themeSelectedListener);

    stateManager.addListener(roomStateChangeListener);

    if (stateManager.getGameStyle() != null) {
        styleSpinner.setSelection(styles.indexOf(stateManager.getGameStyle()), false);
    }
    if (stateManager.getScheme() != null) {
        schemeSpinner.setSelection(getSchemePosition(schemes, stateManager.getScheme().name), false);
    }
    if (stateManager.getWeaponset() != null) {
        weaponsetSpinner.setSelection(getWeaponsetPosition(weaponsets, stateManager.getWeaponset().name),
                false);
    }
    if (stateManager.getMapRecipe() != null) {
        themeSpinner.setSelection(themes.indexOf(stateManager.getMapRecipe().theme), false);
    }

    setChiefState(stateManager.getChiefStatus());

    return v;
}

From source file:org.wso2.carbon.javaee.tomee.ASGlobalListenerSupport.java

private boolean isJavaEEApp(StandardContext standardContext) throws Exception {
    WebappClassloadingContext clContext = ClassloadingContextBuilder
            .buildClassloadingContext(getWebappFilePath(standardContext));
    //check if the classloading environment is JavaEE
    String[] webappCREs = clContext.getEnvironments();
    if (webappCREs != null) {
        Set<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
        set.addAll(Arrays.asList(webappCREs));

        return set.contains(JAVA_EE_CRE) || set.contains(JAVA_EE_OLD_CRE);
    } else {/*from   www  . ja  va 2s.  co  m*/
        String[] defaultCREs = ClassloadingContextBuilder.buildSystemConfig().getEnvironments();
        Set<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
        set.addAll(Arrays.asList(defaultCREs));

        return set.contains(JAVA_EE_CRE) || set.contains(JAVA_EE_OLD_CRE);
    }
}

From source file:net.community.chest.gitcloud.facade.ServletUtils.java

public static final Map<String, String> getResponseHeaders(HttpServletResponse rsp) {
    // NOTE: map must be case insensitive as per HTTP requirements
    Map<String, String> hdrsMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    for (String hdrName : rsp.getHeaderNames()) {
        String hdrValue = rsp.getHeader(hdrName);
        hdrsMap.put(capitalizeHttpHeaderName(hdrName), StringUtils.trimToEmpty(hdrValue));
    }/*from  w  w w  .j  a v a 2 s  .  co  m*/

    return hdrsMap;
}