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.TagPlugin.java

/**
 * Get all tags within the wiki./*from   w  w  w  . j  a va 2s.  co  m*/
 * 
 * @param context XWiki context.
 * @return list of tags (alphabetical order).
 * @throws XWikiException if search query fails (possible failures: DB access problems, etc).
 */
public List<String> getAllTags(XWikiContext context) throws XWikiException {
    List<String> results;

    String hql = "select distinct elements(prop.list) from BaseObject as obj, "
            + "DBStringListProperty as prop where obj.className='XWiki.TagClass' "
            + "and obj.id=prop.id.id and prop.id.name='tags'";
    results = context.getWiki().search(hql, context);
    Collections.sort(results, String.CASE_INSENSITIVE_ORDER);

    return results;
}

From source file:org.androdyne.StacktraceUploader.java

/**
 * Given the NameValuePairs forming a stacktrace submission request, creates a
 * signature over the parameters that the API should recognize.
 **///ww w. j  av  a  2  s.c o m
private String createSignature(List<NameValuePair> params) {
    // First, sort the parameter keys. That'll help later.
    List<String> sortedKeys = new LinkedList<String>();
    for (NameValuePair pair : params) {
        sortedKeys.add(pair.getName());
    }
    Collections.sort(sortedKeys, String.CASE_INSENSITIVE_ORDER);

    // Create signature.
    Mac hmac = null;
    try {
        hmac = Mac.getInstance("HmacSHA1");
        hmac.init(new SecretKeySpec(mAPISecret.getBytes(), "HmacSHA1"));
    } catch (NoSuchAlgorithmException ex) {
        android.util.Log.e(LTAG, "No HmacSHA1 available on this phone.");
        return null;
    } catch (InvalidKeyException ex) {
        android.util.Log.e(LTAG, "Invalid secret; shouldn't be possible.");
        return null;
    }

    final int size = sortedKeys.size();
    for (int i = 0; i < size; ++i) {
        String key = sortedKeys.get(i);

        for (NameValuePair pair : params) {
            if (!key.equals(pair.getName())) {
                continue;
            }

            // This pair is next!
            try {
                hmac.update(String.format("%s=%s", key, URLEncoder.encode(pair.getValue(), "utf8")).getBytes());
            } catch (java.io.UnsupportedEncodingException ex) {
                android.util.Log.e(LTAG, "URLEncoder reports 'utf8' is an unsupported encoding...");
                return null;
            }
            if (i < size - 1) {
                hmac.update("&".getBytes());
            }
        }
    }

    String signature = new BigInteger(1, hmac.doFinal()).toString(16);
    // android.util.Log.d(LTAG, "signature: " + signature);
    return signature;
}

From source file:com.ecyrd.jspwiki.auth.permissions.PagePermission.java

/**
 * Creates a new PagePermission for a specified page name and set of
 * actions. Page should include a prepended wiki name followed by a colon (:).
 * If the wiki name is not supplied or starts with a colon, the page
 * refers to no wiki in particular, and will never imply any other
 * PagePermission./*from  www. ja v a 2s .c o  m*/
 * @param page the wiki page
 * @param actions the allowed actions for this page
 */
public PagePermission(String page, String actions) {
    super(page);

    // Parse wiki and page (which may include wiki name and page)
    // Strip out attachment separator; it is irrelevant.

    // FIXME3.0: Assumes attachment separator is "/".
    String[] pathParams = StringUtils.split(page, WIKI_SEPARATOR);
    String pageName;
    if (pathParams.length >= 2) {
        m_wiki = pathParams[0].length() > 0 ? pathParams[0] : null;
        pageName = pathParams[1];
    } else {
        m_wiki = null;
        pageName = pathParams[0];
    }
    int pos = pageName.indexOf(ATTACHMENT_SEPARATOR);
    m_page = (pos == -1) ? pageName : pageName.substring(0, pos);

    // Parse actions
    String[] pageActions = StringUtils.split(actions.toLowerCase(), ACTION_SEPARATOR);
    Arrays.sort(pageActions, String.CASE_INSENSITIVE_ORDER);
    m_mask = createMask(actions);
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < pageActions.length; i++) {
        buffer.append(pageActions[i]);
        if (i < (pageActions.length - 1)) {
            buffer.append(ACTION_SEPARATOR);
        }
    }
    m_actionString = buffer.toString();
}

From source file:annis.gui.flatquerybuilder.SearchBox.java

