1 21 package com.db4o; 22 23 import java.lang.ref.*; 24 25 import com.db4o.config.*; 26 import com.db4o.foundation.*; 27 import com.db4o.reflect.generic.*; 28 import com.db4o.types.*; 29 30 class JDK_1_2 extends JDKReflect { 31 32 JDK_1_2(){ 33 } 34 35 public static void link(){ 36 39 Object obj = new TCollection(); 40 obj = new TMap(); 41 obj = new TSerializable(); 42 obj = new TTreeMap(); 43 obj = new TTreeSet(); 44 } 45 46 Db4oCollections collections(YapStream a_stream){ 47 return new P2Collections(a_stream); 48 } 49 50 Object createReferenceQueue() { 51 return new YapReferenceQueue(); 52 } 53 54 public Object createWeakReference(Object obj){ 55 return new WeakReference(obj); 56 } 57 58 Object createYapRef(Object a_queue, YapObject a_yapObject, Object a_object) { 59 return new YapRef(a_queue, a_yapObject, a_object); 60 } 61 62 Object getContextClassLoader() { 63 return Thread.currentThread().getContextClassLoader(); 64 } 65 66 void forEachCollectionElement(Object a_object, Visitor4 a_visitor) { 67 java.util.Iterator i = null; 68 if (a_object instanceof java.util.Collection ) { 69 i = ((java.util.Collection ) a_object).iterator(); 70 } else if (a_object instanceof java.util.Map ) { 71 i = ((java.util.Map ) a_object).keySet().iterator(); 72 } 73 if (i != null) { 74 while (i.hasNext()) { 75 a_visitor.visit(i.next()); 76 } 77 } 78 } 79 80 Object getYapRefObject(Object a_object) { 81 if (a_object instanceof YapRef) { 82 return ((YapRef) a_object).get(); 83 } 84 return a_object; 85 } 86 87 boolean isCollectionTranslator(Config4Class a_config) { 88 if (a_config != null) { 89 ObjectTranslator ot = a_config.getTranslator(); 90 if (ot != null) { 91 return ot instanceof TCollection || ot instanceof TMap || ot instanceof THashtable; 92 } 93 } 94 return false; 95 } 96 97 public int ver(){ 98 return 2; 99 } 100 101 void killYapRef(Object obj){ 102 if(obj instanceof YapRef){ 103 ((YapRef)obj).i_yapObject = null; 104 } 105 } 106 107 void pollReferenceQueue(YapStream a_stream, Object a_referenceQueue) { 108 if (a_referenceQueue != null) { 109 YapReferenceQueue yrq = (YapReferenceQueue) a_referenceQueue; 110 YapRef ref; 111 synchronized(a_stream.lock()){ 112 while ((ref = yrq.yapPoll()) != null) { 113 a_stream.purge1(ref.i_yapObject); 114 } 115 } 116 } 117 } 118 119 public void registerCollections(GenericReflector reflector) { 120 reflector.registerCollection(java.util.Collection .class); 121 reflector.registerCollection(java.util.Map .class); 122 reflector.registerCollectionUpdateDepth(java.util.Map .class, 3); 123 } 124 125 void setAccessible(Object a_accessible) { 126 ((java.lang.reflect.AccessibleObject ) a_accessible).setAccessible(true); 127 } 128 129 public Object weakReferenceTarget(Object weakRef){ 130 if(weakRef instanceof WeakReference){ 131 return ((WeakReference)weakRef).get(); 132 } 133 return weakRef; 134 } 135 136 } 137 | Popular Tags |