List of usage examples for java.util SortedMap keySet
Set<K> keySet();
From source file:com.aurel.track.exchange.excel.ExcelFieldMatchBL.java
/** * Gets a columnName to fieldID map/* w w w .j ava 2s. com*/ * @param columnIndexToFieldIDMap * @param columnIndexToColumNameMap * @return */ static Map<String, Integer> getColumnNameToFieldIDMap(Map<Integer, Integer> columnIndexToFieldIDMap, SortedMap<Integer, String> columnIndexToColumNameMap) { Map<String, Integer> columNameToFieldIDMap = new HashMap<String, Integer>(); Iterator<Integer> iterator = columnIndexToColumNameMap.keySet().iterator(); while (iterator.hasNext()) { Integer columnIndex = iterator.next(); String columnName = columnIndexToColumNameMap.get(columnIndex); if (columnIndexToFieldIDMap.containsKey(columnIndex)) { Integer fieldID = columnIndexToFieldIDMap.get(columnIndex); if (fieldID != null && fieldID.intValue() != 0) { columNameToFieldIDMap.put(columnName, columnIndexToFieldIDMap.get(columnIndex)); } } } return columNameToFieldIDMap; }
From source file:com.aurel.track.exchange.excel.ExcelFieldMatchBL.java
/** * Gets a columnIndex to fieldID map// w w w. java2 s . c om * @param columNameToFieldIDMap * @param columnIndexToColumNameMap * @return */ static Map<Integer, Integer> getColumnIndexToFieldIDMap(Map<String, Integer> columNameToFieldIDMap, SortedMap<Integer, String> columnIndexToColumNameMap) { Map<Integer, Integer> columnIndexToFieldIDMap = new HashMap<Integer, Integer>(); Iterator<Integer> iterator = columnIndexToColumNameMap.keySet().iterator(); while (iterator.hasNext()) { Integer columnIndex = iterator.next(); String columnName = columnIndexToColumNameMap.get(columnIndex); if (columNameToFieldIDMap.containsKey(columnName)) { columnIndexToFieldIDMap.put(columnIndex, columNameToFieldIDMap.get(columnName)); } } return columnIndexToFieldIDMap; }
From source file:com.opengamma.web.server.push.ViewportDefinition.java
/** * <p>Creates a {@link ViewportDefinition} from JSON. The format is:</p> * <pre>// ww w . jav a 2s . co m * {"viewDefinitionName": ... * "marketDataType": ... * "marketDataProvider": ... * "snapshotId": ... * "aggregatorName": ... * "portfolioViewport": * {"rowIds": [rowId1, rowId2, ...], * "lastTimestamps": [timestamp1, timestamp2, ...], * "dependencyGraphCells": [[row, col], [row, col], ...] * "fullConversionModeCells": [[row, col], [row, col], ...]}, * "primitiveViewport": * {"rowIds": [rowId1, rowId2, ...], * "lastTimestamps": [timestamp1, timestamp2, ...], * "dependencyGraphCells": [[row, col], [row, col], ...], * "fullConversionModeCells": [[row, col], [row, col], ...]}</pre> * <ul> * <li>{@code viewDefinitionName}: name of the view definition</li> * <li>{@code marketDataType}: {@code "live"} or {@code "snapshot"}</li> * <li>{@code marketDataProvider}: name of the market data provider. Only relevant for live data. Omit or * {@code "Automatic"} for default provider</li> * <li>{@code snapshotId}: ID of the market data snapshot (see below). Required if using a market data snapshot. * <em>TODO No testing has been done using snapshots yet, only live data</em></li> * <li>{@code portfolioViewport / primitiveViewport}: viewport definition for the separate grids showing portfolio * and primitive data</li> * <li>{@code rowIds}: The zero-based row indices whose data should be included in the results.</li> * <li>{@code lastTimestamps}: The timestamp of the last update the client received for each row. Each item * in {@code lastTimestamps} refers to the row at the same index in {@code rowIds}. Therefore {@code rowIds} and * {@code lastTimestamps} must be the same length. If no previous result has been received for the row then * {@code null} should be sent.</li> * <li>{@code dependencyGraphCells}: array of two-element arrays with the row and column numbers of cells whose * dependency graph should be included in the results.</li> * <li>{@code fullConversionModeCells}: array of two-elements arrays with the row and column numbers of cells * whose full data should be sent to the client. This is for cells that contain multi-valued data (e.g. * yield curves) where the user can open a pop-up to view the full data. This can be omitted if full data * isn't required for any cells.</li> * </ul> * @param json JSON representation of a {@link ViewportDefinition} * @return The viewport definition */ public static ViewportDefinition fromJSON(String json) { try { // TODO some of the validation should be in the constructor JSONObject jsonObject = new JSONObject(json); SortedMap<Integer, Long> portfolioRows = getRows(jsonObject, PORTFOLIO_VIEWPORT); Set<WebGridCell> portfolioDepGraphCells = getCells(jsonObject, PORTFOLIO_VIEWPORT, DEPENDENCY_GRAPH_CELLS, portfolioRows.keySet()); Set<WebGridCell> portfolioFullModeCells = getCells(jsonObject, PORTFOLIO_VIEWPORT, FULL_CONVERSION_MODE_CELLS, portfolioRows.keySet()); SortedMap<Integer, Long> primitiveRows = getRows(jsonObject, PRIMITIVE_VIEWPORT); Set<WebGridCell> primitiveDepGraphCells = getCells(jsonObject, PRIMITIVE_VIEWPORT, DEPENDENCY_GRAPH_CELLS, primitiveRows.keySet()); Set<WebGridCell> primitiveFullModeCells = getCells(jsonObject, PRIMITIVE_VIEWPORT, FULL_CONVERSION_MODE_CELLS, primitiveRows.keySet()); String viewDefinitionName = jsonObject.getString(VIEW_DEFINITION_NAME); /* TODO better data spec format? marketData: {type: live, provider: ...} marketData: {type: snapshot, snapshotId: ...} no marketData = live data from default provider? */ String marketDataTypeName = jsonObject.optString(MARKET_DATA_TYPE); MarketDataType marketDataType; if (StringUtils.isEmpty(marketDataTypeName)) { marketDataType = MarketDataType.live; } else { marketDataType = MarketDataType.valueOf(marketDataTypeName); } String marketDataProvider; UniqueId snapshotId; if (marketDataType == MarketDataType.snapshot) { // snapshot ID is compulsory if market data type is snapshot snapshotId = UniqueId.parse(jsonObject.getString(SNAPSHOT_ID)); marketDataProvider = null; } else { // market data provider is optional for live data, blank means default provider marketDataProvider = jsonObject.optString(MARKET_DATA_PROVIDER); if (StringUtils.isEmpty(marketDataProvider)) { marketDataProvider = DEFAULT_LIVE_MARKET_DATA_NAME; } snapshotId = null; } String aggregatorName = jsonObject.optString(AGGREGATOR_NAMES); if (StringUtils.isEmpty(aggregatorName)) { aggregatorName = null; } return new ViewportDefinition(viewDefinitionName, snapshotId, primitiveRows, portfolioRows, portfolioDepGraphCells, primitiveDepGraphCells, portfolioFullModeCells, primitiveFullModeCells, marketDataType, marketDataProvider, aggregatorName); } catch (JSONException e) { throw new IllegalArgumentException("Unable to create ViewportDefinition from JSON: " + json, e); } }
From source file:org.aika.network.neuron.lattice.AndNode.java
private static void prepareNextLevelPattern(Iteration t, LatticeQueue queue, int level, SortedMap<InputNode, Node> parents) { assert level == parents.size(); for (InputNode ref : parents.keySet()) { if (ref.inputNeuron != null && ref.inputNeuron.isBlocked) return; }//ww w . j a v a 2 s . c o m AndNode nlp = new AndNode(level, parents); nlp.computePatternActivations(t, queue, parents.values()); t.addedNodes.add(nlp); }
From source file:org.zaproxy.zap.spider.URLCanonicalizer.java
private static String getCleanedQuery(String escapedQuery) { // Get the parameters' names SortedMap<String, String> params = createParameterMap(escapedQuery); StringBuilder cleanedQueryBuilder = new StringBuilder(); if (params != null && !params.isEmpty()) { for (String key : params.keySet()) { // Ignore irrelevant parameters if (IRRELEVANT_PARAMETERS.contains(key) || key.startsWith("utm_")) { continue; }// ww w . j a v a 2s . c o m if (cleanedQueryBuilder.length() > 0) { cleanedQueryBuilder.append('&'); } cleanedQueryBuilder.append(key); } } return cleanedQueryBuilder.toString(); }
From source file:de.tudarmstadt.ukp.experiments.dip.wp1.documents.Step11GoldDataStatistics.java
/** * Other statistics: we want to report how many documents and sentences * were judged and how many were found relevant among those. * Having the total + standard deviation over queries is enough. *///w w w.j a va 2s .co m public static void statistics5(File inputDir, File outputDir) throws IOException { PrintWriter pw = new PrintWriter(new FileWriter(new File(outputDir, "stats5.csv"))); SortedMap<String, DescriptiveStatistics> result = new TreeMap<>(); result.put("annotatedDocumentsPerQuery", new DescriptiveStatistics()); result.put("annotatedSentencesPerQuery", new DescriptiveStatistics()); result.put("relevantSentencesPerQuery", new DescriptiveStatistics()); // print header for (String mapKey : result.keySet()) { pw.printf(Locale.ENGLISH, "%s\t%sStdDev\t", mapKey, mapKey); } pw.println(); // iterate over query containers for (File f : FileUtils.listFiles(inputDir, new String[] { "xml" }, false)) { QueryResultContainer queryResultContainer = QueryResultContainer .fromXML(FileUtils.readFileToString(f, "utf-8")); System.out.println("Processing " + f); int annotatedDocuments = 0; int relevantSentences = 0; int totalSentences = 0; for (QueryResultContainer.SingleRankedResult rankedResult : queryResultContainer.rankedResults) { if (rankedResult.plainText != null && !rankedResult.plainText.isEmpty()) { annotatedDocuments++; if (rankedResult.goldEstimatedLabels != null) { for (QueryResultContainer.SingleSentenceRelevanceVote sentenceRelevanceVote : rankedResult.goldEstimatedLabels) { totalSentences++; if (Boolean.valueOf(sentenceRelevanceVote.relevant)) { relevantSentences++; } } } } } result.get("annotatedDocumentsPerQuery").addValue(annotatedDocuments); result.get("annotatedSentencesPerQuery").addValue(totalSentences); result.get("relevantSentencesPerQuery").addValue(relevantSentences); } // print results // print header for (String mapKey : result.keySet()) { pw.printf(Locale.ENGLISH, "%.3f\t%.3f\t", result.get(mapKey).getMean(), result.get(mapKey).getStandardDeviation()); } pw.close(); }
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);/*from w w w. j a v a 2 s . co m*/ data.append(sortedParameters.get(key)); } return data.toString(); }
From source file:org.n52.movingcode.runtime.processors.java.JavaJARProcessor.java
/** * Creates an args[] object for executing a main method * /*www . j a va 2 s .co m*/ * @param paramSet * - the parameter specification * @param executionValues * - the values for the parameters */ private static String[] buildArgs(SortedMap<ParameterID, String[]> executionValues, SortedMap<ParameterID, IOParameter> paramMap) throws IllegalArgumentException { List<String> arguments = new ArrayList<String>(); // assemble commandLine with values, separators and all that stuff for (ParameterID identifier : executionValues.keySet()) { String argument = ""; // 1. add prefix argument = argument + paramMap.get(identifier).printPrefix(); // 2. add values with subsequent separator for (String value : executionValues.get(identifier)) { argument = argument + value + paramMap.get(identifier).printSeparator(); } // remove last occurrence of separator if (argument.length() != 0) { argument = argument.substring(0, argument.length() - paramMap.get(identifier).printSeparator().length()); } // 3. add suffix argument = argument + paramMap.get(identifier).printSuffix(); // 4. add to argument to CommandLine arguments.add(argument); } return arguments.toArray(new String[arguments.size()]); }
From source file:org.n52.movingcode.runtime.processors.python.PythonCLIProcessor.java
/** * Creates a CommandLine Object for execution * /*from www .j av a2 s . co m*/ * @param paramSet * - the parameter specification * @param executionValues * - the values for the parameters * @return CommandLine - an executable CommandLine */ private static CommandLine buildCommandLine(String executable, SortedMap<ParameterID, String[]> executionValues, SortedMap<ParameterID, IOParameter> paramMap) throws IllegalArgumentException { CommandLine commandLine = CommandLine.parse(executable); // assemble commandLine with values, separators and all that stuff for (ParameterID identifier : executionValues.keySet()) { String argument = ""; // 1. add prefix argument = argument + paramMap.get(identifier).printPrefix(); // 2. add values with subsequent separator for (String value : executionValues.get(identifier)) { argument = argument + value + paramMap.get(identifier).printSeparator(); } // remove last occurrence of separator if (argument.length() != 0) { argument = argument.substring(0, argument.length() - paramMap.get(identifier).printSeparator().length()); } // 3. add suffix argument = argument + paramMap.get(identifier).printSuffix(); // 4. add to argument to CommandLine commandLine.addArgument(argument, false); } return commandLine; }
From source file:edu.brown.utils.CollectionUtil.java
/** * @param <K>/* ww w.j a va2s. c o m*/ * @param <V> * @param map * @return */ public static <K extends Comparable<?>, V> List<V> getSortedList(SortedMap<K, Collection<V>> map) { List<V> ret = new ArrayList<V>(); for (K key : map.keySet()) { ret.addAll(map.get(key)); } // FOR return (ret); }