KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > DxLib > DxListIterator


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: DxListIterator.java,v 1.6 2000/10/28 16:55:14 daniela Exp $
8

9 package org.ozoneDB.DxLib;
10
11 /**
12  *
13  *
14  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
15  * @version $Revision: 1.6 $Date: 2000/10/28 16:55:14 $
16  */

17 public class DxListIterator extends DxAbstractIterator {
18     
19     final static long serialVersionUID = 1L;
20     
21     DxListCollection list;
22     DxListNode node;
23     Object JavaDoc currentObject;
24     
25     
26     /**
27      */

28     public DxListIterator( DxListCollection _list ) {
29         list = _list;
30         reset();
31     }
32     
33     
34     /**
35      */

36     public Object JavaDoc object() {
37         return currentObject;
38     }
39     
40     
41     /**
42      */

43     public Object JavaDoc next() {
44         if (atFirstObject) {
45             atFirstObject = false;
46         } else {
47             if (currentObject != null && !objectRemoved) {
48                 node = node.next();
49             }
50             objectRemoved = false;
51         }
52         currentObject = node != null ? node.data() : null;
53         return currentObject;
54     }
55     
56     
57     /**
58      */

59     public void reset() {
60         node = list.head().next();
61         atFirstObject = true;
62         objectRemoved = false;
63         currentObject = null;
64     }
65     
66     
67     /**
68      */

69     public Object JavaDoc removeObject() {
70         Object JavaDoc answer = currentObject;
71         if (currentObject != null && !objectRemoved) {
72             DxListNode delNode = node;
73             node = node.next();
74             delNode.remove();
75             objectRemoved = true;
76             list.decCounter();
77             currentObject = null;
78         }
79         return answer;
80     }
81 }
82
Popular Tags