KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > odmg > OzoneODMGDBag


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: OzoneODMGDBag.java,v 1.1 2001/12/18 10:31:31 per_nyfelt Exp $
8

9 package org.ozoneDB.odmg;
10
11 import org.odmg.*;
12 //import org.ozoneDB.*;
13
import java.util.*;
14
15
16 /**
17  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
18  * @version $Revision: 1.1 $Date: 2001/12/18 10:31:31 $
19  */

20 public class OzoneODMGDBag extends ArrayList implements DBag {
21     
22     
23     public OzoneODMGDBag() {
24         super();
25     }
26     
27     
28     public OzoneODMGDBag( Collection _collection ) {
29         super( _collection );
30     }
31     
32     
33     /**
34      * A new <code>DBag</code> instance is created that is the union of this object
35      * and <code>otherBag</code>.
36      * This method is similar to the <code>addAll</code> method in <code>Collection</code>,
37      * except that this method creates a new collection and <code>addAll</code>
38      * modifies the object to contain the result.
39      * @param otherBag The other bag to use in the union operation.
40      * @return A <code>DBag</code> instance that contains the union of this object
41      * and <code>otherBag</code>.
42      */

43     // * @see com.sun.java.util.collections.Collection#addAll
44
public DBag union( DBag otherBag ) {
45         DBag result = new OzoneODMGDBag( this );
46         result.addAll( otherBag );
47         return result;
48     }
49     
50     
51     /**
52      * A new <code>DBag</code> instance is created that contains the intersection of
53      * this object and the <code>DBag</code> referenced by <code>otherBag</code>.
54      * This method is similar to the <code>retainAll</code> method in <code>Collection</code>,
55      * except that this method creates a new collection and <code>retainAll</code>
56      * modifies the object to contain the result.
57      * @param otherBag The other bag to use in creating the intersection.
58      * @return A <code>DBag</code> instance that contains the intersection of this
59      * object and <code>otherBag</code>.
60      */

61     // @see com.sun.java.util.collections.Collection#retainAll
62
public DBag intersection( DBag otherBag ) {
63         DBag result = new OzoneODMGDBag();
64         return result;
65     }
66     
67     
68     /**
69      * A new <code>DBag</code> instance is created that contains the difference of
70      * this object and the <code>DBag</code> instance referenced by <code>otherBag</code>.
71      * This method is similar to the <code>removeAll</code> method in <code>Collection</code>,
72      * except that this method creates a new collection and <code>removeAll</code>
73      * modifies the object to contain the result.
74      * @param otherBag The other bag to use in creating the difference.
75      * @return A <code>DBag</code> instance that contains the elements of this object
76      * minus the elements in <code>otherBag</code>.
77      */

78     // * @see com.sun.java.util.collections.Collection#removeAll
79
public DBag difference( DBag otherBag ) {
80         DBag result = union( otherBag );
81         result.removeAll( otherBag );
82         result.removeAll( this );
83         return result;
84     }
85     
86     
87     /**
88      * This method returns the number of occurrences of the object <code>obj</code>
89      * in the <code>DBag</code> collection.
90      * @param obj The value that may have elements in the collection.
91      * @return The number of occurrences of <code>obj</code> in this collection.
92      */

93     public int occurrences( Object JavaDoc obj ) {
94         int result = 0;
95         if (obj != null) {
96             for (int i = 0, size = size(); i < size; ++i) {
97                 if (obj.equals( get( i ) )) {
98                     ++result;
99                 }
100             }
101         }
102         return result;
103     }
104     
105     
106     /**
107      * NOT SUPPORTED!
108      */

109     public Object JavaDoc selectElement( String JavaDoc predicate ) throws QueryInvalidException {
110         throw new NotImplementedException( "OQL not supported" );
111     }
112     
113     
114     /**
115      * NOT SUPPORTED!
116      */

117     public java.util.Iterator JavaDoc select( String JavaDoc predicate ) throws QueryInvalidException {
118         throw new NotImplementedException( "OQL not supported" );
119     }
120     
121     
122     /**
123      * NOT SUPPORTED!
124      */

125     public DCollection query( String JavaDoc predicate ) throws QueryInvalidException {
126         throw new NotImplementedException( "OQL not supported" );
127     }
128     
129     
130     /**
131      * NOT SUPPORTED!
132      */

133     public boolean existsElement( String JavaDoc predicate ) throws QueryInvalidException {
134         throw new NotImplementedException( "OQL not supported" );
135     }
136     
137 }
138
Popular Tags