001: // You can redistribute this software and/or modify it under the terms of
002: // the Ozone Library License version 1 published by ozone-db.org.
003: //
004: // The original code and portions created by SMB are
005: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006: //
007: // $Id: OzoneODMGDBag.java,v 1.1 2002/05/08 15:03:21 per_nyfelt Exp $
008:
009: package org.ozoneDB.odmg;
010:
011: import org.odmg.*; //import org.ozoneDB.*;
012: import java.util.*;
013:
014: /**
015: * @author <a href="http://www.softwarebuero.de/">SMB</a>
016: * @version $Revision: 1.1 $Date: 2002/05/08 15:03:21 $
017: */
018: public class OzoneODMGDBag extends ArrayList implements DBag {
019:
020: public OzoneODMGDBag() {
021: super ();
022: }
023:
024: public OzoneODMGDBag(Collection _collection) {
025: super (_collection);
026: }
027:
028: /**
029: * A new <code>DBag</code> instance is created that is the union of this object
030: * and <code>otherBag</code>.
031: * This method is similar to the <code>addAll</code> method in <code>Collection</code>,
032: * except that this method creates a new collection and <code>addAll</code>
033: * modifies the object to contain the result.
034: * @param otherBag The other bag to use in the union operation.
035: * @return A <code>DBag</code> instance that contains the union of this object
036: * and <code>otherBag</code>.
037: */
038: // * @see com.sun.java.util.collections.Collection#addAll
039: public DBag union(DBag otherBag) {
040: DBag result = new OzoneODMGDBag(this );
041: result.addAll(otherBag);
042: return result;
043: }
044:
045: /**
046: * A new <code>DBag</code> instance is created that contains the intersection of
047: * this object and the <code>DBag</code> referenced by <code>otherBag</code>.
048: * This method is similar to the <code>retainAll</code> method in <code>Collection</code>,
049: * except that this method creates a new collection and <code>retainAll</code>
050: * modifies the object to contain the result.
051: * @param otherBag The other bag to use in creating the intersection.
052: * @return A <code>DBag</code> instance that contains the intersection of this
053: * object and <code>otherBag</code>.
054: */
055: // @see com.sun.java.util.collections.Collection#retainAll
056: public DBag intersection(DBag otherBag) {
057: DBag result = new OzoneODMGDBag();
058: return result;
059: }
060:
061: /**
062: * A new <code>DBag</code> instance is created that contains the difference of
063: * this object and the <code>DBag</code> instance referenced by <code>otherBag</code>.
064: * This method is similar to the <code>removeAll</code> method in <code>Collection</code>,
065: * except that this method creates a new collection and <code>removeAll</code>
066: * modifies the object to contain the result.
067: * @param otherBag The other bag to use in creating the difference.
068: * @return A <code>DBag</code> instance that contains the elements of this object
069: * minus the elements in <code>otherBag</code>.
070: */
071: // * @see com.sun.java.util.collections.Collection#removeAll
072: public DBag difference(DBag otherBag) {
073: DBag result = union(otherBag);
074: result.removeAll(otherBag);
075: result.removeAll(this );
076: return result;
077: }
078:
079: /**
080: * This method returns the number of occurrences of the object <code>obj</code>
081: * in the <code>DBag</code> collection.
082: * @param obj The value that may have elements in the collection.
083: * @return The number of occurrences of <code>obj</code> in this collection.
084: */
085: public int occurrences(Object obj) {
086: int result = 0;
087: if (obj != null) {
088: for (int i = 0, size = size(); i < size; ++i) {
089: if (obj.equals(get(i))) {
090: ++result;
091: }
092: }
093: }
094: return result;
095: }
096:
097: /**
098: * NOT SUPPORTED!
099: */
100: public Object selectElement(String predicate)
101: throws QueryInvalidException {
102: throw new NotImplementedException("OQL not supported");
103: }
104:
105: /**
106: * NOT SUPPORTED!
107: */
108: public java.util.Iterator select(String predicate)
109: throws QueryInvalidException {
110: throw new NotImplementedException("OQL not supported");
111: }
112:
113: /**
114: * NOT SUPPORTED!
115: */
116: public DCollection query(String predicate)
117: throws QueryInvalidException {
118: throw new NotImplementedException("OQL not supported");
119: }
120:
121: /**
122: * NOT SUPPORTED!
123: */
124: public boolean existsElement(String predicate)
125: throws QueryInvalidException {
126: throw new NotImplementedException("OQL not supported");
127: }
128:
129: }
|