1 21 package com.db4o.inside.query; 22 23 import com.db4o.*; 24 import com.db4o.ext.*; 25 import com.db4o.foundation.*; 26 import com.db4o.query.*; 27 28 29 32 public abstract class AbstractQueryResult implements QueryResult { 33 34 protected final Transaction _transaction; 35 36 public AbstractQueryResult(Transaction transaction) { 37 _transaction = transaction; 38 } 39 40 public final Object activate(Object obj) { 41 stream().activate1(_transaction, obj, config().activationDepth()); 42 return obj; 43 } 44 45 public final Object activatedObject(int id) { 46 YapStream stream = stream(); 47 Object ret = stream.getActivatedObjectFromCache(_transaction, id); 48 if(ret != null){ 49 return ret; 50 } 51 return stream.readActivatedObjectNotInCache(_transaction, id); 52 } 53 54 public Object streamLock() { 55 final YapStream stream = stream(); 56 stream.checkClosed(); 57 return stream.lock(); 58 } 59 60 public YapStream stream() { 61 return _transaction.stream(); 62 } 63 64 public Transaction transaction(){ 65 return _transaction; 66 } 67 68 public ExtObjectContainer objectContainer() { 69 return stream(); 70 } 71 72 public Iterator4 iterator() { 73 return new MappingIterator(iterateIDs()){ 74 protected Object map(Object current) { 75 if(current == null){ 76 return MappingIterator.SKIP; 77 } 78 synchronized (streamLock()) { 79 Object obj = activatedObject(((Integer )current).intValue()); 80 if(obj == null){ 81 return MappingIterator.SKIP; 82 } 83 return obj; 84 } 85 } 86 }; 87 } 88 89 public AbstractQueryResult supportSize(){ 90 return this; 91 } 92 93 public AbstractQueryResult supportSort(){ 94 return this; 95 } 96 97 public AbstractQueryResult supportElementAccess(){ 98 return this; 99 } 100 101 protected int knownSize(){ 102 return size(); 103 } 104 105 public AbstractQueryResult toIdList(){ 106 IdListQueryResult res = new IdListQueryResult(transaction(), knownSize()); 107 IntIterator4 i = iterateIDs(); 108 while(i.moveNext()){ 109 res.add(i.currentInt()); 110 } 111 return res; 112 } 113 114 protected AbstractQueryResult toIdTree(){ 115 return new IdTreeQueryResult(transaction(), iterateIDs()); 116 } 117 118 public Config4Impl config(){ 119 return stream().config(); 120 } 121 122 public int size() { 123 throw new NotImplementedException(); 124 } 125 126 public void sort(QueryComparator cmp) { 127 throw new NotImplementedException(); 128 } 129 130 public Object get(int index) { 131 throw new NotImplementedException(); 132 } 133 134 public int getId(int i) { 135 throw new NotImplementedException(); 136 } 137 138 public int indexOf(int id) { 139 throw new NotImplementedException(); 140 } 141 142 public void loadFromClassIndex(YapClass c) { 143 throw new NotImplementedException(); 144 } 145 146 public void loadFromClassIndexes(YapClassCollectionIterator i) { 147 throw new NotImplementedException(); 148 } 149 150 public void loadFromIdReader(YapReader r) { 151 throw new NotImplementedException(); 152 } 153 154 public void loadFromQuery(QQuery q) { 155 throw new NotImplementedException(); 156 } 157 158 } 159
| Popular Tags
|