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:ac.elements.io.Signature.java
/** * Gets the parameters.//from ww w .jav a2s. com * * @param keyValuePairs * the key value pairs * @param id * the id * @param key * the key * * @return the parameters * @throws SignatureException */ private static Map<String, String> getParameters(Map<String, String> keyValuePairs, String id, String key) throws SignatureException { Map<String, String> parameters = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); parameters.putAll(keyValuePairs); addRequiredParametersToRequest(parameters, id, key); return parameters; }
From source file:com.springsource.insight.plugin.apache.http.hc4.HttpClientExecutionCollectionAspectTest.java
private Map<String, String> runHeadersObfuscationTest(String testName, Collection<String> headerSet, boolean defaultHeaders) throws IOException { HttpClient httpClient = new DefaultHttpClient(); String uri = createTestUri(testName); HttpGet request = new HttpGet(uri); for (String name : headerSet) { if ("WWW-Authenticate".equalsIgnoreCase(name)) { continue; // this is a response header }//w w w . jav a 2s .c o m request.setHeader(name, name); } HttpClientExecutionCollectionAspect aspectInstance = getAspect(); HttpObfuscator obfuscator = aspectInstance.getHttpHeadersObfuscator(); if (!defaultHeaders) { for (String name : HttpObfuscator.DEFAULT_OBFUSCATED_HEADERS_LIST) { if ("WWW-Authenticate".equalsIgnoreCase(name)) { continue; // this is a response header } request.setHeader(name, name); } obfuscator.incrementalUpdate(HttpObfuscator.OBFUSCATED_HEADERS_SETTING, StringUtil.implode(headerSet, ",")); } HttpResponse response = httpClient.execute(request); Operation op = assertExecutionResult(uri, request, response, false); OperationMap reqDetails = op.get("request", OperationMap.class); OperationList reqHeaders = reqDetails.get("headers", OperationList.class); Map<String, String> requestHeaders = toHeadersMap(reqHeaders); OperationMap rspDetails = op.get("response", OperationMap.class); OperationList rspHeaders = rspDetails.get("headers", OperationList.class); Map<String, String> responseHeaders = toHeadersMap(rspHeaders); Map<String, String> hdrsMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); if (MapUtil.size(requestHeaders) > 0) { hdrsMap.putAll(requestHeaders); } if (MapUtil.size(responseHeaders) > 0) { hdrsMap.putAll(responseHeaders); } Collection<?> obscuredValues = (ObscuredValueSetMarker) obfuscator.getSensitiveValueMarker(); for (String name : headerSet) { String value = hdrsMap.get(name); assertNotNull("Missing header=" + name, value); assertTrue("Unobscured value of " + name, obscuredValues.contains(value)); } if (!defaultHeaders) { for (String name : HttpObfuscator.DEFAULT_OBFUSCATED_HEADERS_LIST) { assertFalse("Un-necessarily obscured value of " + name, obscuredValues.contains(name)); } } return hdrsMap; }
From source file:com.zyl.androidvolleyutils.MyBasicNetworkVolley.java
/** * Converts Headers[] to Map./*w w w.ja v a 2s . co m*/ * @param headers * @return Map */ protected static Map<String, String> convertHeaders(Header[] headers) { Map<String, String> result = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); for (Header header : headers) { result.put(header.getName(), header.getValue()); } return result; }
From source file:com.microsoft.tfs.core.clients.versioncontrol.internal.localworkspace.LocalDataAccessLayer.java
/** * * * * @param workspace/*w w w. java 2s.c o m*/ * @param lv * @param pc * @param changeRequests * @param silent * @param failures * @return */ public static GetOperation[] pendAdd(final Workspace workspace, final LocalWorkspaceProperties wp, final WorkspaceVersionTable lv, final LocalPendingChangesTable pc, final ChangeRequest[] changeRequests, final boolean silent, final AtomicReference<Failure[]> failures, final String[] itemPropertyFilters) { Check.notNull(workspace, "workspace"); //$NON-NLS-1$ Check.notNullOrEmpty(changeRequests, "changeRequests"); //$NON-NLS-1$ final List<Failure> failureList = new ArrayList<Failure>(); final List<GetOperation> getOps = new ArrayList<GetOperation>(); // Most duplicates filters are by WorkspaceLocalItem instance; but since // we are creating local version entries ourselves, we have to filter by // target server item. final Set<String> duplicatesFilter = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); for (final ChangeRequest changeRequest : changeRequests) { if (null == changeRequest) { continue; } // It is not legal to modify the state of a lock through a local // call. Check.isTrue( changeRequest.getLockLevel() == LockLevel.UNCHANGED || changeRequest.getLockLevel() == LockLevel.NONE, "changeRequest.getLockLevel() == LockLevel.UNCHANGED || changeRequest.getLockLevel() == LockLevel.NONE"); //$NON-NLS-1$ // The paths for PendAdd must be local items with no recursion. if (ServerPath.isServerPath(changeRequest.getItemSpec().getItem()) || RecursionType.NONE != changeRequest.getItemSpec().getRecursionType()) { throw new IllegalArgumentException(MessageFormat.format( Messages.getString("LocalDataAccessLayer.ChangeRequestMustBeLocalNonRecursiveFormat"), //$NON-NLS-1$ changeRequest.getItemSpec())); } LocalPath.checkLocalItem(changeRequest.getItemSpec().getItem(), "item", false, false, false, true); //$NON-NLS-1$ // The local item includes all pending renames of parents so we // treat it as a target server item. final String targetServerItem = WorkingFolder .getServerItemForLocalItem(changeRequest.getItemSpec().getItem(), wp.getWorkingFolders()); if (null == targetServerItem) { // We should have already validated that the path is mapped; so // if the server item is null, the item must be cloaked. failureList.add(createItemCloakedFailure(changeRequest.getItemSpec().getItem())); continue; } // Verify the length of the resultant target server item meets our // constraints. if (targetServerItem.length() > VersionControlConstants.MAX_SERVER_PATH_SIZE) { failureList.add(createPathTooLongFailure(targetServerItem)); continue; } WorkspaceLocalItem lvEntry = lv.getByLocalItem(changeRequest.getItemSpec().getItem()); LocalPendingChange pcEntry = pc.getByTargetServerItem(targetServerItem); final Failure teamProjectValidationFailure = TeamProject.validateChange(targetServerItem, changeRequest.getItemType()); // if we have a committed local version row, fall back to the error // below. if (teamProjectValidationFailure != null && (lvEntry == null || lvEntry.getVersion() == 0)) { failureList.add(teamProjectValidationFailure); continue; } else if (pcEntry != null && pcEntry.isAdd()) { // Existing pending add. Skip other validators and re-use the // existing pending change. // No change will be made to the existing pending change -- for // example the encoding will *not* be changed to respect the // encoding supplied on this ChangeRequest. } else if (pcEntry != null) { failureList .add(new Failure( MessageFormat.format( Messages.getString( "LocalDataAccessLayer.ChangeAlreadyPendingExceptionFormat"), //$NON-NLS-1$ targetServerItem), FailureCodes.CHANGE_ALREADY_PENDING_EXCEPTION, SeverityType.ERROR, changeRequest.getItemSpec().getItem())); continue; } else if (lvEntry != null && lvEntry.getVersion() != 0) { failureList.add(new Failure( MessageFormat.format(Messages.getString("LocalDataAccessLayer.ItemExistsExceptionFormat"), //$NON-NLS-1$ targetServerItem), FailureCodes.ITEM_EXISTS_EXCEPTION, SeverityType.ERROR, changeRequest.getItemSpec().getItem())); continue; } else if (pc.getRecursiveChangeTypeForTargetServerItem(targetServerItem).contains(ChangeType.DELETE)) { final String changedItem = changeRequest.getItemSpec().getItem(); failureList.add(createPendingParentDeleteFailure(targetServerItem, changedItem)); continue; } if (null == lvEntry) { lvEntry = new WorkspaceLocalItem(); lvEntry.setServerItem(targetServerItem); lvEntry.setVersion(0); lvEntry.setLocalItem(changeRequest.getItemSpec().getItem()); lvEntry.setEncoding((ItemType.FILE == changeRequest.getItemType()) ? changeRequest.getEncoding() : VersionControlConstants.ENCODING_FOLDER); lvEntry.setPendingReconcile(true); lv.add(lvEntry); } lvEntry.setPropertyValues(changeRequest.getProperties()); if (null == pcEntry) { pcEntry = new LocalPendingChange(lvEntry, targetServerItem, ChangeType.ADD_ENCODING); pcEntry.setEncoding(lvEntry.getEncoding()); pcEntry.setTargetServerItem(targetServerItem); pcEntry.setCommittedServerItem(null); if (ItemType.FILE == changeRequest.getItemType()) { pcEntry.setChangeType(pcEntry.getChangeType().combine(ChangeType.EDIT)); } if (changeRequest.getProperties() != null && changeRequest.getProperties().length > 0) { pcEntry.setChangeType(pcEntry.getChangeType().combine(ChangeType.PROPERTY)); pcEntry.setPropertyValues(changeRequest.getProperties()); } pc.pendChange(pcEntry); pc.removeCandidateByTargetServerItem(targetServerItem); } // Create the GetOperation for this pending change. if (!silent) { if (!duplicatesFilter.add(lvEntry.getServerItem())) { continue; } getOps.add(lvEntry.toGetOperation(pcEntry, itemPropertyFilters)); } } for (final Failure failure : failureList) { failure.setRequestType(RequestType.ADD); } failures.set(failureList.toArray(new Failure[failureList.size()])); return getOps.toArray(new GetOperation[getOps.size()]); }
From source file:com.opengamma.financial.analytics.curve.CurveNodeIdMapper.java
/** * Gets all fields used by the Fudge builder. * @return The fields//from ww w . j a va2 s .c o m */ protected static List<String> getCurveIdMapperNames() { final List<String> list = new ArrayList<>(); for (final Field field : CurveNodeIdMapperBuilder.class.getDeclaredFields()) { if (Modifier.isStatic(field.getModifiers()) && field.isSynthetic() == false) { field.setAccessible(true); try { list.add((String) field.get(null)); } catch (final Exception ex) { // Ignore } } } Collections.sort(list, String.CASE_INSENSITIVE_ORDER); return ImmutableList.copyOf(list); }
From source file:org.apache.directory.fortress.core.model.AdminRole.java
/** * Set a Perm OU attribute to be stored on the AdminRole entity. * * @param osP is a Perm OU that maps to 'ftOSP' attribute on 'ftPools' aux object class. *///from ww w.j av a 2 s . c om @Override public void setOsP(String osP) { if (this.osPs == null) { // create Set with case insensitive comparator: osPs = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); } osPs.add(osP); }
From source file:com.comcast.cmb.common.util.AuthUtil.java
private static String constructV1DataToSign(Map<String, String> parameters) { StringBuilder data = new StringBuilder(); SortedMap<String, String> sortedParameters = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); sortedParameters.putAll(parameters); for (String key : sortedParameters.keySet()) { data.append(key);/* ww w .j a v a 2 s. c o m*/ data.append(sortedParameters.get(key)); } return data.toString(); }
From source file:com.ichi2.libanki.Tags.java
/** Strip duplicates, adjust case to match existing tags, and sort. */ public TreeSet<String> canonify(List<String> tagList) { // NOTE: The python version creates a list of tags, puts them into a set, then sorts them. The TreeSet // used here already guarantees uniqueness and sort order, so we return it as-is without those steps. TreeSet<String> strippedTags = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); for (String t : tagList) { String s = sCanonify.matcher(t).replaceAll(""); for (String existingTag : mTags.keySet()) { if (s.equalsIgnoreCase(existingTag)) { s = existingTag;/*from ww w. j av a 2s . c o m*/ } } strippedTags.add(s); } return strippedTags; }
From source file:com.hp.alm.ali.idea.cfg.AliConfigurable.java
private static boolean containsInsensitive(Collection<String> c, String val) { TreeSet<String> ts = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); ts.addAll(c);// w w w .jav a 2 s . c o m return ts.contains(val); }
From source file:com.esri.gpt.control.search.ServletSavedSearch.java
/** * Url to param map.//from w w w . j av a2 s .c om * * @param url the url * @return the map * @throws UnsupportedEncodingException the unsupported encoding exception */ private Map<String, String> urlToParamMap(String url) throws UnsupportedEncodingException { if (url.indexOf("?") >= 0) { url = url.replace("?", ""); } String kvparams[] = url.split("&"); Map<String, String> paramMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); for (String kvpParam : kvparams) { String kvp[] = kvpParam.split("="); if (kvp.length < 2) { continue; } String key = Val.chkStr(kvp[0]); String value = URLDecoder.decode(Val.chkStr(kvp[1]), "UTF-8"); if (key.equals("")) { continue; } paramMap.put(key, value); } return paramMap; }