KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > util > SingletonIterator


1 //$Id: SingletonIterator.java,v 1.1 2005/04/26 06:37:54 oneovthafew Exp $
2
package org.hibernate.util;
3
4 import java.util.Iterator JavaDoc;
5
6 /**
7  * @author Gavin King
8  */

9 public final class SingletonIterator implements Iterator JavaDoc {
10
11     private Object JavaDoc value;
12     private boolean hasNext = true;
13
14     public boolean hasNext() {
15         return hasNext;
16     }
17
18     public Object JavaDoc next() {
19         if (hasNext) {
20             hasNext = false;
21             return value;
22         }
23         else {
24             throw new IllegalStateException JavaDoc();
25         }
26     }
27
28     public void remove() {
29         throw new UnsupportedOperationException JavaDoc();
30     }
31
32     public SingletonIterator(Object JavaDoc value) {
33         this.value = value;
34     }
35
36 }
37
Popular Tags