@Override
public void textChange(TextChangeEvent event) {
    if ("specific".equals(sq.getFilterMechanism())) {
        ConcurrentSkipListSet<String> notInYet = new ConcurrentSkipListSet<String>();
        reducingStringComparator esc = new reducingStringComparator();
        String txt = event.getText();
        if (!txt.equals("")) {
            cb.removeAllItems();//from   w w  w.  j a v  a2s  . c om
            for (Iterator<String> it = annonames.iterator(); it.hasNext();) {
                String s = it.next();
                if (esc.compare(s, txt) == 0) {
                    cb.addItem(s);
                } else {
                    notInYet.add(s);
                }
            }
            //startsWith
            for (String s : notInYet) {
                if (esc.startsWith(s, txt)) {
                    cb.addItem(s);
                    notInYet.remove(s);
                }
            }
            //contains
            for (String s : notInYet) {
                if (esc.contains(s, txt)) {
                    cb.addItem(s);
                }
            }
        } else {
            //have a look and speed it up
            SpanBox.buildBoxValues(cb, ebene, sq);
        }
    }

    if ("levenshtein".equals(sq.getFilterMechanism())) {
        String txt = event.getText();
        HashMap<Integer, Collection> levdistvals = new HashMap<Integer, Collection>();
        if (txt.length() > 1) {
            cb.removeAllItems();
            for (String s : annonames) {
                Integer d = StringUtils.getLevenshteinDistance(removeAccents(txt), removeAccents(s));
                if (levdistvals.containsKey(d)) {
                    levdistvals.get(d).add(s);
                }
                if (!levdistvals.containsKey(d)) {
                    Set<String> newc = new TreeSet<String>();
                    newc.add(s);
                    levdistvals.put(d, newc);
                }
            }
            SortedSet<Integer> keys = new TreeSet<Integer>(levdistvals.keySet());
            for (Integer k : keys.subSet(0, 5)) {
                List<String> values = new ArrayList(levdistvals.get(k));
                Collections.sort(values, String.CASE_INSENSITIVE_ORDER);
                for (String v : values) {
                    cb.addItem(v);
                }
            }
        }
    }
}

From source file:com.stimulus.archiva.presentation.SearchBean.java

public List<String> getFieldLabels() {
    ArrayList<String> fieldLabelList = new ArrayList<String>();
    EmailFields emailFields = Config.getConfig().getEmailFields();
    for (EmailField ef : emailFields.getAvailableFields().values()) {
        // we dont allow end-users to search using bcc
        if (ef.getName().equals("bcc") && getMailArchivaPrincipal().getRole().equals("user"))
            continue;
        if (ef.getName().equals("deliveredto") && getMailArchivaPrincipal().getRole().equals("user"))
            continue;

        if (ef.getAllowSearch() == EmailField.AllowSearch.SEARCH)
            fieldLabelList.add(ef.getResource().toLowerCase(Locale.ENGLISH));
    }//from   w  w w.  ja  va 2 s .  c o  m
    fieldLabelList.add("field_label_addresses");
    fieldLabelList.add("field_label_all");
    Collections.sort(fieldLabelList, String.CASE_INSENSITIVE_ORDER);
    return translateList(fieldLabelList, true);
}

From source file:org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.java

public static Map<String, ByteBuffer> getColumnMap(List<HColumn<String, ByteBuffer>> columns) {
    Map<String, ByteBuffer> column_map = new TreeMap<String, ByteBuffer>(String.CASE_INSENSITIVE_ORDER);
    if (columns != null) {
        for (HColumn<String, ByteBuffer> column : columns) {
            String column_name = column.getName();
            column_map.put(column_name, column.getValue());
        }//from ww  w. ja  va2 s.c  o m
    }
    return column_map;
}

From source file:org.docrj.smartcard.reader.GroupViewActivity.java

