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:pt.webdetails.cdf.dd.render.components.ComponentManager.java
private void processFiles(String dirPath, File dir, String[] files) { if (files != null) { Arrays.sort(files, String.CASE_INSENSITIVE_ORDER); for (String file : files) { try { String basePath = Utils.joinPath(dir.getPath(), file); String xmlPath = Utils.joinPath(basePath, COMPONENT_FILE); Document doc;//from www . j a v a 2 s . c o m try { doc = XmlDom4JHelper.getDocFromFile(basePath, null); } catch (Exception e) { doc = XmlDom4JHelper.getDocFromFile(xmlPath, null); } // To support multiple definitions on the same file, we'll iterate // through all the DesignerComponent nodes List<Node> components = doc.selectNodes("//DesignerComponent"); if (logger.isDebugEnabled() && components.size() > 0) { logger.debug("\t" + file + " [" + components.size() + "]"); } for (Node component : components) { // To figure out whether the component is generic or has a special // implementation, we directly look for the class override in the definition String className = XmlDom4JHelper.getNodeText("Override", component); if (className != null) { BaseComponent renderer = rendererFromClass(className); if (renderer != null) { componentPool.put(renderer.getName(), renderer); } } else { CustomComponent renderer = new CustomComponent(Utils.joinPath(dirPath, file)); if (renderer != null) { renderer.setDefinition(component); componentPool.put(renderer.getName(), renderer); } } } } catch (Exception e) { Logger.getLogger(ComponentManager.class.getName()).log(Level.SEVERE, null, e); } } } }
From source file:com.metamx.druid.merger.common.task.MergeTask.java
private static DataSegment computeMergedSegment(final String dataSource, final String version, final List<DataSegment> segments) { final Interval mergedInterval = computeMergedInterval(segments); final Set<String> mergedDimensions = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER); final Set<String> mergedMetrics = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER); for (DataSegment segment : segments) { mergedDimensions.addAll(segment.getDimensions()); mergedMetrics.addAll(segment.getMetrics()); }//w ww .jav a 2 s . c o m return DataSegment.builder().dataSource(dataSource).interval(mergedInterval).version(version) .shardSpec(new NoneShardSpec()).dimensions(Lists.newArrayList(mergedDimensions)) .metrics(Lists.newArrayList(mergedMetrics)).build(); }
From source file:com.android.calendar.event.EventLocationAdapter.java
/** * Post-process the query results to return the first MAX_LOCATION_SUGGESTIONS * unique locations in alphabetical order. * <p/>/*from w w w .jav a 2 s .c o m*/ * TODO: Refactor to share code with the recent titles auto-complete. */ private static List<Result> processLocationsQueryResults(Cursor cursor) { TreeSet<String> locations = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); cursor.moveToPosition(-1); // Remove dupes. while ((locations.size() < MAX_LOCATION_SUGGESTIONS) && cursor.moveToNext()) { String location = cursor.getString(EVENT_INDEX_LOCATION).trim(); locations.add(location); } // Copy the sorted results. List<Result> results = new ArrayList<Result>(); for (String location : locations) { results.add(new Result(null, location, R.drawable.ic_history_holo_light, null)); } return results; }
From source file:com.ebay.erl.mobius.core.Persistable.java
/** * Save the dataset and store the <code>projections</code> * into a the specified <code>output</code> path in the * format of the given <code>outputFormat</code>. * <p>/*from www . java 2 s. co m*/ * * Only the rows that meet the <code>criteria</code> will be * stored. The <code>criteria</code> can only evaluate the * columns specified in the <code>projections</code>. * <p> * * <code>output</code> will be deleted before the job gets started. */ public Dataset save(MobiusJob job, Path output, Class<? extends FileOutputFormat> outputFormat, TupleCriterion criteria, Projectable... projections) throws IOException { if (projections == null || projections.length == 0) throw new IllegalArgumentException("Please specify the output columns."); // - VALIDATION - make sure no ambiguous column names. // // make sure the projections don't have two or more different columns that // have the same name but in different dataset, as we are going the use // the {@link Column#getOutputColumnName} as the output schema of the // returned dataset. Set<String> columnNames = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); for (Projectable aColumn : projections) { String[] outputSchema = aColumn.getOutputSchema(); for (String anOutput : outputSchema) { if (!columnNames.contains(anOutput)) { columnNames.add(anOutput); } else { throw new IllegalArgumentException(columnNames + " from " + aColumn.toString() + " is ambiguous, it has the same name" + "as aother selected projected in different dataset, please use Column#setNewName(String) to" + "change it."); } } } // - VALIDATION - if <code>criteria</code> is not null, need to make // sure the columns used in the criteria are in the output columns. if (criteria != null) { TupleCriterion.validate(columnNames, criteria); this.jobConf.set(ConfigureConstants.PERSISTANT_CRITERIA, SerializableUtil.serializeToBase64(criteria)); } // setup {@link Dataset} to {@link Column} mapping so we can setup projection columns // for each dataset, and also perform validation on making sure all the projection columns // are from the selected <code>datasets</code> only, Map<Dataset, List<Column>> datasetToColumns = new HashMap<Dataset, List<Column>>(); for (Projectable aFunc : projections) { Column[] requiredInputColumns = aFunc.getInputColumns(); for (Column aColumn : requiredInputColumns) { Dataset aDataset = aColumn.getDataset(); // make sure the <code>aDataset</code> within the participated datasets boolean withinSelectedDataset = false; for (Dataset aSelectedDataset : this.datasets) { if (aSelectedDataset.equals(aDataset)) { withinSelectedDataset = true; break; } } if (!withinSelectedDataset) { // user select a column from a dataset that doesn't // in the selected datasets in this join/group by job. throw new IllegalArgumentException(aColumn.toString() + " does not within the selected datasets " + "in this join/group task, please select columns only from the selected datasets."); } List<Column> projectablesInADataset = null; if ((projectablesInADataset = datasetToColumns.get(aDataset)) == null) { projectablesInADataset = new LinkedList<Column>(); datasetToColumns.put(aDataset, projectablesInADataset); } if (!projectablesInADataset.contains(aColumn)) projectablesInADataset.add(aColumn); } } if (datasetToColumns.keySet().size() != this.datasets.length) { throw new IllegalArgumentException( "Please select at least one column from each dataset in the join/group-by job."); } // SETUP JOB if (this.userDefinedConf != null) { this.jobConf = new JobConf(Util.merge(this.jobConf, this.userDefinedConf)); } this.jobConf.setJarByClass(job.getClass()); this.jobConf.setMapOutputKeyClass(DataJoinKey.class); this.jobConf.setMapOutputValueClass(DataJoinValue.class); this.jobConf.setPartitionerClass(DataJoinKeyPartitioner.class); this.jobConf.setOutputValueGroupingComparator(DataJoinKey.Comparator.class); this.jobConf.setOutputKeyComparatorClass(DataJoinKey.class); this.jobConf.setReducerClass(DefaultMobiusReducer.class); this.jobConf.set(ConfigureConstants.PROJECTION_COLUMNS, SerializableUtil.serializeToBase64(projections)); JobSetup.setupOutputs(this.jobConf, output, outputFormat); // setup input paths, projection columns for each datasets. for (byte assignedDatasetID = 0; assignedDatasetID < this.datasets.length; assignedDatasetID++) { Dataset aDataset = this.datasets[assignedDatasetID]; // setup input for each dataset JobSetup.setupInputs(jobConf, aDataset, assignedDatasetID); // setup projection for each dataset JobSetup.setupProjections(jobConf, aDataset, assignedDatasetID, datasetToColumns.get(aDataset).toArray(new Column[0])); } // setup all dataset IDs for (int i = 0; i < this.datasets.length; i++) { Byte id = this.datasets[i].getID(); if (!this.jobConf.get(ConfigureConstants.ALL_DATASET_IDS, "").isEmpty()) { this.jobConf.set(ConfigureConstants.ALL_DATASET_IDS, this.jobConf.get(ConfigureConstants.ALL_DATASET_IDS) + "," + id); } else { this.jobConf.set(ConfigureConstants.ALL_DATASET_IDS, id.toString()); } } boolean isCombinable = true; for (Projectable aFunc : projections) { aFunc.setConf(jobConf); if (!aFunc.isCombinable()) { isCombinable = false; LOGGER.info(aFunc.toString() + " is not combinable, #isCombinable() return false."); break; } if (aFunc instanceof GroupFunction && aFunc.useGroupKeyOnly()) { LOGGER.info(aFunc.toString() + " is a group function and use group key as its input only, disable combiner."); isCombinable = false; break; } } LOGGER.info("Using Combiner? " + isCombinable); if (isCombinable) { jobConf.setCombinerClass(DefaultMobiusCombiner.class); } job.addToExecQueue(jobConf); AbstractDatasetBuilder builder = DatasetBuildersFactory.getInstance(job).getBuilder(outputFormat, "Dataset_" + output.getName()); // form the output column from the projections List<String> outputColumns = new ArrayList<String>(); for (Projectable func : projections) { String[] aProjectOutputs = func.getOutputSchema(); for (String anOutputName : aProjectOutputs) { outputColumns.add(anOutputName); } } return builder.buildFromPreviousJob(jobConf, outputFormat, outputColumns.toArray(new String[0])); }
From source file:org.pharmgkb.Genotype.java
public String getMetabolizerStatus() { if (this.getStrings().isEmpty()) { return getText(Metabolizer.Unknown); }/*from w ww . ja va2 s . c om*/ List<String> genotypes = new ArrayList<String>(); for (String allele : this.getStrings()) { if (allele != null && !allele.equals("Unknown") && !metabMap.keySet().contains(ItpcUtils.alleleStrip(allele))) { sf_logger.warn("Can't find map for allele: " + ItpcUtils.alleleStrip(allele)); } genotypes.add(getText(metabMap.get(ItpcUtils.alleleStrip(allele)))); } StringBuilder genoBuilder = new StringBuilder(); Collections.sort(genotypes, String.CASE_INSENSITIVE_ORDER); for (int x = 0; x < genotypes.size(); x++) { genoBuilder.append(genotypes.get(x)); if (x != genotypes.size() - 1) { genoBuilder.append("/"); } } return genoBuilder.toString(); }
From source file:org.usergrid.utils.MapUtils.java
public static <A> Map<String, A> merge(Map<String, A>... maps) { Map<String, A> merged = new TreeMap<String, A>(String.CASE_INSENSITIVE_ORDER); for (Map<String, A> m : maps) { merged.putAll(m);//w w w . j a v a 2 s. c o m } return merged; }
From source file:com.springsource.insight.plugin.apache.http.hc3.HttpClientExecutionCollectionAspectTest.java
private Map<String, String> runHeadersObfuscationTest(String testName, Collection<String> headerSet, boolean defaultHeaders) throws IOException { HttpClient httpClient = new HttpClient(); String uri = createTestUri(testName); HttpMethod method = new GetMethod(uri); for (String name : headerSet) { if ("WWW-Authenticate".equalsIgnoreCase(name)) { continue; // this is a response header }/*from w ww. ja v a2s. co m*/ method.addRequestHeader(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 } method.addRequestHeader(name, name); } obfuscator.incrementalUpdate(HttpObfuscator.OBFUSCATED_HEADERS_SETTING, StringUtil.implode(headerSet, ",")); } int response = httpClient.executeMethod(method); Operation op = assertExecutionResult(uri, method, 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 value for 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.microsoft.windowsazure.mobileservices.sdk.testapp.test.SystemPropertiesTests.java
private void insertDoesNotRemovePropertyWhenIdIsString(final String property) throws Throwable { final String tableName = "MyTableName"; final String jsonTestSystemProperty = property.replace("\\", "\\\\").replace("\"", "\\\""); final String responseContent = "{\"id\":\"an id\",\"String\":\"Hey\"}"; MobileServiceClient client = null;/*from ww w. j av a2 s .c o m*/ try { client = new MobileServiceClient(appUrl, appKey, getInstrumentation().getTargetContext()); } catch (MalformedURLException e) { e.printStackTrace(); } // Add a filter to handle the request and create a new json // object with an id defined client = client.withFilter(getTestFilter(responseContent)); client = client.withFilter(new ServiceFilter() { @Override public ListenableFuture<ServiceFilterResponse> handleRequest(ServiceFilterRequest request, NextServiceFilterCallback nextServiceFilterCallback) { String content = request.getContent(); JsonObject obj = new JsonParser().parse(content).getAsJsonObject(); Map<String, JsonElement> properties = new TreeMap<String, JsonElement>( String.CASE_INSENSITIVE_ORDER); for (Entry<String, JsonElement> entry : obj.entrySet()) { properties.put(entry.getKey(), entry.getValue()); } assertTrue(properties.containsKey("id")); assertTrue(properties.containsKey("String")); assertTrue(properties.containsKey(property)); return nextServiceFilterCallback.onNext(request); } }); // Create get the MobileService table MobileServiceJsonTable msTable = client.getTable(tableName); JsonObject obj = new JsonParser() .parse("{\"id\":\"an id\",\"String\":\"what\",\"" + jsonTestSystemProperty + "\":\"a value\"}") .getAsJsonObject(); try { // Call the insert method JsonObject jsonObject = msTable.insert(obj).get(); // Asserts if (jsonObject == null) { fail("Expected result"); } } catch (Exception exception) { fail(exception.getMessage()); } }
From source file:com.msopentech.odatajclient.engine.communication.request.batch.ODataBatchUtilities.java
/** * Retrieves headers of the next batch item. * * @param iterator batch line iterator./*www. java 2s . com*/ * @param boundary batch boundary. * @return batch item headers. */ public static Map<String, Collection<String>> nextItemHeaders(final ODataBatchLineIterator iterator, final String boundary) { final Map<String, Collection<String>> headers = new TreeMap<String, Collection<String>>( String.CASE_INSENSITIVE_ORDER); final String line = ODataBatchUtilities.readBatchPart(new ODataBatchController(iterator, boundary), true); if (line != null && line.trim().equals(boundary)) { ODataBatchUtilities.readHeaders(iterator, headers); } LOG.debug("Retrieved batch item headers {}", headers); return headers; }
From source file:com.android.volley.toolbox.BasicNetwork.java
/** * Converts Headers[] to Map<String, String>. *//* ww w . j a va 2s . c om*/ 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()); } return result; }