KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > detect > StreamEquivalenceClass


1 /*
2  * FindBugs - Find bugs in Java programs
3  * Copyright (C) 2004, University of Maryland
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, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package edu.umd.cs.findbugs.detect;
21
22 import java.util.HashSet JavaDoc;
23 import java.util.Iterator JavaDoc;
24
25 /**
26  * Set of streams that are in an equivalence class.
27  *
28  * @author David Hovemeyer
29  */

30 public class StreamEquivalenceClass {
31     private HashSet JavaDoc<Stream> memberSet;
32     private boolean isClosed;
33
34     /**
35      * Constructor.
36      * Creates an empty set.
37      */

38     public StreamEquivalenceClass() {
39         this.memberSet = new HashSet JavaDoc<Stream>();
40         this.isClosed = false;
41     }
42
43     /**
44      * Add a single member to the equivalence class.
45      *
46      * @param member the member Stream
47      */

48     public void addMember(Stream member) {
49         memberSet.add(member);
50     }
51
52     /**
53      * Get Iterator over the members of the class.
54      */

55     public Iterator JavaDoc<Stream> memberIterator() {
56         return memberSet.iterator();
57     }
58
59     /**
60      * Add all members of other StreamEquivalenceClass to this one.
61      *
62      * @param other the other StreamEquivalenceClass
63      */

64     public void addAll(StreamEquivalenceClass other) {
65         memberSet.addAll(other.memberSet);
66     }
67
68     /**
69      * Mark all members of the class as being closed.
70      */

71     public void setClosed() {
72         if (!isClosed) {
73             isClosed = true;
74             for (Stream member : memberSet) {
75                 member.setClosed();
76             }
77         }
78     }
79 }
80
81 // vim:ts=4
82
Popular Tags