@Override
public void onResume() {
    super.onResume();
    SharedPreferences ss = getSharedPreferences("prefs", Context.MODE_PRIVATE);

    Gson gson = new Gson();
    Type collectionType;//from   w ww .j av a2  s . com
    String json = ss.getString("apps", null);
    if (json == null) {
        mApps = new ArrayList<>();
    } else {
        collectionType = new TypeToken<ArrayList<SmartcardApp>>() {
        }.getType();
        mApps = gson.fromJson(json, collectionType);
    }

    json = ss.getString("groups", null);
    if (json == null) {
        mUserGroups = new LinkedHashSet<>();
    } else {
        collectionType = new TypeToken<LinkedHashSet<String>>() {
        }.getType();
        mUserGroups = gson.fromJson(json, collectionType);
    }

    // alphabetize, case insensitive
    mSortedAllGroups = new ArrayList<>(mUserGroups);
    mSortedAllGroups.addAll(Arrays.asList(DEFAULT_GROUPS));
    Collections.sort(mSortedAllGroups, String.CASE_INSENSITIVE_ORDER);

    Intent intent = getIntent();
    mGroupName = intent.getStringExtra(EXTRA_GROUP_NAME);
    if (mGroupName == null) {
        mGrpPos = intent.getIntExtra(EXTRA_GROUP_POS, 0);
        mGroupName = mSortedAllGroups.get(mGrpPos);
    } else {
        mGrpPos = mSortedAllGroups.indexOf(mGroupName);
    }
    mReadOnly = Util.isDefaultGroup(mGroupName);

    // when adding or removing a group, we may need to adjust group position indices for
    // batch select and app browse activities, which apply to the sorted list of groups
    mSelectedGrpPos = ss.getInt("selected_grp_pos", 0);
    mExpandedGrpPos = ss.getInt("expanded_grp_pos", -1);

    mMemberApps = Util.findGroupMembers(mGroupName, mApps);

    GroupItem groupItem = new GroupItem();
    groupItem.groupName = mGroupName;
    groupItem.apps = mMemberApps;

    List<GroupItem> groupItems = new ArrayList<>(1);
    groupItems.add(groupItem);

    mGrpAdapter = new GroupAdapter(this);
    mGrpAdapter.setData(groupItems);
    mGrpListView.setAdapter(mGrpAdapter);

    mGrpListView.expandGroup(0);
    mGrpListView.setSelectedGroup(0);

    if (!mReadOnly) {
        mNote.setVisibility(View.GONE);
    }
}

From source file:core.com.qiniu.auth.AWS4Signer.java

protected String getCanonicalizedHeaderString(Request<?> request) {
    List<String> sortedHeaders = new ArrayList<String>();
    sortedHeaders.addAll(request.getHeaders().keySet());
    Collections.sort(sortedHeaders, String.CASE_INSENSITIVE_ORDER);

    StringBuilder buffer = new StringBuilder();
    for (String header : sortedHeaders) {
        if (needsSign(header)) {
            String key = StringUtils.lowerCase(header).replaceAll("\\s+", " ");
            String value = request.getHeaders().get(header);

            buffer.append(key).append(":");
            if (value != null) {
                buffer.append(value.replaceAll("\\s+", " "));
            }//www .java2 s  .c o m

            buffer.append("\n");
        }
    }

    return buffer.toString();
}

From source file:com.mirth.connect.client.ui.alert.AlertChannelPane.java

public void setChannels(AlertChannels alertChannels, boolean includeConnectors) {
    if (PlatformUI.MIRTH_FRAME.channelPanel.getCachedChannelStatuses() != null) {
        TreeMap<String, Channel> channelMap = new TreeMap<String, Channel>(String.CASE_INSENSITIVE_ORDER);

        // Sort the channels by channel name
        for (ChannelStatus channelStatus : PlatformUI.MIRTH_FRAME.channelPanel.getCachedChannelStatuses()
                .values()) {/*from  w  ww. j  av  a2 s.  co  m*/
            Channel channel = channelStatus.getChannel();
            channelMap.put(channel.getName(), channel);
        }

        ChannelTreeTableModel model = (ChannelTreeTableModel) channelTreeTable.getTreeTableModel();
        model.addChannels(channelMap.values(), alertChannels, includeConnectors);
    }

    enableButton.setEnabled(false);
    disableButton.setEnabled(false);
}

From source file:com.amazonaws.auth.AWS4Signer.java

protected String getCanonicalizedHeaderString(Request<?> request) {
    List<String> sortedHeaders = new ArrayList<String>();
    sortedHeaders.addAll(request.getHeaders().keySet());
    Collections.sort(sortedHeaders, String.CASE_INSENSITIVE_ORDER);

    StringBuilder buffer = new StringBuilder();
    for (String header : sortedHeaders) {
        String key = header.toLowerCase().replaceAll("\\s+", " ");
        String value = request.getHeaders().get(header);

        buffer.append(key).append(":");
        if (value != null) {
            buffer.append(value.replaceAll("\\s+", " "));
        }//from   w  w w . j  a  v  a 2  s .  c o  m

        buffer.append("\n");
    }

    return buffer.toString();
}