KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xmlc > misc > ReadIterator


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: ReadIterator.java,v 1.2 2005/01/26 08:29:24 jkjome Exp $
22  */

23
24 package org.enhydra.xml.xmlc.misc;
25
26 import java.util.Iterator JavaDoc;
27 import java.util.NoSuchElementException JavaDoc;
28
29 /**
30  * Wrapper around Iterator objects that doesn't allow modification.
31  */

32 public class ReadIterator implements Iterator JavaDoc {
33     /**
34      * Wrapper iterator.
35      */

36     private Iterator JavaDoc fIter;
37
38     /**
39      * Constructor.
40      * @param iter Iterator to wrap.
41      */

42     public ReadIterator(Iterator JavaDoc iter) {
43         fIter = iter;
44     }
45
46     /**
47      * Returns true if the iteration has more elements. (In other words,
48      * returns true if next would return an element rather than throwing
49      * an exception).
50      * @return true if the iterator has more elements.
51      * @see Iterator#hasNext
52      */

53     public boolean hasNext() {
54         return fIter.hasNext();
55     }
56
57     /**
58      * Returns the next element in the interation.
59      * @exception NoSuchElementException iteration has no more elements.
60      */

61     public Object JavaDoc next() {
62         return fIter.next();
63     }
64
65     /**
66      * Throws an exception, preventing modification of the underlying
67      * structure.
68      * @exception UnsupportedOperationException Always thrown.
69      */

70     public void remove() {
71         throw new UnsupportedOperationException JavaDoc("Modification through this iterator is not allowed");
72     }
73 }
74
Popular Tags