1 6 7 package com.hp.hpl.jena.rdf.model.impl; 8 9 import com.hp.hpl.jena.util.iterator.*; 10 import com.hp.hpl.jena.rdf.model.*; 11 12 import java.util.*; 13 14 19 public class ContNodeIteratorImpl 20 extends WrappedIterator implements NodeIterator{ 21 22 protected Statement stmt = null; 23 protected Container cont; 24 protected int size; 25 protected int index = 0; 26 protected int numDeleted = 0; 27 protected Vector moved = new Vector(); 28 29 30 public ContNodeIteratorImpl (Iterator iterator, 31 Object object, 32 Container cont) { 33 super( iterator ); 34 this.cont = cont; 35 this.size = cont.size(); 36 } 37 38 public Object next() throws NoSuchElementException { 39 stmt = (Statement) super.next(); 40 index += 1; 41 return stmt.getObject(); 42 } 43 44 public RDFNode nextNode() throws NoSuchElementException { 45 return (RDFNode) next(); 46 } 47 48 public void remove() throws NoSuchElementException { 49 if (stmt == null) throw new NoSuchElementException(); 50 super.remove(); 51 52 if (index > (size-numDeleted)) { 53 ((ContainerI)cont).remove(((Integer ) moved.elementAt(size-index)) 54 .intValue(), 55 stmt.getObject()); 56 } else { 57 cont.remove(stmt); 58 moved.add(new Integer (index)); 59 } 60 stmt = null; 61 numDeleted++; 62 } 63 64 } 65 95 | Popular Tags |