1 17 18 package org.objectweb.jac.util; 19 20 import java.util.HashMap ; 21 import java.util.Map ; 22 import org.apache.log4j.Logger; 23 24 25 28 public class LinkedMap extends HashMap { 29 static Logger logger = Logger.getLogger("util.map"); 30 31 Map next; 32 public LinkedMap() { 33 } 34 public LinkedMap(Map next) { 35 this.next = next; 36 } 37 public Object get(Object key) { 38 if (super.containsKey(key)) { 39 return super.get(key); 40 } else { 41 Object result = null; 42 if (next!=null) { 43 result = next.get(key); 44 logger.debug(key+" not found, trying next -> "+result); 45 put(key,result); 46 } 47 return result; 48 } 49 } 50 public boolean containsKey(Object key) { 51 if (super.containsKey(key)) { 52 return true; 53 } else { 54 return next!=null && next.containsKey(key); 55 } 56 } 57 } 58 | Popular Tags |