home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / util / coll / BasicIterator.class (.txt) next >
Encoding:
Java Class File  |  2000-06-30  |  1015 b   |  47 lines

  1. package com.extensibility.util.coll;
  2.  
  3. import com.sun.java.util.collections.Iterator;
  4. import com.sun.java.util.collections.UnsupportedOperationException;
  5.  
  6. public abstract class BasicIterator implements Iterator {
  7.    Object onDeck = null;
  8.    Object atBat = null;
  9.    boolean init = false;
  10.  
  11.    private void init() {
  12.       if (!this.init) {
  13.          this.onDeck = this.getNext();
  14.          this.atBat = null;
  15.          this.init = true;
  16.       }
  17.  
  18.    }
  19.  
  20.    public boolean hasNext() {
  21.       this.init();
  22.       return this.onDeck != null;
  23.    }
  24.  
  25.    public Object next() {
  26.       this.init();
  27.       this.atBat = this.onDeck;
  28.       this.onDeck = this.getNext();
  29.       return this.atBat;
  30.    }
  31.  
  32.    public void remove() {
  33.       if (this.atBat == null) {
  34.          throw new IllegalStateException();
  35.       } else {
  36.          this.removeItem(this.atBat);
  37.          this.atBat = null;
  38.       }
  39.    }
  40.  
  41.    protected void removeItem(Object var1) {
  42.       throw new UnsupportedOperationException();
  43.    }
  44.  
  45.    protected abstract Object getNext();
  46. }
  47.