List of usage examples for java.util HashMap get
public V get(Object key)
From source file:com.jaredrummler.android.devices.DevicesToJson.java
private static HashMap<String, List<Device>> getCodenames(List<Device> devices) { HashMap<String, List<Device>> codenames = new HashMap<>(); for (Device device : devices) { List<Device> deviceList = codenames.get(device.codename); if (deviceList == null) { deviceList = new ArrayList<>(); }//w w w .j ava 2s .c om deviceList.add(device); codenames.put(device.codename, deviceList); } return codenames; }
From source file:de.zebrajaeger.psdimage.autopano.GPanoData.java
protected static Integer parseInt(HashMap<String, String> map, String name) { final String val = map.get(name); if (val == null) { return null; }//from w w w . j a va 2s .c o m try { return Integer.parseInt(val); } catch (final NumberFormatException e) { final String msg = String.format("can not convert parameter '%s' with value '%s' to long", name, val); LOG.error(msg); } return null; }
From source file:de.zebrajaeger.psdimage.autopano.GPanoData.java
protected static Boolean parseBoolean(HashMap<String, String> map, String name) { final String val = map.get(name); if (val == null) { return null; }/*from ww w. j a v a2 s .c om*/ try { return Boolean.parseBoolean(val); } catch (final NumberFormatException e) { final String msg = String.format("can not convert parameter '%s' with value '%s' to long", name, val); LOG.error(msg); } return null; }
From source file:de.hbz.lobid.helper.CompareJsonMaps.java
private static void handleUnorderedValues(final HashMap<String, String> actualMap, final Entry<String, String> e) { if (checkIfAllValuesAreContainedUnordered(actualMap.get(e.getKey()), e.getValue())) { actualMap.remove(e.getKey());// ww w.j a v a2 s . c o m CompareJsonMaps.logger.debug("Removed " + e.getKey()); } else { CompareJsonMaps.logger.debug("Missing/wrong: " + e.getKey() + ", will fail"); } }
From source file:Main.java
private static HashMap<Date, Date> getBookedTimeInOneDate(HashMap<Date, Date> bookedTimes, Date date) { HashMap<Date, Date> result = new HashMap<Date, Date>(); for (Date key : bookedTimes.keySet()) { if (isSameDay(key, date)) { result.put(key, bookedTimes.get(key)); }/* www . java 2 s . c om*/ } return result; }
From source file:Main.java
public static void shiftTableUriIds(HashMap<String, ArrayList<ContentValues>> operationMap, String tableName, String idColumnName, String authority, String path, long topTableId) { ArrayList<ContentValues> restoreOperations = operationMap.get(tableName); if (null == restoreOperations) { return;//from ww w. j av a 2 s .c o m } for (ContentValues restoreCv : restoreOperations) { if (restoreCv.containsKey(idColumnName) && null != restoreCv.getAsString(idColumnName)) { Uri uri = Uri.parse(restoreCv.getAsString(idColumnName)); if ("content".equalsIgnoreCase(uri.getScheme()) && authority.equals(uri.getAuthority()) && uri.getPath().substring(0, uri.getPath().lastIndexOf('/')).equals(path)) { Uri.Builder newUri = uri.buildUpon() .path(uri.getPath().substring(0, uri.getPath().lastIndexOf('/'))) .appendPath(String.valueOf( Long.parseLong(uri.getPath().substring(uri.getPath().lastIndexOf('/') + 1)) + topTableId)); // Log.v("URI", uri.getPath().substring(uri.getPath().lastIndexOf('/')+1)); // Log.v("URI", String.valueOf(Long.parseLong(uri.getPath().substring(uri.getPath().lastIndexOf('/')+1)) + topTableId)); restoreCv.put(idColumnName, newUri.build().toString()); } } } }
From source file:cooccurrence.emf.java
/** * Method to insert a triple of from string, to String and the weight to the * coocurrence hashMap//from www . ja v a 2 s . com * * @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:Main.java
public static void putSumInClass(HashMap<String, Integer> suminclass, String text) { int i = 0, index; String info = text;//www .j a va2 s .c o m while ((index = info.indexOf("//@")) > 0) { i++; info = info.substring(index + 2); } if (suminclass.get(Integer.toString(i)) == null) { suminclass.put(Integer.toString(i), 1); } else { suminclass.put(Integer.toString(i), suminclass.get(Integer.toString(i)) + 1); } }
From source file:Main.java
public static double getSumValue(HashMap<String, Double> map) { Double count = 0.0D;// ww w . j a va 2 s . c o m List list = new LinkedList(map.entrySet()); for (Iterator it = list.iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); count += map.get(entry.getKey()); } return count; }
From source file:Main.java
public static void save(HashMap<String, String> map) { SharedPreferences preferences = getPrivateSharedPreference(); SharedPreferences.Editor editor = preferences.edit(); for (String key : map.keySet()) { editor.putString(key, map.get(key)); }/* w ww .j a va2s . c o m*/ editor.commit(); }