KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > util > xml > NodeListIterator


1 /*****************************************************************************
2  * Source code information
3  * -----------------------
4  * Original author Ian Dickinson, HP Labs Bristol
5  * Author email ian.dickinson@hp.com
6  * Package Jena 2
7  * Web http://sourceforge.net/projects/jena/
8  * Created 04-Dec-2003
9  * Filename $RCSfile: NodeListIterator.java,v $
10  * Revision $Revision: 1.3 $
11  * Release status $State: Exp $
12  *
13  * Last modified on $Date: 2005/02/21 12:20:21 $
14  * by $Author: andy_seaborne $
15  *
16  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
17  * [See end of file]
18  *****************************************************************************/

19
20 // Package
21
///////////////
22
package com.hp.hpl.jena.util.xml;
23
24
25 // Imports
26
///////////////
27
import java.util.*;
28
29 import org.w3c.dom.NodeList JavaDoc;
30
31
32 /**
33  * <p>
34  * Implements the java.util.Iterator interface for DOM node lists.
35  * </p>
36  *
37  * @author Ian Dickinson, HP Labs (<a HREF="mailto:Ian.Dickinson@hp.com" >email</a>)
38  * @version CVS $Id: NodeListIterator.java,v 1.3 2005/02/21 12:20:21 andy_seaborne Exp $
39  */

40 public class NodeListIterator
41     implements Iterator
42 {
43
44     // Constants
45
//////////////////////////////////
46

47     // Static variables
48
//////////////////////////////////
49

50     // Instance variables
51
//////////////////////////////////
52

53     /** The node list we are wrapping */
54     protected NodeList JavaDoc m_nodeList;
55     
56     /** The current index into the list */
57     protected int m_index = 0;
58     
59     
60     // Constructors
61
//////////////////////////////////
62

63     public NodeListIterator( NodeList JavaDoc nodeList ) {
64         m_nodeList = nodeList;
65     }
66     
67     
68     // External signature methods
69
//////////////////////////////////
70

71     /**
72      * Removing from a node list is not supported.
73      */

74     public void remove() {
75         throw new UnsupportedOperationException JavaDoc( "Cannot remove() from a DOM nodelist" );
76     }
77
78     /**
79      * Answer true if there is at least one more node in the node list
80      */

81     public boolean hasNext() {
82         return m_index < m_nodeList.getLength();
83     }
84
85     /**
86      * Answer the next object from the list
87      */

88     public Object JavaDoc next() {
89         return m_nodeList.item( m_index++ );
90     }
91     
92
93     // Internal implementation methods
94
//////////////////////////////////
95

96     //==============================================================================
97
// Inner class definitions
98
//==============================================================================
99

100 }
101
102
103 /*
104  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
105  * All rights reserved.
106  *
107  * Redistribution and use in source and binary forms, with or without
108  * modification, are permitted provided that the following conditions
109  * are met:
110  * 1. Redistributions of source code must retain the above copyright
111  * notice, this list of conditions and the following disclaimer.
112  * 2. Redistributions in binary form must reproduce the above copyright
113  * notice, this list of conditions and the following disclaimer in the
114  * documentation and/or other materials provided with the distribution.
115  * 3. The name of the author may not be used to endorse or promote products
116  * derived from this software without specific prior written permission.
117  *
118  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
119  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
120  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
121  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
122  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
123  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
124  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
125  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
126  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
127  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
128  */

129
Popular Tags