KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > dom4j > o3impl > SingleIterator


1 /*
2  * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
3  *
4  * This software is open source.
5  * See the bottom of this file for the licence.
6  *
7  * $Id: SingleIterator.java,v 1.2 2003/06/10 16:18:36 per_nyfelt Exp $
8  */

9
10 package org.ozoneDB.xml.dom4j.o3impl;
11
12 import java.util.Iterator JavaDoc;
13
14 /** <p><code>SingleIterator</code> is an {@link Iterator} over a single
15  * object instance.</p>
16  *
17  * @author <a HREF="mailto:james.strachan@metastuff.com">James Strachan</a>
18  * @version $Revision: 1.2 $
19  */

20 public class SingleIterator implements Iterator JavaDoc {
21
22     private boolean first = true;
23     private Object JavaDoc object;
24
25     public SingleIterator(Object JavaDoc object) {
26         this.object = object;
27     }
28
29     public boolean hasNext() {
30         return first;
31     }
32
33     public Object JavaDoc next() {
34         Object JavaDoc answer = object;
35         object = null;
36         first = false;
37         return answer;
38     }
39
40     public void remove() {
41         throw new UnsupportedOperationException JavaDoc("remove() is not supported by this iterator");
42     }
43
44 }
45
46
47 /*
48  * Redistribution and use of this software and associated documentation
49  * ("Software"), with or without modification, are permitted provided
50  * that the following conditions are met:
51  *
52  * 1. Redistributions of source code must retain copyright
53  * statements and notices. Redistributions must also contain a
54  * copy of this document.
55  *
56  * 2. Redistributions in binary form must reproduce the
57  * above copyright notice, this list of conditions and the
58  * following disclaimer in the documentation and/or other
59  * materials provided with the distribution.
60  *
61  * 3. The name "DOM4J" must not be used to endorse or promote
62  * products derived from this Software without prior written
63  * permission of MetaStuff, Ltd. For written permission,
64  * please contact dom4j-info@metastuff.com.
65  *
66  * 4. Products derived from this Software may not be called "DOM4J"
67  * nor may "DOM4J" appear in their names without prior written
68  * permission of MetaStuff, Ltd. DOM4J is a registered
69  * trademark of MetaStuff, Ltd.
70  *
71  * 5. Due credit should be given to the DOM4J Project
72  * (http://dom4j.org/).
73  *
74  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
75  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
76  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
77  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
78  * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
79  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
80  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
81  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
82  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
83  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
84  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
85  * OF THE POSSIBILITY OF SUCH DAMAGE.
86  *
87  * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
88  *
89  * $Id: SingleIterator.java,v 1.2 2003/06/10 16:18:36 per_nyfelt Exp $
90  */

91
Popular Tags