Source code: javatools/db/xml/XIterator.java
1 /*
2 * XIterator.java
3 *
4 * Created on 1 aprile 2003, 19.02
5 Javatools (modified version) - Some useful general classes.
6 Copyright (C) 2002-2003 Chris Bitmead (original) Antonio Petrelli (modified)
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 Contact me at: brenmcguire@users.sourceforge.net
23 */
24
25 package javatools.db.xml;
26
27 import java.util.Iterator;
28 import javatools.db.*;
29
30 /**
31 *
32 * @author antonio
33 */
34 public class XIterator implements javatools.db.DbIterator {
35
36 /** Creates a new instance of XIterator */
37 public XIterator(XTable table) {
38 this.table = table;
39 resultIt = table.resultList.iterator();
40 }
41
42 /** Checks if this iterator has a value after the current one.
43 * @return <CODE>true</CODE>: if there is another value;
44 * <CODE>false</CODE>: otherwise.
45 */
46 public boolean hasNext() {
47 return resultIt.hasNext();
48 }
49
50 /** Are there more rows to iterator through?
51 * @throws DbException If something goes wrong.
52 * @return <CODE>true</CODE>: if there is another row;
53 * <CODE>false</CODE>: otherwise.
54 */
55 public boolean hasNextRow() throws DbException {
56 return resultIt.hasNext();
57 }
58
59 /** Takes the next object from the iterator.
60 * @return The needed object.
61 */
62 public Object next() {
63 return resultIt.next();
64 }
65
66 /**
67 * Get the next DbRow in the table.
68 * @throws DbException If something goes wrong.
69 * @return The needed row.
70 */
71 public DbRow nextRow() throws DbException {
72 return (DbRow) resultIt.next();
73 }
74
75 /** Removes the current element in the iterator.
76 */
77 public void remove() {
78 resultIt.remove();
79 }
80
81 XTable table;
82 Iterator resultIt;
83 }