List of usage examples for java.util HashMap containsKey
public boolean containsKey(Object key)
From source file:edu.cornell.mannlib.vitro.webapp.utils.ConceptSearchService.ConceptSearchServiceUtils.java
public static String getConceptSearchServiceClassName(String searchServiceName) { HashMap<String, String> map = getMapping(); if (map.containsKey(searchServiceName)) { return map.get(searchServiceName); }//from w w w . j a va 2s. c om return null; }
From source file:Main.java
public static HashMap<String, Integer> getMostFrequentDestination(ArrayList<String> destination) { System.out.println("ARRAYLIST INPUT! : " + destination.size()); HashMap<String, Integer> temp = new HashMap<String, Integer>(); for (String d : destination) { if (temp.containsKey(d)) { temp.put(d, temp.get(d) + 1); } else {/* www . j a v a2 s. c o m*/ temp.put(d, 1); } } return temp; }
From source file:com.nubits.nubot.utils.VersionInfo.java
/** * get version from ".nubot file"/*from w w w. ja v a 2 s . c o m*/ * * @return */ public static String getVersionName() { if (FilesystemUtils.insideJar()) { HashMap km = getInfoFile(); if (km.containsKey("version")) { return "" + km.get("version"); } return "load version error"; } else { String branch = getCurrentgitBranch(); return branch; } }
From source file:com.nubits.nubot.utils.VersionInfo.java
public static String getBranchCommitInfo() { if (FilesystemUtils.insideJar()) { HashMap km = getInfoFile(); if (km.containsKey("version")) { return "" + km.get("version"); }//from w w w . j a v a 2s.co m return "load version error"; } else { return getCurrentgitBranch(); } }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3Utils.java
public static ProcessDataGetterN3 getDataGetterProcessorN3(String dataGetterClass, JSONObject jsonObject) { HashMap<String, String> map = ProcessDataGetterN3Map.getDataGetterTypeToProcessorMap(); ///* ww w .j a v a2s . c om*/ if (map.containsKey(dataGetterClass)) { String processorClass = map.get(dataGetterClass); try { ProcessDataGetterN3 pn = instantiateClass(processorClass, jsonObject); return pn; } catch (Exception ex) { log.error("Exception occurred in trying to get processor class for n3 for " + dataGetterClass, ex); return null; } } return null; }
From source file:cooccurrence.emf.java
/** * Method to insert a triple of from string, to String and the weight to the * coocurrence hashMap//from w w w. j av a2s . c o m * * @param from * @param to * @param count * @param matrix */ private static void addToMatrix(String from, String to, Double count, HashMap<String, HashMap<String, Double>> matrix) { HashMap<String, Double> innerMatrix; if (matrix.containsKey(from)) { innerMatrix = matrix.get(from); } else { innerMatrix = new HashMap<>(); } if (innerMatrix.containsKey(to)) { Double countTemp = innerMatrix.get(to); countTemp = countTemp + count; innerMatrix.put(to, countTemp); matrix.put(from, innerMatrix); } else { innerMatrix.put(to, count); matrix.put(from, innerMatrix); } }
From source file:gov.nasa.jpl.analytics.util.CommonUtil.java
public static HashMap<String, Integer> termFrequency(Iterable<String> terms) { HashMap<String, Integer> map = new HashMap(); for (String term : terms) { if (!map.containsKey(term)) { map.put(term, 1);/*from w w w . j a va 2 s .co m*/ } else { map.put(term, map.get(term) + 1); } } return map; }
From source file:lee.util.jtap.JTapCli.java
/** * @param argsMap/*from ww w . j av a 2 s .c o m*/ * @return */ protected static String setSession(HashMap<String, String> argsMap) { if (!argsMap.containsKey("host") || !argsMap.containsKey("bucket")) { return "Host and bucket values are required for session to be set."; } int portInt = 0; try { if (argsMap.containsKey("port")) { portInt = Integer.parseInt(argsMap.get("port")); } if (portInt == 0) { portInt = JTapSession.DEFAULT_PORT; } } catch (Exception e) { //Just use default. portInt = JTapSession.DEFAULT_PORT; } JTapCli.session = new JTapSession(argsMap.get("host"), portInt, argsMap.get("bucket"), argsMap.get("password")); JTapCli.session.save(); return "Session set. host=" + JTapCli.session.getHost() + ":" + JTapCli.session.getPort() + " bucket=" + JTapCli.session.getBucket(); }
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()); }/*w w w. j a va2 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 HashMap<String, List<Object[]>> getUnitDataMap(List<Object[]> list, int index) { HashMap<String, List<Object[]>> dataMap = new HashMap<String, List<Object[]>>(); for (int i = 0; i < list.size(); i++) { Object obj = list.get(i)[index]; String unit = obj.toString(); if (dataMap.containsKey(unit)) { dataMap.get(unit).add((Object[]) list.get(i)); } else {/* w w w. j a va2s . c om*/ ArrayList<Object[]> rowdata = new ArrayList<Object[]>(); rowdata.add((Object[]) list.get(i)); dataMap.put(unit, rowdata); } } return dataMap; }