1 package org.lobobrowser.util; 2 3 import java.util.*; 4 5 public class Items { 6 private Items() { 7 } 8 9 private static Map sourceMap = new WeakHashMap(); 10 11 public static Object getItem(Object source, String name) { 12 Map sm = sourceMap; 13 synchronized(sm) { 14 Map itemMap = (Map) sm.get(source); 15 if(itemMap == null) { 16 return null; 17 } 18 return itemMap.get(name); 19 } 20 } 21 22 public static void setItem(Object source, String name, Object value) { 23 Map sm = sourceMap; 24 synchronized(sm) { 25 Map itemMap = (Map) sm.get(source); 26 if(itemMap == null) { 27 itemMap = new HashMap(1); 28 sm.put(source, itemMap); 29 } 30 itemMap.put(name, value); 31 } 32 } 33 } 34 | Popular Tags |