001: /*****************************************************************************
002: * Source code information
003: * -----------------------
004: * Original author Ian Dickinson, HP Labs Bristol
005: * Author email ian.dickinson@hp.com
006: * Package Jena 2
007: * Web http://sourceforge.net/projects/jena/
008: * Created 04-Dec-2003
009: * Filename $RCSfile: NodeListIterator.java,v $
010: * Revision $Revision: 1.6 $
011: * Release status $State: Exp $
012: *
013: * Last modified on $Date: 2008/01/02 12:09:42 $
014: * by $Author: andy_seaborne $
015: *
016: * (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
017: * [See end of file]
018: *****************************************************************************/package com.hp.hpl.jena.util.xml;
019:
020: // Imports
021: ///////////////
022: import java.util.*;
023:
024: import org.w3c.dom.NodeList;
025:
026: /**
027: * <p>
028: * Implements the java.util.Iterator interface for DOM node lists.
029: * </p>
030: *
031: * @author Ian Dickinson, HP Labs (<a href="mailto:Ian.Dickinson@hp.com" >email</a>)
032: * @version CVS $Id: NodeListIterator.java,v 1.6 2008/01/02 12:09:42 andy_seaborne Exp $
033: */
034: public class NodeListIterator implements Iterator {
035:
036: // Constants
037: //////////////////////////////////
038:
039: // Static variables
040: //////////////////////////////////
041:
042: // Instance variables
043: //////////////////////////////////
044:
045: /** The node list we are wrapping */
046: protected NodeList m_nodeList;
047:
048: /** The current index into the list */
049: protected int m_index = 0;
050:
051: // Constructors
052: //////////////////////////////////
053:
054: public NodeListIterator(NodeList nodeList) {
055: m_nodeList = nodeList;
056: }
057:
058: // External signature methods
059: //////////////////////////////////
060:
061: /**
062: * Removing from a node list is not supported.
063: */
064: public void remove() {
065: throw new UnsupportedOperationException(
066: "Cannot remove() from a DOM nodelist");
067: }
068:
069: /**
070: * Answer true if there is at least one more node in the node list
071: */
072: public boolean hasNext() {
073: return m_index < m_nodeList.getLength();
074: }
075:
076: /**
077: * Answer the next object from the list
078: */
079: public Object next() {
080: return m_nodeList.item(m_index++);
081: }
082:
083: // Internal implementation methods
084: //////////////////////////////////
085:
086: //==============================================================================
087: // Inner class definitions
088: //==============================================================================
089:
090: }
091:
092: /*
093: * (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
094: * All rights reserved.
095: *
096: * Redistribution and use in source and binary forms, with or without
097: * modification, are permitted provided that the following conditions
098: * are met:
099: * 1. Redistributions of source code must retain the above copyright
100: * notice, this list of conditions and the following disclaimer.
101: * 2. Redistributions in binary form must reproduce the above copyright
102: * notice, this list of conditions and the following disclaimer in the
103: * documentation and/or other materials provided with the distribution.
104: * 3. The name of the author may not be used to endorse or promote products
105: * derived from this software without specific prior written permission.
106: *
107: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
108: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
109: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
110: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
111: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
112: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
113: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
114: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
115: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
116: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
117: */
|