Coverage Report - net.wotonomy.foundation.NSSet
 
Classes in this File Line Coverage Branch Coverage Complexity
NSSet
0% 
0% 
1.375
 
 1  
 /*
 2  
 Wotonomy: OpenStep design patterns for pure Java applications.
 3  
 Copyright (C) 2000 Blacksmith, Inc.
 4  
 
 5  
 This library is free software; you can redistribute it and/or
 6  
 modify it under the terms of the GNU Lesser General Public
 7  
 License as published by the Free Software Foundation; either
 8  
 version 2.1 of the License, or (at your option) any later version.
 9  
 
 10  
 This library is distributed in the hope that it will be useful,
 11  
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
 Lesser General Public License for more details.
 14  
 
 15  
 You should have received a copy of the GNU Lesser General Public
 16  
 License along with this library; if not, see http://www.gnu.org
 17  
 */
 18  
 
 19  
 package net.wotonomy.foundation;
 20  
 
 21  
 import java.util.Collection;
 22  
 import java.util.Enumeration;
 23  
 import java.util.HashSet;
 24  
 import java.util.Iterator;
 25  
 import java.util.Set;
 26  
 import java.util.Vector;
 27  
 
 28  
 /**
 29  
 * A pure java implementation of NSSet that
 30  
 * implements Set for greater java interoperability.
 31  
 *
 32  
 * @author michael@mpowers.net
 33  
 * @author $Author: cgruber $
 34  
 * @version $Revision: 893 $
 35  
 */
 36  
 public class NSSet extends HashSet
 37  
 {
 38  
     /**
 39  
     * Default constructor.
 40  
     */
 41  
     public NSSet ()
 42  
     {
 43  0
         super();
 44  0
     }
 45  
 
 46  
     /**
 47  
     * Constructs a NSSet containing the objects
 48  
     * in the specified collection.
 49  
     */
 50  
     public NSSet ( Collection aCollection )
 51  
     {
 52  0
         super( aCollection );
 53  0
     }
 54  
 
 55  
     /**
 56  
     * Constructs a NSSet containing only
 57  
     * the specified object.
 58  
     */
 59  
     public NSSet ( Object anObject )
 60  
     {
 61  0
         super();
 62  0
         add( anObject );
 63  0
     }
 64  
 
 65  
     /**
 66  
     * Constructs a NSSet containing the objects
 67  
     * in the specified array.
 68  
     */
 69  
     public NSSet ( Object[] anObjectArray )
 70  
     {
 71  0
         super();
 72  0
         for ( int i = 0; i < anObjectArray.length; i++ )
 73  
         {
 74  0
             add( anObjectArray[i] );
 75  
         }
 76  0
     }
 77  
 
 78  
     /**
 79  
     * Returns an NSArray containing all objects in the set.
 80  
     */
 81  
     public NSArray allObjects ()
 82  
     {
 83  0
         return new NSArray( this );
 84  
     }
 85  
 
 86  
     /**
 87  
     * 
 88  
     */
 89  
     public Object anyObject ()
 90  
     {
 91  0
         throw new RuntimeException( "Not implemented yet." );
 92  
     }
 93  
 
 94  
     /**
 95  
     * Returns whether this set contains the
 96  
     * specified object.
 97  
     */
 98  
     public boolean containsObject ( Object anObject )
 99  
     {
 100  0
         return contains( anObject );
 101  
     }
 102  
 
 103  
     /**
 104  
     * Returns the number of elements in this set.
 105  
     */
 106  
     public int count ()
 107  
     {
 108  0
         return size();
 109  
     }
 110  
 
 111  
     /**
 112  
     * Returns whether this set has one or more
 113  
     * elements in common with the specified set.
 114  
     */
 115  
     public boolean intersectsSet ( Set aSet )
 116  
     {
 117  0
         Iterator it = aSet.iterator();
 118  0
         while ( it.hasNext() )
 119  
         {
 120  0
             if ( this.containsObject( it.next() ) )
 121  
             {
 122  0
                 return true;
 123  
             }
 124  
         } 
 125  0
         return false;
 126  
         
 127  
     }
 128  
 
 129  
     /**
 130  
     * Returns whether this set contains the
 131  
     * same object as the specified set.
 132  
     */
 133  
     public boolean isEqualToSet ( Set aSet )
 134  
     {
 135  0
         return equals( aSet );
 136  
     }
 137  
 
 138  
     /**
 139  
     * Returns whether this set is a subset
 140  
     * of the specified set.
 141  
     */
 142  
     public boolean isSubsetOfSet ( Set aSet )
 143  
     {
 144  0
         return aSet.containsAll( this );
 145  
     }
 146  
 
 147  
     /**
 148  
     * 
 149  
     */
 150  
     public Object member ( Object anObject )
 151  
     {
 152  0
         throw new RuntimeException( "Not implemented yet." );
 153  
     }
 154  
 
 155  
     /**
 156  
     * Returns an enumerator over the objects
 157  
     * in this set.
 158  
     */
 159  
     public Enumeration objectEnumerator ()
 160  
     {
 161  0
         return new Vector( this ).elements();
 162  
     }
 163  
 
 164  
     /**
 165  
     * Returns a set that is the intersection
 166  
     * of this set and the specified set.
 167  
     */
 168  
     public NSSet setByIntersectingSet ( Set aSet )
 169  
     {
 170  0
         NSSet result = new NSSet( this );
 171  0
         result.retainAll( aSet );
 172  0
         return result;
 173  
     }
 174  
 
 175  
     /**
 176  
     * Returns a set that contains all elements
 177  
     * in this set that are not in the specified set.
 178  
     */
 179  
     public NSSet setBySubtractingSet ( Set aSet )
 180  
     {
 181  0
         NSSet result = new NSSet( this );
 182  0
         result.removeAll( aSet );
 183  0
         return result;
 184  
     }
 185  
 
 186  
     /**
 187  
     * Returns a set that is the union
 188  
     * of this set and the specified set.
 189  
     */
 190  
     public NSSet setByUnioningSet ( Set aSet )
 191  
     {
 192  0
         NSSet result = new NSSet( this );
 193  0
         result.addAll( aSet );
 194  0
         return result;
 195  
     }
 196  
                 
 197  
 }
 198  
 
 199  
 /*
 200  
  * $Log$
 201  
  * Revision 1.2  2006/02/16 13:15:00  cgruber
 202  
  * Check in all sources in eclipse-friendly maven-enabled packages.
 203  
  *
 204  
  * Revision 1.1.1.1  2000/12/21 15:47:45  mpowers
 205  
  * Contributing wotonomy.
 206  
  *
 207  
  * Revision 1.3  2000/12/20 16:25:39  michael
 208  
  * Added log to all files.
 209  
  *
 210  
  *
 211  
  */
 212