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: DxMultiIterator.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 DxMultiIterator extends DxAbstractIterator {
18:
19: final static long serialVersionUID = 1L;
20:
21: DxMultiMap multiMap;
22: DxIterator mapIt;
23: DxIterator contIt;
24:
25: /**
26: */
27: public DxMultiIterator(DxMultiMap _multiMap) {
28: multiMap = _multiMap;
29: reset();
30: }
31:
32: /**
33: */
34: public Object object() {
35: return contIt != null ? contIt.object() : null;
36: }
37:
38: /**
39: */
40: public Object key() {
41: return mapIt != null ? mapIt.key() : null;
42: }
43:
44: /**
45: */
46: public Object next() {
47: Object obj = contIt != null ? contIt.next() : null;
48: if (obj == null) {
49: contIt = null;
50: if (mapIt != null && mapIt.next() != null) {
51: contIt = ((DxCollection) mapIt.object()).iterator();
52: obj = contIt.next();
53: } else {
54: mapIt = null;
55: }
56: }
57: return obj;
58: }
59:
60: /**
61: */
62: public void reset() {
63: mapIt = multiMap.iterator();
64: if (mapIt.next() != null) {
65: contIt = ((DxCollection) mapIt.object()).iterator();
66: } else {
67: mapIt = null;
68: }
69: }
70:
71: /**
72: */
73: public Object removeObject() {
74: Object obj = null;
75: if (contIt != null) {
76: obj = contIt.removeObject();
77: multiMap.multiItemCount--;
78: if (((DxCollection) mapIt.object()).isEmpty()) {
79: contIt = null;
80: mapIt.removeObject();
81: }
82: }
83: return obj;
84: }
85: }
|