1 30 31 package com.hp.hpl.jena.util.iterator; 32 33 import java.util.Iterator ; 34 import java.util.NoSuchElementException ; 35 36 42 public class IteratorIterator implements Iterator 43 { 44 private Iterator top; 45 private Iterator currentMember; 46 47 51 public IteratorIterator(Iterator e) { 52 top = e; 53 currentMember = null; 54 } 55 56 59 public boolean hasNext() { 60 while ( currentMember == null || !currentMember.hasNext() ) { 61 if (!top.hasNext()) 62 return false; 63 currentMember = (Iterator )top.next(); 64 } 65 return true; 66 } 67 68 public Object next() { 69 hasNext(); 70 if (currentMember == null) 71 throw new NoSuchElementException (); 72 return currentMember.next(); 73 } 74 77 public void remove() { 78 if (currentMember == null) 79 throw new IllegalStateException (); 80 currentMember.remove(); 81 } 82 } 83 | Popular Tags |