List of usage examples for java.lang String CASE_INSENSITIVE_ORDER
Comparator CASE_INSENSITIVE_ORDER
To view the source code for java.lang String CASE_INSENSITIVE_ORDER.
Click Source Link
From source file:org.apache.jsp.people_jsp.java
private String getListOfCommunities(JSONArray memberOf, HttpServletRequest request, HttpServletResponse response) { StringBuffer communityList = new StringBuffer(); communityList.append("<table width=\"100%\">"); try {//ww w. j ava 2 s. co m // Create an array list of communities the user is a member of List<String> memberOfList = new ArrayList<String>(); for (int i = 0; i < memberOf.length(); i++) { JSONObject c = memberOf.getJSONObject(i); memberOfList.add(c.getString("_id")); } // Get a list of all communities from the api JSONObject communitiesObject = new JSONObject(getAllCommunities(request, response)); JSONArray communities = communitiesObject.getJSONArray("data"); // Create an array list of all community names so we can sort them correctly for display List<String> listOfCommunityNames = new ArrayList<String>(); for (int i = 0; i < communities.length(); i++) { JSONObject c = communities.getJSONObject(i); if (c.has("name")) { listOfCommunityNames.add(c.getString("name")); } } Collections.sort(listOfCommunityNames, String.CASE_INSENSITIVE_ORDER); int column = 1; for (String communityName : listOfCommunityNames) { // Iterate over the list of all communities for (int i = 0; i < communities.length(); i++) { JSONObject community = communities.getJSONObject(i); if (community.has("name") && community.getString("name").equalsIgnoreCase(communityName.toLowerCase())) { // Only show the non-system, non-personal communities if (community.getString("isPersonalCommunity").equalsIgnoreCase("false") && community.getString("isSystemCommunity").equalsIgnoreCase("false")) { if (column == 1) { communityList.append("<tr valign=\"middle\">"); } communityList.append("<td width=\"5%\">"); String listFilterString = ""; if (listFilter.length() > 0) listFilterString = "&listFilterStr=" + listFilter; String pageString = ""; if (currentPage > 1) pageString = "&page=" + currentPage; String deleteLink = "<a href=\"people.jsp?action=edit&personid=" + personid + pageString + listFilterString + "&removefrom=" + community.getString("_id") + "\" title=\"Remove User from Community\" " + "onclick='return confirm(\"Do you really wish to remove the user account from: " + community.getString("name") + "?\");'><img src=\"image/minus_button.png\" border=0></a>"; String addLink = "<a href=\"people.jsp?action=edit&personid=" + personid + pageString + listFilterString + "&addto=" + community.getString("_id") + "\" title=\"Add User to Community\"><img src=\"image/plus_button.png\" border=0></a>"; String divOne = ""; String divTwo = ""; if (memberOfList.contains(community.getString("_id"))) { communityList.append(deleteLink); } else { communityList.append(addLink); divOne = "<div class=\"notAMemberOfCommunity\">"; divTwo = "</div>"; } communityList.append("</td>"); communityList.append("<td width=\"45%\">"); communityList.append(divOne + community.getString("name") + divTwo); communityList.append("</td>"); if (column == 1) { column = 2; } else { communityList.append("</tr>"); column = 1; } } } } } } catch (Exception e) { System.out.println(e.getMessage()); } communityList.append("</table>"); return communityList.toString(); }
From source file:me.ryanhamshire.PopulationDensity.DataStore.java
@Override public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) throws IllegalArgumentException { Validate.notNull(sender, "Sender cannot be null"); Validate.notNull(args, "Arguments cannot be null"); Validate.notNull(alias, "Alias cannot be null"); if (args.length == 0) { return ImmutableList.of(); }//from w w w . j a v a 2 s.c o m StringBuilder builder = new StringBuilder(); for (String arg : args) { builder.append(arg + " "); } String arg = builder.toString().trim(); ArrayList<String> matches = new ArrayList<String>(); for (String name : this.coordsToNameMap.values()) { if (StringUtil.startsWithIgnoreCase(name, arg)) { matches.add(name); } } Player senderPlayer = sender instanceof Player ? (Player) sender : null; for (Player player : sender.getServer().getOnlinePlayers()) { if (senderPlayer == null || senderPlayer.canSee(player)) { if (StringUtil.startsWithIgnoreCase(player.getName(), arg)) { matches.add(player.getName()); } } } Collections.sort(matches, String.CASE_INSENSITIVE_ORDER); return matches; }
From source file:org.apache.phoenix.hive.HiveTestUtil.java
private static void ensureQvFileList(String queryDir) { if (cachedQvFileList != null) return;// ww w. ja v a 2 s. c o m // Not thread-safe. LOG.info("Getting versions from " + queryDir); cachedQvFileList = (new File(queryDir)).list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".qv"); } }); if (cachedQvFileList == null) return; // no files at all Arrays.sort(cachedQvFileList, String.CASE_INSENSITIVE_ORDER); List<String> defaults = getVersionFilesInternal("default"); cachedDefaultQvFileList = (defaults != null) ? ImmutableList.copyOf(defaults) : ImmutableList.<String>of(); }
From source file:org.apache.jsp.communities_jsp.java
private String listItems(HttpServletRequest request, HttpServletResponse response) { StringBuffer communities = new StringBuffer(); Map<String, String> listOfCommunities = getListOfAllNonPersonalCommunities(request, response); if (listOfCommunities.size() > 0) { communities.append("<table class=\"listTable\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" >"); // Sort the sources alphabetically List<String> sortedKeys = new ArrayList<String>(listOfCommunities.keySet()); Collections.sort(sortedKeys, String.CASE_INSENSITIVE_ORDER); // Filter the list List<String> sortedAndFilteredKeys = new ArrayList<String>(); for (String key : sortedKeys) { if (listFilter.length() > 0) { if (key.toLowerCase().contains(listFilter.toLowerCase())) sortedAndFilteredKeys.add(key); } else { sortedAndFilteredKeys.add(key); }// w ww.ja v a 2 s. co m } // If the user has filtered the list down we might need to adjust our page calculations // e.g. 20 total items might = 2 pages but filtered down to 5 items there would only be 1 // Calculate first item to start with with // Page = 1, item = 1 // Page = X, item = ( ( currentPage - 1 ) * itemsToShowPerPage ) + 1; int startItem = 1; int endItem = startItem + itemsToShowPerPage - 1; if (currentPage > 1) { startItem = ((currentPage - 1) * itemsToShowPerPage) + 1; endItem = (startItem + itemsToShowPerPage) - 1; } int currentItem = 1; for (String key : sortedAndFilteredKeys) { String name = key; if (currentItem >= startItem && currentItem <= endItem && !name.equalsIgnoreCase("Infinit.e System Community")) { String id = listOfCommunities.get(key).toString(); String editLink = ""; String deleteLink = ""; String listFilterString = ""; if (listFilter.length() > 0) listFilterString = "&listFilterStr=" + listFilter; editLink = "<a href=\"communities.jsp?action=edit&communityid=" + id + "&page=" + currentPage + listFilterString + "\" title=\"Edit Community\">" + name + "</a>"; deleteLink = "<a href=\"communities.jsp?action=delete&communityid=" + id + listFilterString + "\" title=\"Delete Community\" " + "onclick='return confirm(\"Do you really wish to delete the following community: " + name + "?\");'><img src=\"image/delete_x_button.png\" border=0></a>"; // Create the HTML table row communities.append("<tr>"); communities.append("<td bgcolor=\"white\" width=\"100%\">" + editLink + "</td>"); communities.append("<td align=\"center\" bgcolor=\"white\">" + deleteLink + "</td>"); communities.append("</tr>"); } currentItem++; } // Calculate number of pages, current page, page links... communities.append("<tr><td colspan=\"2\" align=\"center\" class=\"subTableFooter\">"); // -------------------------------------------------------------------------------- // Create base URL for each page StringBuffer baseUrl = new StringBuffer(); baseUrl.append("communities.jsp?"); String actionString = (action.length() > 0) ? "action=" + action : ""; String communityIdString = (communityid.length() > 0) ? "communityid=" + communityid : ""; if (actionString.length() > 0) baseUrl.append(actionString); if (actionString.length() > 0 && communityIdString.length() > 0) baseUrl.append("&"); if (communityIdString.length() > 0) baseUrl.append(communityIdString); if (actionString.length() > 0 || communityIdString.length() > 0) baseUrl.append("&"); baseUrl.append("page="); communities.append(createPageString(sortedAndFilteredKeys.size(), itemsToShowPerPage, currentPage, baseUrl.toString())); communities.append("</td></tr>"); // -------------------------------------------------------------------------------- communities.append("</table>"); } else { communities.append("No communities were retrieved"); } return communities.toString(); }
From source file:org.getlantern.firetweet.activity.support.ComposeActivity.java
private boolean handleReplyIntent(final ParcelableStatus status) { if (status == null || status.id <= 0) return false; final String myScreenName = getAccountScreenName(this, status.account_id); if (isEmpty(myScreenName)) return false; mEditText.append("@" + status.user_screen_name + " "); final int selectionStart = mEditText.length(); if (!isEmpty(status.retweeted_by_screen_name)) { mEditText.append("@" + status.retweeted_by_screen_name + " "); }// w ww .jav a2 s. co m final Collection<String> mentions = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); mentions.addAll(mExtractor.extractMentionedScreennames(status.text_plain)); for (final String mention : mentions) { if (mention.equalsIgnoreCase(status.user_screen_name) || mention.equalsIgnoreCase(myScreenName) || mention.equalsIgnoreCase(status.retweeted_by_screen_name)) { continue; } mEditText.append("@" + mention + " "); } final int selectionEnd = mEditText.length(); mEditText.setSelection(selectionStart, selectionEnd); mAccountsAdapter.setSelectedAccountIds(status.account_id); return true; }
From source file:org.apache.jsp.sources_jsp.java
private String listItems(HttpServletRequest request, HttpServletResponse response) { StringBuffer sources = new StringBuffer(); Map<String, String> listOfSources = getUserSourcesAndShares(request, response); if (listOfSources.size() > 0) { sources.append("<table class=\"listTable\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" >"); // Sort the sources alphabetically List<String> sortedKeys = new ArrayList<String>(listOfSources.keySet()); Collections.sort(sortedKeys, String.CASE_INSENSITIVE_ORDER); // Filter the list List<String> sortedAndFilteredKeys = new ArrayList<String>(); for (String key : sortedKeys) { if (listFilter.length() > 0) { if (key.toLowerCase().contains(listFilter.toLowerCase())) sortedAndFilteredKeys.add(key); } else { sortedAndFilteredKeys.add(key); }//from w ww .j av a2s . c o m } // If the user has filtered the list down we might need to adjust our page calculations // e.g. 20 total items might = 2 pages but filtered down to 5 items there would only be 1 // Calculate first item to start with with // Page = 1, item = 1 // Page = X, item = ( ( currentPage - 1 ) * itemsToShowPerPage ) + 1; int startItem = 1; int endItem = startItem + itemsToShowPerPage - 1; if (currentPage > 1) { startItem = ((currentPage - 1) * itemsToShowPerPage) + 1; endItem = (startItem + itemsToShowPerPage) - 1; } int currentItem = 1; for (String key : sortedAndFilteredKeys) { String name = key; if (currentItem >= startItem && currentItem <= endItem) { String id = listOfSources.get(key).toString(); String editLink = ""; String deleteLink = ""; String listFilterString = ""; if (listFilter.length() > 0) listFilterString = "&listFilterStr=" + listFilter; if (name.contains("*")) { editLink = "<a href=\"sources.jsp?action=edit&shareid=" + id + "&page=" + currentPage + listFilterString + "\" title=\"Edit Share\">" + name + "</a>"; deleteLink = "<a href=\"sources.jsp?action=delete&shareid=" + id + "&page=" + currentPage + listFilterString + "\" title=\"Delete Share\" " + "onclick='return confirm(\"Do you really wish to delete the share: " + name + "?\");'><img src=\"image/delete_x_button.png\" border=0></a>"; } else { editLink = "<a href=\"sources.jsp?action=sharefromsource&sourceid=" + id + "&page=" + currentPage + listFilterString + "\" title=\"Create Share from Source\">" + name + "</a>"; deleteLink = "<a href=\"sources.jsp?action=deletesource&sourceid=" + id + "&page=" + currentPage + listFilterString + "\" title=\"Delete Source\" " + "onclick='return confirm(\"Do you really wish to delete the source: " + name + "?\");'><img src=\"image/delete_x_button.png\" border=0></a>"; } // Create the HTML table row sources.append("<tr valign=\"top\">"); sources.append("<td bgcolor=\"white\" width=\"100%\">" + editLink + "</td>"); sources.append("<td align=\"center\" bgcolor=\"white\">" + deleteLink + "</td>"); sources.append("</tr>"); } currentItem++; } sources.append("<tr valign=\"top\">"); sources.append("<td bgcolor=\"white\" width=\"100%\" colspan=\"2\">"); sources.append("(*) Share<br>"); sources.append("(+) Source owned by someone else"); sources.append("</td>"); sources.append("</tr>"); // Calculate number of pages, current page, page links... sources.append("<tr><td colspan=\"2\" align=\"center\" class=\"subTableFooter\">"); // -------------------------------------------------------------------------------- // Create base URL for each page StringBuffer baseUrl = new StringBuffer(); baseUrl.append("sources.jsp?"); String actionString = (action.length() > 0) ? "action=" + action : ""; String shareIdString = (shareid.length() > 0) ? "shareid=" + shareid : ""; if (actionString.length() > 0) baseUrl.append(actionString); if (actionString.length() > 0 && shareIdString.length() > 0) baseUrl.append("&"); if (shareIdString.length() > 0) baseUrl.append(shareIdString); if (actionString.length() > 0 || shareIdString.length() > 0) baseUrl.append("&"); baseUrl.append("page="); sources.append(createPageString(sortedAndFilteredKeys.size(), itemsToShowPerPage, currentPage, baseUrl.toString())); sources.append("</td></tr>"); // -------------------------------------------------------------------------------- sources.append("</table>"); } else { sources.append("No sources were retrieved"); } return sources.toString(); }
From source file:org.mariotaku.twidere.activity.support.ComposeActivity.java
private boolean handleReplyIntent(final ParcelableStatus status) { if (status == null || status.id <= 0) return false; final String myScreenName = Utils.getAccountScreenName(this, status.account_id); if (TextUtils.isEmpty(myScreenName)) return false; int selectionStart = 0; if (status.is_quote) { mEditText.append("@" + status.quoted_by_user_screen_name + " "); selectionStart = mEditText.length(); }//from w w w .ja v a 2s. c o m mEditText.append("@" + status.user_screen_name + " "); if (!status.is_quote) { selectionStart = mEditText.length(); } if (status.is_retweet) { mEditText.append("@" + status.retweeted_by_user_screen_name + " "); } final Collection<String> mentions = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); mentions.addAll(mExtractor.extractMentionedScreennames(status.text_plain)); for (final String mention : mentions) { if (mention.equalsIgnoreCase(status.user_screen_name) || mention.equalsIgnoreCase(myScreenName) || mention.equalsIgnoreCase(status.retweeted_by_user_screen_name)) { continue; } mEditText.append("@" + mention + " "); } final int selectionEnd = mEditText.length(); mEditText.setSelection(selectionStart, selectionEnd); mAccountsAdapter.setSelectedAccountIds(status.account_id); return true; }
From source file:com.cnaude.purpleirc.PurpleIRC.java
/** * * @param ircBot/*w w w. jav a 2 s.c o m*/ * @param channelName * @return */ public PlayerList getMCPlayerList(PurpleBot ircBot, String channelName) { PlayerList pl = new PlayerList(); Map<String, String> playerList = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); for (Player player : getServer().getOnlinePlayers()) { if (ircBot.hideListWhenVanished.get(channelName)) { logDebug("List: Checking if player " + player.getName() + " is vanished."); if (vanishHook.isVanished(player)) { logDebug("Not adding player to list command" + player.getName() + " due to being vanished."); continue; } } String pName = tokenizer.playerTokenizer(player, listPlayer); playerList.put(player.getName(), pName); } String pList; if (!listSortByName) { // sort as before ArrayList<String> tmp = new ArrayList<>(playerList.values()); Collections.sort(tmp, Collator.getInstance()); pList = Joiner.on(listSeparator).join(tmp); } else { // sort without nick prefixes pList = Joiner.on(listSeparator).join(playerList.values()); } pl.count = playerList.size(); pl.max = getServer().getMaxPlayers(); pl.list = pList; return pl; }
From source file:org.dasein.cloud.aws.AWSCloud.java
private String getV4CanonicalRequest(String action, String serviceUrl, Map<String, String> headers, String bodyHash) throws InternalException { /*/*w w w. jav a 2 s. c o m*/ CanonicalRequest = HTTPRequestMethod + '\n' + CanonicalURI + '\n' + CanonicalQueryString + '\n' + CanonicalHeaders + '\n' + SignedHeaders + '\n' + HexEncode(Hash(Payload)) */ final URI endpoint; try { endpoint = new URI(serviceUrl.replace(" ", "%20")).normalize(); } catch (URISyntaxException e) { throw new InternalException(e); } final StringBuilder s = new StringBuilder(); s.append(action.toUpperCase()).append("\n"); String path = endpoint.getPath(); if (path == null || path.length() == 0) { path = "/"; } s.append(encode(path, true)).append("\n"); s.append(getV4CanonicalQueryString(endpoint)).append("\n"); List<String> sortedHeaders = new ArrayList<String>(); sortedHeaders.addAll(headers.keySet()); Collections.sort(sortedHeaders, String.CASE_INSENSITIVE_ORDER); for (String header : sortedHeaders) { String value = headers.get(header).trim().replaceAll("\\s+", " "); header = header.toLowerCase().replaceAll("\\s+", " "); s.append(header).append(":").append(value).append("\n"); } s.append("\n").append(getV4SignedHeaders(headers)).append("\n").append(bodyHash); return s.toString(); }
From source file:org.opencms.workplace.tools.workplace.logging.CmsLog4JAdminDialog.java
/** * Help function to get all loggers from LogManager.<p> * * @return List of Logger//from w w w. j av a 2 s. com */ private List<Logger> getLoggers() { // list of all loggers List<Logger> definedLoggers = new ArrayList<Logger>(); // list of all parent loggers List<Logger> packageLoggers = new ArrayList<Logger>(); @SuppressWarnings("unchecked") List<Logger> curentloggerlist = Collections.list(LogManager.getCurrentLoggers()); Iterator<Logger> it_curentlogger = curentloggerlist.iterator(); // get all current loggers while (it_curentlogger.hasNext()) { // get the logger Logger log = it_curentlogger.next(); String logname = log.getName(); String[] prefix = buildsufix(logname); // create all possible package logger from given logger name for (int i = 0; i < prefix.length; i++) { // get the name of the logger without the prefix String temp = log.getName().replace(prefix[i], ""); // if the name has suffix if (temp.length() > 1) { temp = temp.substring(1); } if (temp.lastIndexOf(".") > 1) { // generate new logger with "org.opencms" prefix and the next element // between the points e.g.: "org.opencms.search" Logger temp_logger = Logger.getLogger(prefix[i] + "." + temp.substring(0, temp.indexOf("."))); // activate the heredity so the logger get the appender from parent logger temp_logger.setAdditivity(true); // add the logger to the packageLoggers list if it is not part of it if (!packageLoggers.contains(temp_logger)) { packageLoggers.add(temp_logger); } } } definedLoggers.add(log); } Iterator<Logger> it_logger = packageLoggers.iterator(); // iterate about all packageLoggers while (it_logger.hasNext()) { Logger temp = it_logger.next(); // check if the logger is part of the logger list if (!definedLoggers.contains(temp)) { // add the logger to the logger list definedLoggers.add(temp); } } // sort all loggers by name Collections.sort(definedLoggers, new Comparator<Object>() { public int compare(Logger o1, Logger o2) { return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName()); } public int compare(Object obj, Object obj1) { return compare((Logger) obj, (Logger) obj1); } }); // return all loggers return definedLoggers; }