1 6 7 package com.hp.hpl.jena.util.iterator; 8 9 import java.util.*; 10 11 19 20 public class WrappedIterator extends NiceIterator 21 { 22 26 protected boolean removeDenied; 27 28 32 public static ExtendedIterator create( Iterator it ) 33 { return it instanceof ExtendedIterator ? (ExtendedIterator) it : new WrappedIterator( it, false ); } 34 35 public static WrappedIterator createNoRemove( Iterator it ) 36 { return new WrappedIterator( it, true ); } 37 38 39 private Iterator base; 40 41 42 protected WrappedIterator( Iterator base ) 43 { this( base, false ); } 44 45 50 protected WrappedIterator( Iterator base, boolean removeDenied ) 51 { this.base = base; 52 this.removeDenied = removeDenied; } 53 54 55 public boolean hasNext() 56 { return base.hasNext(); } 57 58 59 public Object next() 60 { return base.next(); } 61 62 66 public void remove() 67 { 68 if (removeDenied) throw new UnsupportedOperationException (); 69 base.remove(); 70 } 71 72 73 public void close() 74 { close( base ); } 75 76 80 public static void close( Iterator it ) 81 { NiceIterator.close( it ); } 82 } 83 84 113 | Popular Tags |