KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > ba > obl > State


1 /*
2  * Bytecode Analysis Framework
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.ba.obl;
21
22 /**
23  * Error-handling obligation analysis state.
24  * This is a set of obligations and a program path on which
25  * they are outstanding (not cleaned up).
26  *
27  * <p>See Weimer and Necula,
28  * <a HREF="http://doi.acm.org/10.1145/1028976.1029011"
29  * >Finding and preventing run-time error handling mistakes</a>,
30  * OOPSLA 2004.</p>
31  *
32  * @author David Hovemeyer
33  */

34 public class State {
35     private ObligationSet obligationSet;
36     private Path path;
37     
38     private State() {
39     }
40
41     public State(int maxObligationTypes, ObligationFactory factory) {
42         this.obligationSet = new ObligationSet(maxObligationTypes, factory);
43         this.path = new Path();
44     }
45     
46     /**
47      * @return Returns the obligationSet.
48      */

49     public ObligationSet getObligationSet() {
50         return obligationSet;
51     }
52
53     /**
54      * @return Returns the path.
55      */

56     public Path getPath() {
57         return path;
58     }
59     
60     public State duplicate() {
61         State dup = new State();
62         dup.obligationSet = this.obligationSet.duplicate();
63         dup.path = this.path.duplicate();
64         
65         return dup;
66     }
67
68     @Override JavaDoc
69          public boolean equals(Object JavaDoc o) {
70         if (o == null || o.getClass() != this.getClass())
71             return false;
72         State other = (State) o;
73         return this.obligationSet.equals(other.obligationSet)
74             || this.path.equals(other.path);
75     }
76
77     @Override JavaDoc
78          public int hashCode() {
79         return obligationSet.hashCode() + (1009 * path.hashCode());
80     }
81     
82     @Override JavaDoc
83          public String JavaDoc toString() {
84         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
85         buf.append("[");
86         buf.append(obligationSet.toString());
87         buf.append(",");
88         buf.append(path.toString());
89         buf.append("]");
90         return buf.toString();
91     }
92 }
93
94 // vim:ts=4
95
Popular Tags