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:com.fbr.services.SecurityService.java
public Map<String, String> splitQuery(String queryString) throws UnsupportedEncodingException { final Map<String, String> query_pairs = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); final String[] pairs = queryString.split("&"); for (String pair : pairs) { final int idx = pair.indexOf("="); final String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), "UTF-8") : pair; final String value = idx > 0 && pair.length() > idx + 1 ? URLDecoder.decode(pair.substring(idx + 1), "UTF-8") : null;/*w w w . ja v a 2 s .c o m*/ query_pairs.put(key, value); } return query_pairs; }
From source file:com.amazonaws.cbui.AmazonFPSCBUIPipeline.java
/** * Calculate String to Sign for SignatureVersion 1 * /* w ww. j ava 2 s . c o m*/ * @param parameters request parameters * @return String to Sign * @throws java.security.SignatureException */ private static String calculateStringToSignV1(Map<String, String> parameters) { StringBuilder data = new StringBuilder(); Map<String, String> sorted = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); sorted.putAll(parameters); Iterator<Map.Entry<String, String>> pairs = sorted.entrySet().iterator(); while (pairs.hasNext()) { Map.Entry<String, String> pair = pairs.next(); if (pair.getKey().equalsIgnoreCase(SIGNATURE_KEYNAME)) continue; data.append(pair.getKey()); data.append(pair.getValue()); } return data.toString(); }
From source file:com.qmetry.qaf.automation.step.client.AbstractScenarioFileParser.java
@SuppressWarnings("unchecked") protected int parseScenario(Object[][] statements, int statementIndex, String referece, List<Scenario> scenarios) { String description = statements[statementIndex].length > 2 ? (String) statements[statementIndex][2] : ""; String stepName = statements[statementIndex].length > 1 ? ((String) statements[statementIndex][1]).trim() : ""; int lineNo = getLineNum(statements, statementIndex); // collect all steps of scenario Collection<TestStep> steps = new ArrayList<TestStep>(); Map<String, Object> metadata = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER); if (StringUtil.isNotBlank(description)) { metadata.putAll(gson.fromJson(description, Map.class)); }/*ww w .j a va2 s . c o m*/ metadata.put("referece", referece); metadata.put("lineNo", lineNo); /** * check enabled flag in meta-data and apply groups filter if configured * in xml configuration file. the custom meta-data filter will covered * in method filter where it will not include groups from xml * configuration file. */ if (include(includeGroups, excludeGroups, metadata)) { String dataProvider = getDP(metadata); Scenario scenario = StringUtil.isBlank(dataProvider) ? new Scenario(stepName, steps, metadata) : new DataDrivenScenario(stepName, steps, dataProvider, metadata); scenarios.add(scenario); } else { logger.debug("Excluded SCENARIO - " + stepName + ":" + metadata.get(DESCRIPTION)); } String nextSteptype = ""; do { statementIndex++; lineNo = getLineNum(statements, statementIndex); String currStepName = (String) statements[statementIndex][0]; if (!currStepName.equalsIgnoreCase(END)) { TestStep step = parseStepCall(statements[statementIndex], referece, lineNo); steps.add(step); } if (statements.length > (statementIndex + 2)) { nextSteptype = ((String) statements[statementIndex + 1][0]).trim(); } else { nextSteptype = END; // EOF } } while (!(nextSteptype.equalsIgnoreCase(STEP_DEF) || nextSteptype.equalsIgnoreCase(SCENARIO) || nextSteptype.equalsIgnoreCase(END) || nextSteptype.equalsIgnoreCase(TEST_DATA))); return statementIndex; }
From source file:com.hichinaschool.flashcards.libanki.Tags.java
/** Strip duplicates and sort. */ public TreeSet<String> canonify(List<String> tagList) { TreeSet<String> tree = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); tree.addAll(tagList);//from ww w . ja v a 2 s. c om return tree; }
From source file:org.apache.directory.fortress.core.impl.RoleUtil.java
/** * * @param roles//w ww . ja v a2 s. c om * @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com. * @return set of ascendant roles associated with this entry. */ static Set<String> getAscendantRoles(List<String> roles, String contextId) { // create Set with case insensitive comparator: Set<String> iRoles = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); if (CollectionUtils.isNotEmpty(roles)) { for (String role : roles) { iRoles.add(role); Set<String> parents = HierUtil.getAscendants(role, getGraph(contextId)); if (CollectionUtils.isNotEmpty(parents)) { iRoles.addAll(parents); } } } return iRoles; }
From source file:com.hanuor.pearl.toolbox.BasicNetwork.java
protected static Map<String, String> convertHeaders(Header[] headers) { Map<String, String> result = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); for (int i = 0; i < headers.length; i++) { result.put(headers[i].getName(), headers[i].getValue()); }// w w w . ja va2 s . c o m return result; }
From source file:org.jkcsoft.java.util.JndiHelper.java
public static void logLdap(Log plog, int level, int nth, Object dirEntry) throws NamingException { try {/*from www .jav a 2s .c o m*/ if (dirEntry instanceof NamingEnumeration) { NamingEnumeration nameEnum = (NamingEnumeration) dirEntry; JndiHelper.logLevel(plog, level, nth, "Naming Enumeration: " + nameEnum); try { int nthThis = 0; List nameList = new Vector(Collections.list(nameEnum)); Collections.sort(nameList, new Comparator() { public int compare(Object o1, Object o2) { if (o1 instanceof Attribute) { return String.CASE_INSENSITIVE_ORDER.compare(((Attribute) o1).getID(), ((Attribute) o2).getID()); } return 0; } }); Iterator nameIter = nameList.iterator(); while (nameIter.hasNext()) { logLdap(plog, level + 1, nthThis++, nameIter.next()); } } catch (NamingException ex) { plog.error("Exception iterating thru NamingEnumeration: " + ex.getMessage()); } } else if (dirEntry instanceof Attribute) { Attribute dirAttr = (Attribute) dirEntry; JndiHelper.logLevel(plog, level, nth, "Attribute: [" + dirAttr + "]"); } else if (dirEntry instanceof DirContext) { DirContext lctx = (DirContext) dirEntry; JndiHelper.logLevel(plog, level, nth, "LDAP Context: DN [" + lctx.getNameInNamespace() + "]" + " Attributes ==>"); logLdap(plog, level, nth, lctx.getAttributes("").getAll()); } else if (dirEntry instanceof SearchResult) { SearchResult sr = (SearchResult) dirEntry; JndiHelper.logLevel(plog, level, nth, "SearchResult: ClassName of Bound Object [" + sr.getClassName() + "]" + " Name: [" + sr.getName() + "]" + " Bound Object ==>"); // sr.s logLdap(plog, level, nth, sr.getObject()); logLdap(plog, level, nth, sr.getAttributes().getAll()); } else { JndiHelper.logLevel(plog, level, nth, "(?) class of entry: [" + dirEntry + "]"); } nth++; } catch (NamingException e1) { plog.error("Naming Exception (will try to continue): " + e1.getMessage()); } }
From source file:de.ingrid.portal.portlets.mdek.MdekAdminLoginPortlet.java
/** * This function looks for all connected catalogs and its' users and returns them. * //from www. j ava 2s .c o m * @return a hashmap with * CATALOG: contains information of found catalogs * USER_OF_CATALOG: contains all users found in each catalog; it's a list of a list * and has the same order as the catalogs, which means that the first list contains * the users for the first catalog, the second list the users for the second catalog, ... */ private Map<String, List> buildConnectedCatalogList() { Map<String, List> dataContainer = new HashMap<String, List>(); List<Map<String, String>> catalogList = new ArrayList<Map<String, String>>(); List<List> userLists = new ArrayList<List>(); Session s = HibernateUtil.currentSession(); s.beginTransaction(); // query all connected iPlugs/catalogs for (String plugId : this.mdekClientCaller.getRegisteredIPlugs()) { List<UserData> userDataList = (List<UserData>) s.createCriteria(UserData.class) .add(Restrictions.eq("plugId", plugId)).list(); List<String> userList = new ArrayList<String>(); // get users that belong to the iPlug (are mdek user) for (UserData userData : userDataList) { userList.add('"' + userData.getPortalLogin() + '"'); } if (log.isDebugEnabled()) { log.debug("Total users found: " + userList.size() + " (" + plugId + ")"); } // sort users Collections.sort(userList, String.CASE_INSENSITIVE_ORDER); userLists.add(userList); if (userDataList != null && userDataList.size() != 0) { HashMap<String, String> catalogData = new HashMap<String, String>(); UserData userData = userDataList.get(0); IMdekCallerCatalog mdekCallerCatalog = MdekCallerCatalog.getInstance(); IngridDocument cat = mdekCallerCatalog.fetchCatalog(plugId, userData.getAddressUuid()); String catName = ""; try { CatalogBean catBean = MdekCatalogUtils.extractCatalogFromResponse(cat); catName = catBean.getCatalogName(); } catch (Exception e) { log.error("Problems extracting catalog data for iPlug " + plugId, e); catName = "ERROR, see log !"; } // Display the catalogData catalogData.put("plugId", plugId); catalogData.put("catName", catName); catalogList.add(catalogData); } } s.getTransaction().commit(); HibernateUtil.closeSession(); // put all necessary data in another hashmap dataContainer.put(USER_OF_CATALOG, userLists); dataContainer.put(CATALOG, catalogList); return dataContainer; }
From source file:com.xpn.xwiki.plugin.tag.TagPlugin.java
/** * Get cardinality map of tags matching a parameterized hql query. * //www . j ava2 s .c om * @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. * @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 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 BaseObject as tagobject, DBStringListProperty as prop"; String where = " where 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 += ", XWikiDocument as doc" + fromHql; } if (!StringUtils.isBlank(whereHql)) { where += " and doc.fullName=tagobject.name and " + whereHql; } List<?> params = parameterValues; if (params == null) { params = new ArrayList<String>(); } results = context.getWiki().getStore().search(from + where, 0, 0, params, context); 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:com.aitangba.volley.BasicNetwork.java
/** * Converts Headers[] to Map<String, String>. *///from ww w . ja v a 2 s .c o m protected static Map<String, String> convertHeaders(Map<String, String> headers) { Map<String, String> result = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); if (headers != null && headers.size() > 0) { for (String key : headers.keySet()) { result.put(key, headers.get(key)); } } return result; }