List of usage examples for java.util HashMap get
public V get(Object key)
From source file:com.zimbra.cs.util.yauth.TokenAuthenticateV1.java
/** * @param username/*from w ww . j a v a 2 s . c o m*/ * @param passwd * @return The token */ public static String getToken(String username, String passwd) throws IOException, HttpException { GetMethod method = new GetMethod( "https://login.yahoo.com/config/pwtoken_get?src=ymsgr&login=" + username + "&passwd=" + passwd); int response = HttpClientUtil.executeMethod(method); if (response >= 200 && response < 300) { String body = method.getResponseBodyAsString(); HashMap<String, String> map = new HashMap<String, String>(); map.put("ymsgr", null); parseResponseBody(body, map); return map.get("ymsgr"); } else { throw new IOException("HTTPClient response: " + response); } }
From source file:edu.vt.vbi.patric.dao.HibernateHelper.java
public static void closeSession() { HashMap<String, Session> sessionMaps = sessionMapsThreadLocal.get(); sessionMapsThreadLocal.set(null);//from w w w . j a va2 s . c om if (sessionMaps != null) { Session session = sessionMaps.get(""); if (session != null && session.isOpen()) session.close(); } }
From source file:Main.java
public static void removeEntriesWhereMatch(HashMap<String, ArrayList<ContentValues>> operationMap, String tableName, String idColumnName, ArrayList<ContentValues> compareContentValues, String compareColumnName) { ArrayList<ContentValues> restoreOperations = operationMap.get(tableName); if (null == restoreOperations) { return;/* ww w . j a v a 2s . c o m*/ } ArrayList<ContentValues> removeOperations = new ArrayList<ContentValues>(); for (ContentValues restoreCv : restoreOperations) { for (ContentValues compareCv : compareContentValues) { if (restoreCv.containsKey(idColumnName) && compareCv.containsKey(compareColumnName)) { if (restoreCv.getAsLong(idColumnName) == compareCv.getAsLong(compareColumnName)) { removeOperations.add(restoreCv); } } } } for (ContentValues removeCv : removeOperations) { restoreOperations.remove(removeCv); } }
From source file:org.hfoss.posit.android.web.PositHttpUtils.java
public static List<NameValuePair> convertFindsForPost(String[] projection, HashMap<String, String> findsMap) { List<NameValuePair> finds = new ArrayList<NameValuePair>(); for (String item : projection) { finds.add(new BasicNameValuePair(item, findsMap.get(item))); }// w ww . j a v a 2 s . c om return finds; }
From source file:Main.java
public static Object getAdditionalInstanceField(Object obj, String key) { if (obj == null) throw new NullPointerException("object must not be null"); if (key == null) throw new NullPointerException("key must not be null"); HashMap<String, Object> objectFields; synchronized (additionalFields) { objectFields = additionalFields.get(obj); if (objectFields == null) return null; }/*from ww w.ja v a 2s. c om*/ synchronized (objectFields) { return objectFields.get(key); } }
From source file:com.vivekpanyam.evolve.Utils.java
/** * Set the ClassLoader for the running application * * @param a An activity in the currently running application * @param classLoader The ClassLoader used to load the new DEX file *///w w w .ja v a2s.com public static void setClassLoader(Activity a, ClassLoader classLoader) { try { Field mMainThread = getField(Activity.class, "mMainThread"); Object mainThread = mMainThread.get(a); Class<?> threadClass = mainThread.getClass(); Field mPackages = getField(threadClass, "mPackages"); HashMap<String, ?> map = (HashMap<String, ?>) mPackages.get(mainThread); WeakReference<?> ref = (WeakReference<?>) map.get(a.getPackageName()); Object apk = ref.get(); Class<?> apkClass = apk.getClass(); Field mClassLoader = getField(apkClass, "mClassLoader"); mClassLoader.set(apk, classLoader); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.dtolabs.rundeck.core.common.NodeEntryFactory.java
public static Map<String, String> toMap(final INodeEntry node) { HashMap<String, String> map = new HashMap<String, String>(); if (null != node.getAttributes()) { map.putAll(node.getAttributes()); }/* ww w . j a v a 2 s . co m*/ if (null == map.get("tags")) { map.put("tags", ""); } return map; }
From source file:Main.java
/** * Returns a {@link Map} mapping each unique element in the given * {@link Collection} to an {@link Integer} representing the number of * occurances of that element in the {@link Collection}. An entry that maps * to <tt>null</tt> indicates that the element does not appear in the given * {@link Collection}./*from w w w .ja v a 2 s . com*/ */ public static Map getCardinalityMap(final Collection col) { HashMap count = new HashMap(); Iterator it = col.iterator(); while (it.hasNext()) { Object obj = it.next(); Integer c = (Integer) (count.get(obj)); if (null == c) { count.put(obj, new Integer(1)); } else { count.put(obj, new Integer(c.intValue() + 1)); } } return count; }
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 {/*from w ww. j a va 2 s .c om*/ ArrayList<Object[]> rowdata = new ArrayList<Object[]>(); rowdata.add((Object[]) list.get(i)); dataMap.put(unit, rowdata); } } return dataMap; }
From source file:it.acubelab.smaph.entityfilters.LibSvmEntityFilter.java
/** * Turns a frature_name-feature_value mapping to an array of features. * /*from w ww . ja va2 s . c om*/ * @param features * the mapping from feature names to feature values. * @return an array of feature values. */ public static double[] featuresToFtrVectStatic(HashMap<String, Double> features) { if (!checkFeatures(features)) { for (String ftrName : features.keySet()) System.err.printf("%s -> %f%n", ftrName, features.get(ftrName)); throw new RuntimeException("Implementation error -- check the features"); } Vector<Double> ftrValues = new Vector<>(); for (String ftrName : ftrNames) ftrValues.add(getOrDefault(features, ftrName, 0.0)); return ArrayUtils.toPrimitive(ftrValues.toArray(new Double[] {})); }