litesoft
@ 938
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.core.util; import java.util.*; /** * This class's purpose is to be extended by any concrete Iterator that is * wrapping/decorating another Iterator.<p> * * @author George Smith * @version 1.0 7/28/01 */ public abstract class AbstractWrappingIterator<T> extends AbstractReadOnlyIterator<T> { /** * Construct an Iterator wrapping Iterator.<p> * * @param pIterator Iterator to be <i>wrapped</i> (!null).<p> * * @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/Util/Iterator.html">java.util.Iterator</a> */ protected AbstractWrappingIterator( Iterator<T> pIterator ) throws NullPointerException { if ( (zIterator = pIterator) == null ) { throw new NullPointerException( "Iterator was null" ); } } /** * Reference to the <i>wrapped</i> Iterator. */ protected Iterator<T> zIterator; /** * This hasNext() simply forwards the request to the <i>wrapped</i> Iterator.<p> * * @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/Util/Iterator.html#hasNext()">java.util.Iterator#hasNext()</a> */ @Override public boolean hasNext() { return zIterator.hasNext(); } /** * This next() simply forwards the request to the <i>wrapped</i> Iterator.<p> * * @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/Util/Iterator.html#next()">java.util.Iterator#next()</a> */ @Override public T next() { return zIterator.next(); } @Override public void dispose() { if ( zIterator instanceof Disposable ) { ((Disposable) zIterator).dispose(); } super.dispose(); } } |