01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Library License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: DxListIterator.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
08:
09: package org.ozoneDB.DxLib;
10:
11: /**
12: *
13: *
14: * @author <a href="http://www.softwarebuero.de/">SMB</a>
15: * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
16: */
17: public class DxListIterator extends DxAbstractIterator {
18:
19: final static long serialVersionUID = 1L;
20:
21: DxListCollection list;
22: DxListNode node;
23: Object currentObject;
24:
25: /**
26: */
27: public DxListIterator(DxListCollection _list) {
28: list = _list;
29: reset();
30: }
31:
32: /**
33: */
34: public Object object() {
35: return currentObject;
36: }
37:
38: /**
39: */
40: public Object next() {
41: if (atFirstObject) {
42: atFirstObject = false;
43: } else {
44: if (currentObject != null && !objectRemoved) {
45: node = node.next();
46: }
47: objectRemoved = false;
48: }
49: currentObject = node != null ? node.data() : null;
50: return currentObject;
51: }
52:
53: /**
54: */
55: public void reset() {
56: node = list.head().next();
57: atFirstObject = true;
58: objectRemoved = false;
59: currentObject = null;
60: }
61:
62: /**
63: */
64: public Object removeObject() {
65: Object answer = currentObject;
66: if (currentObject != null && !objectRemoved) {
67: DxListNode delNode = node;
68: node = node.next();
69: delNode.remove();
70: objectRemoved = true;
71: list.decCounter();
72: currentObject = null;
73: }
74: return answer;
75: }
76: }
|