List of usage examples for java.util HashMap get
public V get(Object key)
From source file:com.soomla.levelup.data.WorldStorage.java
public static boolean isLevel(String worldId) { JSONObject model = LevelUp.getLevelUpModel(); if (model != null) { HashMap<String, JSONObject> worlds = LevelUp.getWorlds(model); JSONObject world = worlds.get(worldId); if (world != null) { try { if (world.getString("itemId").equals(worldId)) { return (world.getString("className").equals("Level")); }/*from w w w . j ava2s. c o m*/ } catch (JSONException ex) { SoomlaUtils.LogDebug(TAG, "Model JSON is malformed " + ex.getMessage()); } } } return false; }
From source file:Main.java
@SuppressWarnings("unchecked") public static Bundle addMapToBundle(HashMap<String, ?> map, Bundle bundle) { for (String key : map.keySet()) { Object value = map.get(key); if (value instanceof String) { bundle.putString(key, (String) value); } else if (value instanceof Integer) { bundle.putInt(key, (Integer) value); } else if (value instanceof Double) { bundle.putDouble(key, ((Double) value)); } else if (value instanceof Boolean) { bundle.putBoolean(key, (Boolean) value); } else if (value instanceof HashMap) { bundle.putBundle(key, addMapToBundle((HashMap<String, Object>) value, new Bundle())); } else if (value instanceof ArrayList) { putArray(key, (ArrayList) value, bundle); }/*from w ww . java2s . c o m*/ } return bundle; }
From source file:eu.hydrologis.jgrass.geonotes.util.ExifHandler.java
/** * Extract the creation {@link DateTime} from the map of tags read by {@link #readMetaData(File)}. * // w w w . java 2 s . c om * @param tags2ValuesMap the map of tags read by {@link #readMetaData(File)}. * @return the datetime. */ public static DateTime getCreationDatetimeUtc(HashMap<String, String> tags2ValuesMap) { String creationDate = tags2ValuesMap.get(TiffConstants.EXIF_TAG_CREATE_DATE.name); creationDate = creationDate.replaceAll("'", ""); creationDate = creationDate.replaceFirst(":", "-"); creationDate = creationDate.replaceFirst(":", "-"); String dateTimeFormatterYYYYMMDDHHMMSS_string = "yyyy-MM-dd HH:mm:ss"; DateTimeFormatter dateTimeFormatterYYYYMMDDHHMMSS = DateTimeFormat .forPattern(dateTimeFormatterYYYYMMDDHHMMSS_string); DateTime parseDateTime = dateTimeFormatterYYYYMMDDHHMMSS.parseDateTime(creationDate); DateTime dt = parseDateTime.toDateTime(DateTimeZone.UTC); return dt; }
From source file:edu.vt.vbi.patric.dao.HibernateHelper.java
public static void closeSession(String key) { HashMap<String, Session> sessionMaps = sessionMapsThreadLocal.get(); if (sessionMaps != null) { Session session = sessionMaps.get(key); if (session != null && session.isOpen()) session.close();/* w w w .j a v a 2s .c o m*/ } }
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(); ///*from ww w .j a v a 2 s . com*/ 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: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)); }//from ww w. j av a 2 s.co m } return result; }
From source file:Main.java
public static HashMap<Integer, ArrayList<Double>> transposeHashMap(HashMap<Integer, ArrayList<Double>> data) { HashMap<Integer, ArrayList<Double>> dataT = new HashMap<Integer, ArrayList<Double>>(); //transpose data to get data for each sensor channel for (int i = 0; i < data.get(0).size(); i++) { ArrayList<Double> tmp = new ArrayList<Double>(); for (int j = 0; j < data.size(); j++) { tmp.add(data.get(j).get(i)); }/*from w w w . j ava 2 s. co m*/ dataT.put(i, tmp); } return dataT; }
From source file:Main.java
public static String decodeLZW(int[] encodedText, HashMap<Integer, String> dict, int dictSize) { String decodedText = ""; for (int i = 0; i < encodedText.length; i++) { String nextString = ""; String currentEntry = dict.get(encodedText[i]); decodedText = decodedText.concat(currentEntry); if (i + 1 < encodedText.length && dict.size() < dictSize) { if (encodedText[i + 1] < dict.size()) nextString = dict.get(encodedText[i + 1]); else/* w ww . j a v a 2 s . c o m*/ nextString = currentEntry; String nextChar = String.valueOf(nextString.charAt(0)); if (!dict.containsValue(currentEntry.concat(nextChar))) { dict.put(dict.size(), currentEntry.concat(nextChar)); } } } return decodedText; }
From source file:org.hfoss.posit.android.web.PositHttpUtils.java
public static List<NameValuePair> convertFindsForPost(Find find) { List<NameValuePair> findList = new ArrayList<NameValuePair>(); HashMap<String, String> findMap = find.getContentMap(); for (String key : findMap.keySet()) { findList.add(new BasicNameValuePair(key, findMap.get(key))); }/*w w w .j ava2 s. c o m*/ return findList; }
From source file:Main.java
public static void shiftTableIdsExceptWhen(HashMap<String, ArrayList<ContentValues>> operationMap, String tableName, String idColumnName, long topTableId, String exceptionColumn, String exceptionValue) { ArrayList<ContentValues> restoreOperations = operationMap.get(tableName); if (null == restoreOperations || null == exceptionValue) { return;//from w ww . j a va 2s .c o m } for (ContentValues restoreCv : restoreOperations) { if (!exceptionValue.equals(restoreCv.getAsString(exceptionColumn))) { restoreCv.put(idColumnName, restoreCv.getAsLong(idColumnName) + topTableId); } } }