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:grails.plugin.cache.web.filter.PageFragmentCachingFilter.java
/** * Set the headers in the response object, excluding the Gzip header * @param pageInfo//from ww w. j a v a 2 s.co m * @param response */ protected void setHeaders(final PageInfo pageInfo, final HttpServletResponse response) { Collection<Header<? extends Serializable>> headers = pageInfo.getHeaders(); // Track which headers have been set so all headers of the same name // after the first are added TreeSet<String> setHeaders = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); for (Header<? extends Serializable> header : headers) { String name = header.getName(); switch (header.getType()) { case STRING: if (setHeaders.contains(name)) { response.addHeader(name, (String) header.getValue()); } else { setHeaders.add(name); response.setHeader(name, (String) header.getValue()); } break; case DATE: if (setHeaders.contains(name)) { response.addDateHeader(name, (Long) header.getValue()); } else { setHeaders.add(name); response.setDateHeader(name, (Long) header.getValue()); } break; case INT: if (setHeaders.contains(name)) { response.addIntHeader(name, (Integer) header.getValue()); } else { setHeaders.add(name); response.setIntHeader(name, (Integer) header.getValue()); } break; default: throw new IllegalArgumentException("No mapping for Header: " + header); } } }
From source file:io.pivotal.cla.service.github.MylynGitHubApi.java
@SneakyThrows public List<String> getOrganizations(String username) { OrganizationService orgs = new OrganizationService(createClient(oauthConfig.getPivotalClaAccessToken())); List<org.eclipse.egit.github.core.User> organizations = orgs.getOrganizations(username); return organizations.stream().map(o -> o.getLogin()).sorted(String.CASE_INSENSITIVE_ORDER) .collect(Collectors.toList()); }
From source file:org.apache.flink.client.cli.CliFrontend.java
private static void printJobStatusMessages(List<JobStatusMessage> jobs) { SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); Comparator<JobStatusMessage> startTimeComparator = (o1, o2) -> (int) (o1.getStartTime() - o2.getStartTime()); Comparator<Map.Entry<JobStatus, List<JobStatusMessage>>> statusComparator = (o1, o2) -> String.CASE_INSENSITIVE_ORDER.compare(o1.getKey().toString(), o2.getKey().toString()); Map<JobStatus, List<JobStatusMessage>> jobsByState = jobs.stream() .collect(Collectors.groupingBy(JobStatusMessage::getJobState)); jobsByState.entrySet().stream().sorted(statusComparator).map(Map.Entry::getValue).flatMap(List::stream) .sorted(startTimeComparator) .forEachOrdered(job -> System.out.println(dateFormat.format(new Date(job.getStartTime())) + " : " + job.getJobId() + " : " + job.getJobName() + " (" + job.getJobState() + ")")); }
From source file:url.Path.java
public void urlHierarchyFreq(String inputFile, String outputFile, int threshold) { BufferedReader br = null;//from ww w . j a va 2s.co m String line = ""; ArrayList<String> d3list = new ArrayList<String>(); Map<String, Integer> wordMap = new HashMap<String, Integer>(); Map<String, Integer> pathMap = new HashMap<String, Integer>(); try { br = new BufferedReader(new FileReader(inputFile)); int count = 0; while ((line = br.readLine()) != null) { //"at"-"ac"-"univie"-"publizistik",4:"institut"-"aktuelles"-"news-einzelansicht",1 String domain_part[] = line.split(":"); //"at"-"ac"-"univie"-"publizistik",4 String domain_freq = domain_part[0]; //"at"-"ac"-"univie"-"publizistik",4 //String domain_cut[]=domain_freq.split(","); //String domain=domain_cut[0]; //"at"-"ac"-"univie"-"publizistik" String path_cut[] = domain_part[1].split(","); //"institut"-"aktuelles"-"news-einzelansicht",1 String path = path_cut[0]; int path_freq = Integer.parseInt(path_cut[1]); /*System.out.println("domain part arr "+ Arrays.toString(domain_part)); System.out.println("domain part "+domain_freq); System.out.println("path cut"+ Arrays.toString(path_cut)); System.out.println("path part "+path);*/ String key = domain_freq + ":" + path; count++; if (count > 100) { // break; } if (wordMap.containsKey(key)) { wordMap.put(key, wordMap.get(key) + 1); //System.out.println("key: "+key+" count: "+wordMap.get(key)); } else { wordMap.put(key, 1); pathMap.put(key, path_freq); } } try { PrintWriter writer = new PrintWriter(outputFile, "UTF-8"); List<Map.Entry<String, Integer>> list = sortByValue(wordMap); for (Map.Entry<String, Integer> entry : list) { int sum = entry.getValue() + pathMap.get(entry.getKey()); //System.out.println("sum"+sum+" theshold:"+threshold); if (sum > threshold) { // System.out.println("url: "+entry.getKey()+','+sum); d3list.add(entry.getKey() + ',' + sum); } } Collections.sort(d3list, String.CASE_INSENSITIVE_ORDER); //Collections.reverse(d3list); for (int i = 0; i < d3list.size() - 1; i++) { writer.println(d3list.get(i)); } writer.close(); System.out.println("Write to file-->" + outputFile); } catch (FileNotFoundException | UnsupportedEncodingException ex) { } } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null) br.close(); } catch (Exception ex) { } } }
From source file:org.apache.directory.fortress.core.impl.HierUtil.java
/** * Recursively traverse the hierarchical graph and return all of the ascendants of a given node. * * @param childName maps to vertex to determine parentage. * @param parentName points to top most ascendant where traversal must stop. * @param isInclusive if set to true will include the parentName in the result set. False will not return specified parentName. * @param graph contains a reference to simple digraph {@code org.jgrapht.graph.SimpleDirectedGraph}. * @return Set of names that are parents of given child. *///from www. ja v a 2s . c o m static Set<String> getAscendants(String childName, String parentName, boolean isInclusive, SimpleDirectedGraph<String, Relationship> graph) { Map<String, String> vx = new HashMap<>(); // TreeSet will return in sorted order: // create Set with case insensitive comparator: Set<String> parents = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); vx.put(VERTEX, childName.toUpperCase()); getAscendants(vx, graph, parents, parentName, isInclusive); return parents; }
From source file:org.apache.directory.fortress.core.impl.PolicyDAO.java
/** * @return/*from w w w.j a v a2 s . c om*/ * @throws FinderException */ Set<String> getPolicies(String contextId) throws FinderException { Set<String> policySet = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); LdapConnection ld = null; String policyRoot = getPolicyRoot(contextId); try { String filter = "(objectclass=" + OLPW_POLICY_CLASS + ")"; ld = getAdminConnection(); SearchCursor searchResults = search(ld, policyRoot, SearchScope.ONELEVEL, filter, PASSWORD_POLICY_NAME_ATR, false, GlobalIds.BATCH_SIZE); while (searchResults.next()) { policySet.add(getAttribute(searchResults.getEntry(), SchemaConstants.CN_AT)); } } catch (LdapException e) { String error = "getPolicies caught LdapException=" + e.getMessage(); throw new FinderException(GlobalErrIds.PSWD_SEARCH_FAILED, error, e); } catch (CursorException e) { String error = "getPolicies caught LdapException=" + e.getMessage(); throw new FinderException(GlobalErrIds.PSWD_SEARCH_FAILED, error, e); } finally { closeAdminConnection(ld); } return policySet; }
From source file:org.springframework.jdbc.repo.impl.jdbc.RawPropertiesRepoImpl.java
private Object createEntityEntry(final String id) { if (StringUtils.isEmpty(id)) { throw new IllegalArgumentException( "createEntityEntry(" + getEntityClass().getSimpleName() + ") no ID provided"); }//from w w w . jav a 2 s. c o m // NOTE !!! we rely on auto-generated internal ID try { int nRows = jdbcAccessor.update( "INSERT INTO " + IDENTIFIED_ENTITIES_TABLE + "(" + ENTITY_TYPE_COL + "," + ENTITY_ID_COL + ")" + " VALUES (:" + ENTITY_TYPE_COL + ",:" + ENTITY_ID_COL + ")", new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER) { private static final long serialVersionUID = 1L; { put(ENTITY_TYPE_COL, getEntityClass().getSimpleName()); put(ENTITY_ID_COL, id); } }); if (nRows < 0) { logger.warn("createEntityEntry(" + getEntityClass().getSimpleName() + ")[" + id + "] bad rows count: " + nRows); } } catch (RuntimeException e) { logger.warn("createEntityEntry(" + getEntityClass().getSimpleName() + ")[" + id + "]" + " failed (" + e.getClass().getSimpleName() + ") to create entry: " + e.getMessage()); throw e; } Object internalId = findInternalId(id); if (internalId == null) { throw new IllegalStateException("createEntityEntry(" + getEntityClass().getSimpleName() + ")[" + id + "] no internal ID available"); } if (logger.isDebugEnabled()) { logger.debug("createEntityEntry(" + getEntityClass().getSimpleName() + ")[" + id + "]: " + internalId); } return internalId; }
From source file:org.apache.felix.webconsole.AbstractWebConsolePlugin.java
/** * This method is called to generate the top level links with the available plug-ins. * * @param request the HTTP request coming from the user * @param pw the writer, where the HTML data is rendered *///from w ww.ja v a2 s . co m protected void renderTopNavigation(HttpServletRequest request, PrintWriter pw) { // assume pathInfo to not be null, else this would not be called boolean linkToCurrent = true; String current = request.getPathInfo(); int slash = current.indexOf("/", 1); if (slash < 0) { slash = current.length(); linkToCurrent = false; } current = current.substring(1, slash); boolean disabled = false; String appRoot = (String) request.getAttribute(WebConsoleConstants.ATTR_APP_ROOT); Map labelMap = (Map) request.getAttribute(WebConsoleConstants.ATTR_LABEL_MAP); if (labelMap != null) { // prepare the navigation SortedMap map = new TreeMap(String.CASE_INSENSITIVE_ORDER); for (Iterator ri = labelMap.entrySet().iterator(); ri.hasNext();) { Map.Entry labelMapEntry = (Map.Entry) ri.next(); if (labelMapEntry.getKey() == null) { // ignore renders without a label } else if (disabled || current.equals(labelMapEntry.getKey())) { if (linkToCurrent) { map.put(labelMapEntry.getValue(), "<div class='ui-state-active'><a href='" + appRoot + "/" + labelMapEntry.getKey() + "'>" + labelMapEntry.getValue() + "</a></div>"); } else { map.put(labelMapEntry.getValue(), "<div class='ui-state-active'><span>" + labelMapEntry.getValue() + "</span></div>"); } } else { map.put(labelMapEntry.getValue(), "<div class='ui-state-default'><a href='" + appRoot + "/" + labelMapEntry.getKey() + "'>" + labelMapEntry.getValue() + "</a></div>"); } } // render the navigation pw.println("<div id='technav' class='ui-widget ui-widget-header'>"); for (Iterator li = map.values().iterator(); li.hasNext();) { pw.print(' '); pw.println(li.next()); } pw.println("</div>"); } // render lang-box Map langMap = (Map) request.getAttribute(WebConsoleConstants.ATTR_LANG_MAP); if (null != langMap && !langMap.isEmpty()) { pw.println("<div id='langSelect'>"); //$NON-NLS-1$ pw.println(" <span class='ui-icon ui-icon-comment'> </span>"); //$NON-NLS-1$ pw.println(" <span class='flags ui-helper-hidden'>"); //$NON-NLS-1$ for (Iterator li = langMap.keySet().iterator(); li.hasNext();) { // <img src="us.gif" alt="en" title="English"/> final Object l = li.next(); pw.print(" <img src='"); //$NON-NLS-1$ pw.print(appRoot); pw.print("/res/flags/"); //$NON-NLS-1$ pw.print(l); pw.print(".gif' alt='"); //$NON-NLS-1$ pw.print(l); pw.print("' title='"); //$NON-NLS-1$ pw.print(langMap.get(l)); pw.println("'/>"); //$NON-NLS-1$ } pw.println(" </span>"); //$NON-NLS-1$ pw.println("</div>"); //$NON-NLS-1$ } }
From source file:org.wso2.carbon.identity.oauth2.util.OAuth2Util.java
public static Map<String, String> getAvailableUserStoreDomainMappings() throws IdentityOAuth2Exception { //TreeMap is used to ignore the case sensitivity of key. Because when user logged in, the case of the user name is ignored. Map<String, String> userStoreDomainMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); String domainsStr = getAccessTokenPartitioningDomains(); if (domainsStr != null) { String[] userStoreDomainsArr = domainsStr.split(","); for (String userStoreDomains : userStoreDomainsArr) { String[] mapping = userStoreDomains.trim().split(":"); //A:foo.com , B:bar.com if (mapping.length < 2) { throw new IdentityOAuth2Exception("Domain mapping has not defined correctly"); }//w w w .ja v a 2 s . co m userStoreDomainMap.put(mapping[1].trim(), mapping[0].trim()); //key=domain & value=mapping } } return userStoreDomainMap; }
From source file:org.apache.directory.fortress.core.impl.DelAccessMgrImpl.java
/** * This helper function processes ARBAC PRA "can assign". * @param session//from w ww .j av a 2 s.c o m * @param role * @param perm * @return boolean * @throws SecurityException */ private boolean checkRolePermission(Session session, Role role, Permission perm) throws SecurityException { boolean result = false; List<UserAdminRole> uaRoles = session.getAdminRoles(); if (CollectionUtils.isNotEmpty(uaRoles)) { // validate perm and retrieve perm's ou: PermObj inObj = new PermObj(perm.getObjName()); inObj.setContextId(contextId); PermObj pObj = permP.read(inObj); for (UserAdminRole uaRole : uaRoles) { if (uaRole.getName().equalsIgnoreCase(SUPER_ADMIN)) { result = true; break; } Set<String> osPs = uaRole.getOsP(); if (CollectionUtils.isNotEmpty(osPs)) { // create Set with case insensitive comparator: Set<String> osPsFinal = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); for (String osP : osPs) { // Add osU children to the set: osPsFinal.add(osP); Set<String> children = PsoUtil.getDescendants(osP, this.contextId); osPsFinal.addAll(children); } // does the admin role have authority over the perm object? if (osPsFinal.contains(pObj.getOu())) { // Get the Role range for admin role: Set<String> range; if (uaRole.getBeginRange() != null && uaRole.getEndRange() != null && !uaRole.getBeginRange().equalsIgnoreCase(uaRole.getEndRange())) { range = RoleUtil.getAscendants(uaRole.getBeginRange(), uaRole.getEndRange(), uaRole.isEndInclusive(), this.contextId); if (uaRole.isBeginInclusive()) { range.add(uaRole.getBeginRange()); } if (CollectionUtils.isNotEmpty(range)) { // Does admin role have authority over a role contained with the allowable role range? if (range.contains(role.getName())) { result = true; break; } } } // Does admin role have authority over the role? else if (uaRole.getBeginRange() != null && uaRole.getBeginRange().equalsIgnoreCase(role.getName())) { result = true; break; } } } } } return result; }