List of usage examples for java.util WeakHashMap get
public V get(Object key)
From source file:Main.java
public static void main(String[] args) { WeakHashMap<String, String> weakHashMap = new WeakHashMap<String, String>(); weakHashMap.put("1", "first"); weakHashMap.put("2", "two"); weakHashMap.put("3", "from java2s.com"); // check existence of value for key 2 System.out.println("Checking value for key 2"); System.out.println(weakHashMap.get("2")); }
From source file:com.benefit.buy.library.http.query.callback.BitmapAjaxCallback.java
@Override public final void callback(String url, Bitmap bm, AjaxStatus status) { ImageView firstView = v.get(); WeakHashMap<ImageView, BitmapAjaxCallback> ivs = queueMap.remove(url); //check if view queue already contains first view if ((ivs == null) || !ivs.containsKey(firstView)) { checkCb(this, url, firstView, bm, status); }//from w w w. j a va2s. co m if (ivs != null) { Set<ImageView> set = ivs.keySet(); for (ImageView view : set) { BitmapAjaxCallback cb = ivs.get(view); cb.status = status; checkCb(cb, url, view, bm, status); } } }
From source file:com.appbase.androidquery.callback.BitmapAjaxCallback.java
@Override public final void callback(String url, Bitmap bm, AjaxStatus status) { ImageView firstView = v.get(); WeakHashMap<ImageView, BitmapAjaxCallback> ivs = queueMap.remove(url); //check if view queue already contains first view if (ivs == null || !ivs.containsKey(firstView)) { checkCb(this, url, firstView, bm, status); }//from w ww . j av a 2 s . c om if (ivs != null) { Set<ImageView> set = ivs.keySet(); for (ImageView view : set) { BitmapAjaxCallback cb = ivs.get(view); cb.status = status; checkCb(cb, url, view, bm, status); } } }
From source file:org.cellprofiler.preferences.CellProfilerPreferences.java
/** * Lookup or create a CellProfilerPreferences node for a given path. * @param delegate//from www.j a va 2 s . co m * @param map * @return */ static private CellProfilerPreferences retrieveNode(String path, WeakHashMap<String, CellProfilerPreferences> map) { synchronized (map) { CellProfilerPreferences result = map.get(path); if (result == null) { CellProfilerPreferences root = map.get("/"); final Preferences delegate = root.delegate.node(path); final int lastSlash = path.lastIndexOf("/"); CellProfilerPreferences parent = null; if (lastSlash == 0) { parent = root; } else { parent = retrieveNode(path.substring(0, lastSlash), map); } result = new CellProfilerPreferences(parent, delegate, map); map.put(path, result); } return result; } }
From source file:org.compass.gps.device.hibernate.embedded.CompassEventListener.java
private CompassHolder getCompassHolder(Configuration cfg) { WeakHashMap<Configuration, CompassHolder> contextMap = contexts.get(); if (contextMap == null) { contextMap = new WeakHashMap<Configuration, CompassHolder>(2); contexts.set(contextMap);/*from w w w . ja va2 s. c om*/ } CompassHolder compassHolder = contextMap.get(cfg); if (compassHolder == null) { compassHolder = initCompassHolder(cfg); if (compassHolder != null) { if (log.isDebugEnabled()) { log.debug("Regsitering new Compass Holder [" + compassHolder + "]"); } contextMap.put(cfg, compassHolder); } } return compassHolder; }
From source file:org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.java
private static IsSuccessorResult isSuccessorOf_checkCache(Class<?> clazz, String requiredClass) { WeakHashMap<Class<?>, IsSuccessorResult> classes = m_isSuccessorOfCache.get(requiredClass); if (classes != null) { return classes.get(clazz); }//from w ww . j a va2 s . c o m return IsSuccessorResult.UNKNOWN; }