/** * Returns the first value for the given key from the given map. * * @param <K> * Type of the key. * @param <V> * Type of the value. * @param map * map, must not be <code>null</code>. * @param key * key. * @return If given map contains values for the given key, returns the first * one from these values, otherwise returns <code>null</code> * */ public static <K, V> V get(MultiMap<K, V> map, K key) { Validate.notNull(map, "Map parameter must not be null."); //$NON-NLS-1$ final Collection<V> collection = map.get(key); if (collection == null || collection.isEmpty()) { return null; } return collection.iterator().next(); } }
public static boolean isEmpty(@Nullable MultiMap<?, ?> map) { return map == null || map.isEmpty(); }
private MultiMap<String, String> createRequestMap(HttpServletRequest request) { @SuppressWarnings("unchecked") final Map<String, String[]> draftMap = request.getParameterMap(); final MultiMap<String, String> source = new MultiHashMap<String, String>(draftMap.size()); for (Entry<String, String[]> entry : draftMap.entrySet()) { for (String value : entry.getValue()) { final String key = entry.getKey(); source.put(key.toLowerCase(), value); } } return source; }
tempMap.put(termAcc, termName + INTERNAL_SEPARATOR + isSyn); } else { tempMap.put(termName, termAcc); if (!tempMap.isEmpty()) { for (String nextVal : tempMap.keySet()) { Collection<String> values = tempMap.get(name); Collection<String> values = tempMap.get(acc); name = getPreferredValueForAccession(values); retval.put(acc, name);
private void parseConfigLine(String line) { //namespaces allowed_prefixes fileName sourceURL fullName "definition" [optional query URL] StringTokenizer st = new StringTokenizer(line, "\t"); if (st.countTokens() >= 6) { String namespace = st.nextToken().trim(); String prefixes = st.nextToken().trim(); String fileName = st.nextToken().trim(); String sourceURL = st.nextToken().trim(); String shortLabel = st.nextToken().trim(); String definition = st.nextToken().trim(); String queryURL = null; //still have one token, its the URL if (st.countTokens() == 1) { queryURL = st.nextToken().trim(); } ontologies.put(namespace, new Ontology(namespace, prefixes, fileName, definition, shortLabel, queryURL, sourceURL)); } else { logger.warn("Invalid ontology configuration line: " + line); } }
public static boolean isNotEmpty(@Nullable MultiMap<?, ?> map) { return map != null && !map.isEmpty(); }
private void processNameLine(String oneLine) { /* 9606 Homo sapiens scientific name 1 tax_id Unique ID of taxon. name Name of taxon. name_class Class of name. priority Priority of a name class: A numeric value that can be used to order taxonomic names according to their classes. */ String tax_id; String name; String priority; if (namesRegex.match(oneLine)) { tax_id = namesRegex.getParen(1); name = namesRegex.getParen(2); priority = namesRegex.getParen(3); nameStorage.put(tax_id, new SynHolder(Integer.parseInt(priority), name)); } else { logger.warn("Name line could not be parsed: " + oneLine); } }