1 4 package java.util; 5 6 import com.tc.object.ObjectID; 7 import com.tc.object.bytecode.Manageable; 8 import com.tc.object.bytecode.ManagerUtil; 9 10 import java.util.HashMapTC.ValueWrapper ; 11 12 17 public abstract class LinkedHashMapTC extends LinkedHashMap implements Manageable { 18 19 private final boolean accessOrder; 21 22 public LinkedHashMapTC() { 23 super(); 24 accessOrder = false; 25 } 26 27 public LinkedHashMapTC(int initialCapacity) { 28 super(initialCapacity); 29 accessOrder = false; 30 } 31 32 public LinkedHashMapTC(Map arg0) { 33 super(arg0); 34 accessOrder = false; 35 } 36 37 public LinkedHashMapTC(int initialCapacity, float loadFactor) { 38 super(initialCapacity, loadFactor); 39 accessOrder = false; 40 } 41 42 public LinkedHashMapTC(int initialCapacity, float loadFactor, boolean accessOrder) { 43 super(initialCapacity, loadFactor, accessOrder); 44 this.accessOrder = accessOrder; 45 } 46 47 public boolean containsValue(Object value) { 49 if (__tc_isManaged()) { 50 synchronized (__tc_managed().getResolveLock()) { 51 if (value != null) { 52 return super.containsValue(new ValueWrapper(value)); 55 } else { 56 return super.containsValue(value); 57 } 58 } 59 } else { 60 return super.containsValue(value); 61 } 62 } 63 64 public Object get(Object key) { 65 if (__tc_isManaged()) { 66 synchronized (__tc_managed().getResolveLock()) { 67 Object val = super.get(key); 68 if (accessOrder) { 69 ManagerUtil.checkWriteAccess(this); 70 ManagerUtil.logicalInvoke(this, "get(Ljava/lang/Object;)Ljava/lang/Object;", new Object [] { key }); 71 } 72 return lookUpAndStoreIfNecessary(key, val); 73 } 74 } else { 75 return super.get(key); 76 } 77 } 78 79 private Object lookUpAndStoreIfNecessary(Object key, Object value) { 80 if (value instanceof ObjectID) { 81 Object newVal = ManagerUtil.lookupObject((ObjectID) value); 82 Map.Entry e = getEntry(key); 83 e.setValue(newVal); 85 return newVal; 86 } else { 87 return value; 88 } 89 } 90 91 } 92 | Popular Tags |