KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > uk > co > jezuk > mango > iterators > SingletonIterator


1 package uk.co.jezuk.mango.iterators;
2
3 /**
4  * Iterators over a single object
5  *
6  * @author Jez Higgins, jez@jezuk.co.uk
7  * @version $Id: SingletonIterator.java 65 2002-07-31 21:59:26Z jez $
8  */

9 public class SingletonIterator implements java.util.Iterator JavaDoc
10 {
11   public SingletonIterator(Object JavaDoc object)
12   {
13     object_ = object;
14   } // SingletonIterator
15

16   public boolean hasNext()
17   {
18     return (object_ != null);
19   } // hasNext
20

21   public Object JavaDoc next()
22   {
23     Object JavaDoc o = object_;
24     object_ = null;
25     return o;
26   } // next
27

28   public void remove()
29   {
30     throw new UnsupportedOperationException JavaDoc("uk.co.jezuk.mango.SingletonIterator does not support the remove method");
31   } // remove
32

33   //////////////////////
34
private Object JavaDoc object_;
35 } // SingletonIterator
36
Popular Tags