KickJava   Java API By Example, From Geeks To Geeks.

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


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: DxAbstractSet.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 abstract class DxAbstractSet extends DxAbstractCollection implements DxSet {
18     
19     final static long serialVersionUID = 1L;
20     
21     
22     /** */
23     public boolean equals( Object JavaDoc obj ) {
24         if (obj instanceof DxSet && obj != null) {
25             DxSet rhs = (DxSet)obj;
26             
27             if (this == obj) {
28                 return true;
29             }
30             
31             if (count() != rhs.count()) {
32                 return false;
33             }
34             
35             return containsAll( rhs );
36         } else {
37             return false;
38         }
39     }
40     
41     
42     /**
43      */

44     public synchronized boolean retainAll( DxCollection coll ) {
45         boolean answer = false;
46         DxIterator it = iterator();
47         Object JavaDoc obj;
48         while ((obj = it.next()) != null) {
49             if (!coll.contains( obj )) {
50                 it.removeObject();
51                 answer = true;
52             }
53         }
54         return answer;
55     }
56     
57 }
58
Popular Tags