1 6 7 package com.hp.hpl.jena.graph.impl; 8 9 import com.hp.hpl.jena.graph.*; 10 import com.hp.hpl.jena.util.iterator.*; 11 12 import java.util.*; 13 14 17 public abstract class FragmentTripleIterator extends NiceIterator 18 { 19 private final GraphAddList pending; 20 private final Iterator it; 21 22 27 public FragmentTripleIterator( Triple match, Iterator it ) 28 { 29 super(); 30 this.it = it; 31 this.pending = new GraphAddList( match ); 32 } 33 34 35 40 public boolean hasNext() 41 { 42 refill(); 43 return pending.size() > 0; 44 } 45 46 52 public Object next() 53 { 54 ensureHasNext(); 55 return pending.remove( pending.size() - 1 ); 56 } 57 58 63 protected abstract void fill( GraphAdd ga, Node n, Object fragmentsObject ); 64 65 69 private void refill() 70 { while (pending.size() == 0 && it.hasNext()) refillFrom( pending, it.next() ); } 71 72 77 protected void refillFrom( GraphAdd pending, Object next ) 78 { 79 Map.Entry e = (Map.Entry) next; 80 fill( pending, (Node) e.getKey(), e.getValue() ); 81 } 82 } 83 84 | Popular Tags |