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: OzoneODMGDSet.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 OzoneODMGDSet extends HashSet implements DSet {
019:
020: public OzoneODMGDSet() {
021: super ();
022: }
023:
024: public OzoneODMGDSet(Collection _collection) {
025: super (_collection);
026: }
027:
028: /**
029: * Create a new <code>DSet</code> object that is the set union of this
030: * <code>DSet</code> object and the set referenced by <code>otherSet</code>.
031: * @param otherSet The other set to be used in the union operation.
032: * @return A newly created <code>DSet</code> instance that contains the union of the two sets.
033: */
034: public DSet union(DSet otherSet) {
035: DSet result = new OzoneODMGDSet(this );
036: result.addAll(otherSet);
037: return result;
038: }
039:
040: /**
041: * Create a new <code>DSet</code> object that is the set intersection of this
042: * <code>DSet</code> object and the set referenced by <code>otherSet</code>.
043: * @param otherSet The other set to be used in the intersection operation.
044: * @return A newly created <code>DSet</code> instance that contains the
045: * intersection of the two sets.
046: */
047: public DSet intersection(DSet otherSet) {
048: DSet result = new OzoneODMGDSet(this );
049: result.retainAll(otherSet);
050: return result;
051: }
052:
053: /**
054: * Create a new <code>DSet</code> object that contains the elements of this
055: * collection minus the elements in <code>otherSet</code>.
056: * @param otherSet A set containing elements that should not be in the result set.
057: * @return A newly created <code>DSet</code> instance that contains the elements
058: * of this set minus those elements in <code>otherSet</code>.
059: */
060: public DSet difference(DSet otherSet) {
061: DSet result = new OzoneODMGDSet(this );
062: result.removeAll(otherSet);
063: return result;
064: }
065:
066: /**
067: * Determine whether this set is a subset of the set referenced by <code>otherSet</code>.
068: * @param otherSet Another set.
069: * @return True if this set is a subset of the set referenced by <code>otherSet</code>,
070: * otherwise false.
071: */
072: public boolean subsetOf(DSet otherSet) {
073: return otherSet.containsAll(this );
074: }
075:
076: /**
077: * Determine whether this set is a proper subset of the set referenced by
078: * <code>otherSet</code>.
079: * @param otherSet Another set.
080: * @return True if this set is a proper subset of the set referenced by
081: * <code>otherSet</code>, otherwise false.
082: */
083: public boolean properSubsetOf(DSet otherSet) {
084: // because of Sets never have duplicate members this is true
085: return this .size() == otherSet.size() && subsetOf(otherSet);
086: }
087:
088: /**
089: * Determine whether this set is a superset of the set referenced by <code>otherSet</code>.
090: * @param otherSet Another set.
091: * @return True if this set is a superset of the set referenced by <code>otherSet</code>,
092: * otherwise false.
093: */
094: public boolean super setOf(DSet otherSet) {
095: return this .containsAll(otherSet);
096: }
097:
098: /**
099: * Determine whether this set is a proper superset of the set referenced by
100: * <code>otherSet</code>.
101: * @param otherSet Another set.
102: * @return True if this set is a proper superset of the set referenced by
103: * <code>otherSet</code>, otherwise false.
104: */
105: public boolean properSupersetOf(DSet otherSet) {
106: // because of Sets never have duplicate members this is true
107: return this .size() == otherSet.size() && super setOf(otherSet);
108: }
109:
110: /**
111: * NOT SUPPORTED!
112: */
113: public Object selectElement(String predicate)
114: throws QueryInvalidException {
115: throw new NotImplementedException("OQL not supported");
116: }
117:
118: /**
119: * NOT SUPPORTED!
120: */
121: public java.util.Iterator select(String predicate)
122: throws QueryInvalidException {
123: throw new NotImplementedException("OQL not supported");
124: }
125:
126: /**
127: * NOT SUPPORTED!
128: */
129: public DCollection query(String predicate)
130: throws QueryInvalidException {
131: throw new NotImplementedException("OQL not supported");
132: }
133:
134: /**
135: * NOT SUPPORTED!
136: */
137: public boolean existsElement(String predicate)
138: throws QueryInvalidException {
139: throw new NotImplementedException("OQL not supported");
140: }
141:
142: }
|