List of usage examples for java.util HashMap put
public V put(K key, V value)
From source file:com.hortonworks.amstore.view.utils.MisconfigurationFormattedException.java
protected static Response errorEntity(String name) { HashMap<String, Object> response = new HashMap<String, Object>(); response.put("message", String.format(message, name)); response.put("trace", null); response.put("status", STATUS); return Response.status(STATUS).entity(new JSONObject(response)).type(MediaType.APPLICATION_JSON).build(); }
From source file:Main.java
public static <T, K> HashMap<T, K> toMap(Collection<Entry<T, K>> entryCollection) { HashMap<T, K> map = new HashMap<T, K>(); for (Entry<T, K> entry : entryCollection) { map.put(entry.getKey(), entry.getValue()); }/*from www .jav a 2 s . c o m*/ return map; }
From source file:Main.java
public static void swapColors(BufferedImage img, Color... mapping) { int[] pixels = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth()); HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); for (int i = 0; i < mapping.length / 2; i++) { map.put(mapping[2 * i].getRGB(), mapping[2 * i + 1].getRGB()); }// ww w . j av a 2 s .c o m for (int i = 0; i < pixels.length; i++) { if (map.containsKey(pixels[i])) pixels[i] = map.get(pixels[i]); } img.setRGB(0, 0, img.getWidth(), img.getHeight(), pixels, 0, img.getWidth()); }
From source file:Main.java
public static <S> Map<Integer, S> asIndexMap(List<S> pList) { final HashMap<Integer, S> map = new HashMap<Integer, S>(pList.size()); for (final S s : pList) { map.put(pList.indexOf(s), s); }//from w w w . j ava 2s.co m return map; }
From source file:Main.java
public static HashMap<String, String> getEANHashMap(String[] eans) { HashMap<String, String> ret = new HashMap<String, String>(); for (int i = 0; i < eans.length; i++) { ret.put(eans[i], Integer.toString(i + 1)); }/*from ww w .ja v a 2 s. c o m*/ return ret; }
From source file:Main.java
public static HashMap getParamMap(Map map) { HashMap hashmap = new HashMap(); hashmap.put(encodeStr("appid"), encodeStr("1uMqYWpHo3MoLH")); hashmap.put(encodeStr("callid"), encodeStr((new StringBuilder()).append("").append(generateCallId()).toString())); hashmap.put(encodeStr("v"), encodeStr("1.0")); hashmap.put(encodeStr("lang"), encodeStr(Locale.getDefault().getLanguage())); if (map != null) { hashmap.putAll(map);/*from ww w . j a va 2 s. co m*/ } hashmap.put("bd_sig", generateBgsid(hashmap)); return hashmap; }
From source file:Main.java
public static HashMap<String, String> paserParams(String url) { String params = url.substring(url.indexOf("?") + 1); String[] arr = params.split("&"); HashMap<String, String> maps = new HashMap<String, String>(); for (String s : arr) { maps.put(s.substring(0, s.indexOf("=")), s.substring(s.indexOf("=") + 1)); }//from www . java 2s .c om return maps; }
From source file:Main.java
public static void putRepostByDay(HashMap<String, Integer> reposttimelinebyDay, String date) { if (reposttimelinebyDay.get(date) == null) { reposttimelinebyDay.put(date, 1); } else {/*from w w w .j a va 2 s . co m*/ reposttimelinebyDay.put(date, reposttimelinebyDay.get(date) + 1); } }
From source file:com.hortonworks.amstore.view.GenericException.java
protected static Response errorEntity(String message, Throwable e) { HashMap<String, Object> response = new HashMap<String, Object>(); response.put("message", message); String trace = null;//from w w w.ja va 2 s . co m if (e != null) trace = ExceptionUtils.getStackTrace(e); response.put("trace", trace); response.put("status", STATUS); return Response.status(STATUS).entity(new JSONObject(response)).type(MediaType.APPLICATION_JSON).build(); }
From source file:net.ecfirm.ec.ec1.net.EcNetHelper.java
public static HashMap<String, String> getApiHttp(String nameCom, String nameKey, String task, String[] keys, String[] values) {/*w ww .java 2 s .c om*/ ////////FIXME if (task.equals("getItems")) { nameKey = nameKey + "s"; task = "display"; } //////// HashMap<String, String> box = new HashMap<>(); box.put(EcConst.NET_API_HTTP_1, "?option=com_ec" + nameCom + "&format=json&task=" + nameKey + "." + task); int i = 0; for (String value : values) { if (!value.isEmpty()) box.put(keys[i], value); i++; } return box; }