List of usage examples for java.util HashMap put
public V put(K key, V value)
From source file:edu.cornell.mannlib.vitro.webapp.utils.ConceptSearchService.ConceptSearchServiceUtils.java
private static HashMap<String, String> getMapping() { HashMap<String, String> map = new HashMap<String, String>(); map.put(UMLSVocabSource, "edu.cornell.mannlib.semservices.service.impl.UMLSService"); map.put(AgrovocVocabSource, "edu.cornell.mannlib.semservices.service.impl.AgrovocService"); map.put(GemetVocabSource, "edu.cornell.mannlib.semservices.service.impl.GemetService"); map.put(LCSHVocabSource, "edu.cornell.mannlib.semservices.service.impl.LCSHService"); return map;// ww w .j a va 2 s .co m }
From source file:Main.java
public static HashMap<String, String> getApiPost(String[] keys, String[] values) { HashMap<String, String> box = new HashMap<>(); int i = 0;//from w w w. ja va2 s.c o m for (String value : values) { if (!value.isEmpty()) box.put(keys[i], value); i++; } return box; }
From source file:com.cognifide.cq.cqsm.core.scripts.ScriptUtils.java
public static String toJson(List<Script> scripts) { final List<Map<String, Object>> results = new ArrayList<>(); for (final Script script : scripts) { final HashMap<String, Object> result = new HashMap<>(); result.put("name", FilenameUtils.getBaseName(script.getPath())); result.put("path", script.getPath()); result.put("verified", script.isValid()); result.put("executionEnabled", script.isExecutionEnabled()); result.put("executionMode", script.getExecutionMode()); result.put("executionSchedule", script.getExecutionSchedule()); results.add(result);//from w w w. j av a 2 s .c om } return GSON.toJson(results); }
From source file:com.splunk.shuttl.server.mbeans.rest.RestUtil.java
/** * @param thawedBucketBeans/*from ww w.ja v a 2 s. co m*/ * @param failedBucketBeans * @return */ public static String writeBucketAction(List<BucketBean> successfulBuckets, Object failedObjects) { HashMap<String, Object> response = new HashMap<String, Object>(); response.put("buckets", successfulBuckets); response.put("failed", failedObjects); return RestUtil.writeMapAsJson(response); }
From source file:Main.java
public static HashMap getSysParamMap(Map map) { HashMap hashmap = new HashMap(); HashMap hashmap1 = 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())); hashmap1.putAll(hashmap);/*from w w w .ja v a 2s . co m*/ if (map != null) { hashmap1.putAll(map); } hashmap.put("bd_sig", generateBgsid(hashmap1)); return hashmap; }
From source file:com.clz.share.sec.util.SignInUtils.java
public static ResponseEntity<?> getToken(Principal principal) throws HttpRequestMethodNotSupportedException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("client_id", "appid"); parameters.put("client_secret", "myOAuthSecret"); parameters.put("grant_type", "password"); parameters.put("username", "user"); parameters.put("password", "pass"); parameters.put("scope", "read write"); return tokenEndpoint.getAccessToken(principal, parameters); }
From source file:Main.java
private static HashMap<Date, Date> getBookedTimeInOneDate(HashMap<Date, Date> bookedTimes, Date date) { HashMap<Date, Date> result = new HashMap<>(); for (Date key : bookedTimes.keySet()) { if (isSameDay(key, date)) { result.put(key, bookedTimes.get(key)); }// w w w . j a v a2 s .co m } return result; }
From source file:Main.java
public static HashMap[] getSMSes(Context context, String address, String searchPattern, int limit) { ArrayList<HashMap> list = new ArrayList<HashMap>(); HashMap<String, String> hm = new HashMap<String, String>(); hm.put("id", "12345"); hm.put("address", "111222"); hm.put("text", "u spent 100.12 rub. in Kokoko store. now u have 300.34 rub."); list.add(hm);//from w w w . jav a 2 s . c o m // FIXME: should be optimized by special query /*Cursor cursor = context.getContentResolver().query( Uri.parse("content://sms/inbox"), null, null, null, null ); cursor.moveToFirst(); ArrayList<HashMap> list = new ArrayList<HashMap>(); //if (searchPattern.length() > 0) { int num = 0; do { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("id", ""); hm.put("address", ""); hm.put("text", ""); for(int i = 0; i < cursor.getColumnCount(); i++) { String key = cursor.getColumnName(i) + ""; String val = cursor.getString(i) + ""; String msgData = key + ": " + val; if (key.equals("_id") || key.equals("date") || key.equals("date_sent")) hm.put("id", hm.get("id") + val); else if (key.equals("address")) hm.put("address", val); else if (key.equals("body")) hm.put("text", val); } if (address.length() > 0 && !hm.get("address").equals(address)) continue; if (searchPattern.length() > 0 && hm.get("text").indexOf(searchPattern) == -1) continue; list.add(hm); ++num; if (num >= limit) break; } while (cursor.moveToNext()); //} */ return list.toArray(new HashMap[0]); }
From source file:Main.java
/** * Method that merges 2 data structures into 1 * /*w ww.j a v a2 s . c o m*/ * @param featureSet: * the structure containing all features * @param featureSet2: * the structure containing Pairwise Correlation features * @return the concatenated data structure */ public static HashMap<Integer, ArrayList<HashMap<String, Double>>> mergeStructures( HashMap<Integer, ArrayList<HashMap<String, Double>>> featureSet, ArrayList<ArrayList<HashMap<String, Double>>> featureSet2) { HashMap<Integer, ArrayList<HashMap<String, Double>>> featureSet_final = new HashMap<Integer, ArrayList<HashMap<String, Double>>>(); for (int i = 0; i < featureSet.size(); i++) { ArrayList<HashMap<String, Double>> featuresPerChann = featureSet.get(i); ArrayList<HashMap<String, Double>> featuresPerChann2 = featureSet2.get(i); if (featuresPerChann2 == null) continue; ArrayList<HashMap<String, Double>> featuresPerChann_final = new ArrayList<HashMap<String, Double>>(); for (int ii = 0; ii < featuresPerChann.size(); ii++) { HashMap<String, Double> h1 = new HashMap<String, Double>(); HashMap<String, Double> h2 = new HashMap<String, Double>(); // System.out.println("s:: "+String.format("%03d", ii)); h1 = featuresPerChann.get(ii); for (int j = 0; j < featuresPerChann2.size(); j++) { h2 = featuresPerChann2.get(j); // System.out.println("h2:"+h2); String s = h2.keySet().toString(); if (s.contains("s" + String.format("%04d", ii))) { // System.out.println("sss"+s.substring(1,14)); String new_s = s.substring(1, 17); if (h2.get(new_s) != null) { double v = h2.get(new_s); HashMap<String, Double> h = new HashMap<String, Double>(); h.put(new_s.substring(0, 11), v); h1.putAll(h); } } } featuresPerChann_final.add(h1); } featureSet_final.put(i, featuresPerChann_final); } return featureSet_final; }
From source file:Main.java
public static HashMap<String, Integer> parseImageSizeWithUrl(Activity activity, String imageUrl) { int widthPx = DEFAULT_POST_IMAGE_WIDTH; int heightPx = DEFAULT_POST_IMAGE_HEIGHT; String[] file = imageUrl.split("\\."); int index = file.length - 2; String[] snippet = file[index].split("_"); int snippetCount = snippet.length; if (snippetCount >= 3) { if (null != snippet[1]) { widthPx = Integer.parseInt(snippet[1]); }//from w w w. ja v a2s . c o m if (null != snippet[2]) { heightPx = Integer.parseInt(snippet[2]); } } WindowManager windowManager = activity.getWindowManager(); Display display = windowManager.getDefaultDisplay(); Point size = new Point(); int screenWidth = 0; int screenHeight = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); screenWidth = size.x; screenHeight = size.y; } else { screenWidth = display.getWidth(); screenHeight = display.getHeight(); } if (widthPx > screenWidth) { widthPx = screenWidth; } else if (widthPx < DEFAULT_POST_IMAGE_WIDTH) { widthPx = DEFAULT_POST_IMAGE_WIDTH; } if (heightPx > screenHeight) { heightPx = screenHeight; } else if (heightPx < DEFAULT_POST_IMAGE_HEIGHT) { heightPx = DEFAULT_POST_IMAGE_HEIGHT; } HashMap<String, Integer> imageSize = new HashMap<String, Integer>(); imageSize.put("widthPx", widthPx); imageSize.put("heightPx", heightPx); return imageSize; }