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: DxAbstractBag.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
08:
09: package org.ozoneDB.DxLib;
10:
11: /**
12: * @author <a href="http://www.softwarebuero.de/">SMB</a>
13: * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
14: */
15: public abstract class DxAbstractBag extends DxAbstractCollection
16: implements DxBag {
17:
18: final static long serialVersionUID = 1L;
19:
20: public DxAbstractBag() {
21: }
22:
23: /**
24: * Compares two bags for equality. Returns true, if obj is also a DxBag,
25: * both bags have the same size and it contains all elements in the same
26: * order as the receiver.
27: */
28: public boolean equals(Object obj) {
29: if (obj instanceof DxBag && obj != null) {
30: DxBag rhs = (DxBag) obj;
31:
32: if (this == obj) {
33: return true;
34: }
35: if (count() != rhs.count()) {
36: return false;
37: }
38:
39: DxIterator it = iterator();
40: DxIterator it2 = rhs.iterator();
41: Object cursor;
42: Object cursor2;
43: while ((cursor = it.next()) != null
44: && (cursor2 = it2.next()) != null) {
45: if (!cursor.equals(cursor2)) {
46: return false;
47: }
48: }
49: return true;
50: } else {
51: return false;
52: }
53: }
54:
55: public synchronized boolean add(Object obj) {
56: return addBack(obj);
57: }
58:
59: public synchronized boolean addBack(Object obj) {
60: throw new RuntimeException("");
61: }
62:
63: }
|