1 21 package com.db4o.inside.query; 22 23 import com.db4o.*; 24 import com.db4o.foundation.*; 25 import com.db4o.inside.classindex.*; 26 import com.db4o.reflect.*; 27 28 29 32 public abstract class AbstractLateQueryResult extends AbstractQueryResult { 33 34 protected Iterable4 _iterable; 35 36 public AbstractLateQueryResult(Transaction transaction) { 37 super(transaction); 38 } 39 40 public AbstractQueryResult supportSize(){ 41 return toIdTree(); 42 } 43 44 public AbstractQueryResult supportSort(){ 45 return toIdList(); 46 } 47 48 public AbstractQueryResult supportElementAccess(){ 49 return toIdList(); 50 } 51 52 protected int knownSize(){ 53 return 0; 54 } 55 56 public IntIterator4 iterateIDs() { 57 if(_iterable == null){ 58 throw new IllegalStateException (); 59 } 60 return new IntIterator4Adaptor(_iterable); 61 } 62 63 public AbstractQueryResult toIdList(){ 64 return toIdTree().toIdList(); 65 } 66 67 public boolean skipClass(YapClass yapClass){ 68 if (yapClass.getName() == null) { 69 return true; 70 } 71 ReflectClass claxx = yapClass.classReflector(); 72 if (stream().i_handlers.ICLASS_INTERNAL.isAssignableFrom(claxx)){ 73 return true; 74 } 75 return false; 76 } 77 78 protected Iterable4 classIndexesIterable(final YapClassCollectionIterator classCollectionIterator) { 79 return new Iterable4() { 80 public Iterator4 iterator() { 81 return new CompositeIterator4( 82 new MappingIterator(classCollectionIterator) { 83 protected Object map(Object current) { 84 final YapClass yapClass = (YapClass)current; 85 if(skipClass(yapClass)){ 86 return MappingIterator.SKIP; 87 } 88 return classIndexIterator(yapClass); 89 } 90 } 91 ); 92 } 93 }; 94 } 95 96 protected Iterable4 classIndexIterable(final YapClass clazz) { 97 return new Iterable4() { 98 public Iterator4 iterator() { 99 return classIndexIterator(clazz); 100 } 101 }; 102 } 103 104 public Iterator4 classIndexIterator(YapClass clazz) { 105 return BTreeClassIndexStrategy.iterate(clazz, transaction()); 106 } 107 108 } 109 | Popular Tags |