List of usage examples for java.util Map entrySet
Set<Map.Entry<K, V>> entrySet();
From source file:org.springmodules.cache.util.Reflections.java
private static int reflectionHashCode(Map map) { int hash = INITIAL_HASH; for (Iterator i = map.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); hash = MULTIPLIER * hash + reflectionHashCode(entry); }/*from w ww . j a v a2 s. c o m*/ return hash; }
From source file:org.lightjason.agentspeak.action.builtin.rest.IBaseRest.java
/** * transformas a map into a literal/* www . j av a 2s.co m*/ * * @param p_map input map * @return term stream */ @Nonnull private static Stream<ITerm> flatmap(@Nonnull final Map<String, ?> p_map) { return p_map.entrySet().stream().map(i -> CLiteral .from(i.getKey().toLowerCase().replaceAll("[^([a-z][0-9]\\-/_)]]", "_"), flatterm(i.getValue()))); }
From source file:jenajsonld.JsonLDWriter.java
private static void addPrefixes(Map<String, Object> ctx, PrefixMap prefixMap) { Map<String, IRI> pmap = prefixMap.getMapping(); for (Entry<String, IRI> e : pmap.entrySet()) { ctx.put(e.getKey(), e.getValue().toString()); }/*from w w w . j a va2s . c om*/ }
From source file:com.parse.ParseRESTQueryCommand.java
static <T extends ParseObject> Map<String, String> encode(ParseQuery.State<T> state, boolean count) { ParseEncoder encoder = PointerEncoder.get(); HashMap<String, String> parameters = new HashMap<>(); List<String> order = state.order(); if (!order.isEmpty()) { parameters.put("order", ParseTextUtils.join(",", order)); }/*from w w w. j a va 2 s . com*/ ParseQuery.QueryConstraints conditions = state.constraints(); if (!conditions.isEmpty()) { JSONObject encodedConditions = (JSONObject) encoder.encode(conditions); parameters.put("where", encodedConditions.toString()); } // This is nullable since we allow unset selectedKeys as well as no selectedKeys Set<String> selectedKeys = state.selectedKeys(); if (selectedKeys != null) { parameters.put("keys", ParseTextUtils.join(",", selectedKeys)); } Set<String> includeds = state.includes(); if (!includeds.isEmpty()) { parameters.put("include", ParseTextUtils.join(",", includeds)); } if (count) { parameters.put("count", Integer.toString(1)); } else { int limit = state.limit(); if (limit >= 0) { parameters.put("limit", Integer.toString(limit)); } int skip = state.skip(); if (skip > 0) { parameters.put("skip", Integer.toString(skip)); } } Map<String, Object> extraOptions = state.extraOptions(); for (Map.Entry<String, Object> entry : extraOptions.entrySet()) { Object encodedExtraOptions = encoder.encode(entry.getValue()); parameters.put(entry.getKey(), encodedExtraOptions.toString()); } if (state.isTracingEnabled()) { parameters.put("trace", Integer.toString(1)); } return parameters; }
From source file:com.shz.foundation.service.dynamic.SearchFilter.java
/** * searchParamskey?OPERATOR_FIELDNAME//from w w w . j av a 2 s. co m */ public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) { Map<String, SearchFilter> filters = Maps.newHashMap(); for (Entry<String, Object> entry : searchParams.entrySet()) { // String key = entry.getKey(); Object value = entry.getValue(); if (StringUtils.isBlank((String) value)) { continue; } // operatorfiledAttribute String[] names = StringUtils.split(key, "_"); if (names.length != 2) { throw new IllegalArgumentException(key + " is not a valid search filter name"); } String filedName = names[1]; Operator operator = Operator.fromString(names[0]); // searchFilter SearchFilter filter = new SearchFilter(filedName, operator, value); filters.put(key, filter); } return filters; }
From source file:hu.ppke.itk.nlpg.purepos.common.Util.java
public static <K> Map.Entry<K, Double> findMax(Map<K, Double> map) { Map.Entry<K, Double> ret = null; for (Map.Entry<K, Double> e : map.entrySet()) { if (ret == null || e.getValue() > ret.getValue()) { ret = e;/*from w w w . j av a 2 s .c o m*/ } } return ret; }
From source file:jp.go.nict.langrid.foundation.servlet.ResponseProcessor.java
private static void addLangridHeaders(Map<String, List<String>> src, HttpServletResponse dst) { for (Map.Entry<String, List<String>> e : src.entrySet()) { if (e.getKey().startsWith("X-LanguageGrid-")) { for (String v : e.getValue()) { dst.addHeader(e.getKey(), v); }//from w ww . j a v a 2s . c om } } }
From source file:de.christianseipl.utilities.maputils.MapPrinting.java
public static <K, L, M, V> void printThreeDimensionalMap(String _header, Map<K, Map<L, Map<M, V>>> _map) { System.out.println(_header);/*from w ww. ja v a 2s .c o m*/ for (Entry<K, Map<L, Map<M, V>>> first : _map.entrySet()) { System.out.println(first.getKey().toString()); for (Entry<L, Map<M, V>> second : first.getValue().entrySet()) { System.out.println( String.format("%20s\t%20s", first.getKey().toString(), second.getKey().toString())); for (Entry<M, V> third : second.getValue().entrySet()) { System.out.println(String.format("%20s\t%20s\t%20s\t%20s", first.getKey().toString(), second.getKey().toString(), third.getKey().toString(), third.getValue().toString())); } System.out.println(); } System.out.println(); } System.out.println(); }
From source file:de.micromata.mgc.jpa.hibernatesearch.bridges.TabAttrFieldBridge.java
public static void addToIndex(String prefix, Object value, Document document, LuceneOptions luceneOptions) { if ((value instanceof Map) == false) { return;/*from www. ja va 2 s . c o m*/ } Map rawmap = (Map) value; if (rawmap.isEmpty() == true) { return; } Set<Map.Entry> mes = rawmap.entrySet(); for (Map.Entry me : mes) { if ((me.getKey() instanceof String) == false || (me.getValue() instanceof JpaTabAttrBaseDO) == false) { LOG.error("Bridge to incompatible type: " + me.getKey() + "=" + me.getValue()); continue; } String key = (String) me.getKey(); JpaTabAttrBaseDO<?, ?> attr = (JpaTabAttrBaseDO<?, ?>) me.getValue(); String svalue = attr.getStringData(); svalue = StringUtils.defaultString(svalue); Field field = new StringField(key, svalue, DEFAULT_STORE); document.add(field); field = new StringField("ALL", svalue, DEFAULT_STORE); document.add(field); field = new StringField("propertyName", key, DEFAULT_STORE); document.add(field); field = new StringField("value", svalue, DEFAULT_STORE); document.add(field); } }
From source file:Main.java
/** * Convenience function for creating elements. * //ww w. j a va2 s .c o m * @param document * the DOM document we're creating the element in * @param name * the tagname for the element * @param attributes * a map from attribute names to attributes, or <CODE>null</CODE> * if this element should have no attributes * @param text * the text for the element, which will be made into a text node * and added as a child of the created element, or <CODE>null</CODE> * if the element should have no children * @return a new element */ public static Element createElement(Document doc, String name, Object text, Map<String, Object> attributes) { Element e = doc.createElement(name); // Set the attributes. if (attributes != null) { for (Entry<String, Object> entry : attributes.entrySet()) { e.setAttribute(entry.getKey(), entry.getValue().toString()); } } // Add the text element. if (text != null) e.appendChild(createTextNode(doc, text.toString())); return e; }