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: DxHashIterator.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
08:
09: package org.ozoneDB.DxLib;
10:
11: import java.io.*;
12: import java.util.*;
13:
14: /**
15: *
16: *
17: * @author <a href="http://www.softwarebuero.de/">SMB</a>
18: * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
19: */
20: public final class DxHashIterator extends DxAbstractIterator {
21:
22: final static long serialVersionUID = 1L;
23:
24: Enumeration keyEnum;
25: Enumeration objEnum;
26: Object currentKey;
27: Object currentObject;
28: Hashtable ht;
29:
30: /**
31: */
32: public DxHashIterator(DxHashCollection _coll) {
33: ht = _coll.internalHashtable();
34: reset();
35: }
36:
37: /**
38: */
39: public Object object() {
40: return currentObject;
41: }
42:
43: /**
44: */
45: public Object key() {
46: return currentKey;
47: }
48:
49: /**
50: */
51: public Object next() {
52: if (atFirstObject) {
53: atFirstObject = false;
54: } else {
55: if (objEnum.hasMoreElements()) {
56: currentObject = objEnum.nextElement();
57: currentKey = keyEnum.nextElement();
58: } else {
59: return null;
60: }
61: }
62: return object();
63: }
64:
65: /**
66: */
67: public void reset() {
68: atFirstObject = true;
69: objectRemoved = false;
70: keyEnum = ht.keys();
71: objEnum = ht.elements();
72: if (objEnum.hasMoreElements()) {
73: currentObject = objEnum.nextElement();
74: }
75: if (keyEnum.hasMoreElements()) {
76: currentKey = keyEnum.nextElement();
77: }
78: }
79:
80: /**
81: */
82: public synchronized Object removeObject() {
83: return ht.remove(currentKey);
84: }
85: }
|