KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > ba > npe > LocationWhereValueBecomesNull


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2006, 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.npe;
21
22 import edu.umd.cs.findbugs.ba.Location;
23 import edu.umd.cs.findbugs.ba.vna.ValueNumber;
24
25 /**
26  * A Location where a particular value number becomes null.
27  *
28  * @author David Hovemeyer
29  */

30 public class LocationWhereValueBecomesNull implements Comparable JavaDoc<LocationWhereValueBecomesNull> {
31     private Location location;
32     private ValueNumber valueNumber;
33     
34     /**
35      * Constructor.
36      *
37      * @param location the Location where a value becomes null
38      * @param valueNumber the value number
39      */

40     public LocationWhereValueBecomesNull(Location location, ValueNumber valueNumber) {
41         this.location = location;
42         this.valueNumber = valueNumber;
43     }
44     
45     /**
46      * @return Returns the location.
47      */

48     public Location getLocation() {
49         return location;
50     }
51     
52     /**
53      * @return Returns the valueNumber.
54      */

55     public ValueNumber getValueNumber() {
56         return valueNumber;
57     }
58     
59     /* (non-Javadoc)
60      * @see java.lang.Comparable#compareTo(java.lang.Object)
61      */

62     public int compareTo(LocationWhereValueBecomesNull o) {
63         int cmp = this.location.compareTo(o.location);
64         if (cmp != 0) {
65             return cmp;
66         }
67         cmp = this.valueNumber.compareTo(o.valueNumber);
68         return cmp;
69     }
70     
71     /* (non-Javadoc)
72      * @see java.lang.Object#equals(java.lang.Object)
73      */

74     @Override JavaDoc
75     public boolean equals(Object JavaDoc obj) {
76         if (obj == null || obj.getClass() != this.getClass()) {
77             return false;
78         }
79         LocationWhereValueBecomesNull other = (LocationWhereValueBecomesNull) obj;
80         return this.location.equals(other.location)
81             && this.valueNumber.equals(other.valueNumber);
82     }
83     
84     /* (non-Javadoc)
85      * @see java.lang.Object#hashCode()
86      */

87     @Override JavaDoc
88     public int hashCode() {
89         return location.hashCode() * 6563 + valueNumber.hashCode();
90     }
91     
92     @Override JavaDoc
93     public String JavaDoc toString() {
94         return valueNumber + " becomes null at " + location.getHandle().getPosition() +":" + location;
95     }
96 }
97
Popular Tags