KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Bytecode Analysis Framework
3  * Copyright (C) 2003-2005 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 package edu.umd.cs.findbugs.ba.npe;
20
21 import edu.umd.cs.findbugs.ba.Edge;
22 import edu.umd.cs.findbugs.ba.Location;
23
24 /**
25  * An instruction recorded as a redundant reference comparison. We keep track of
26  * the line number, in order to ensure that if the branch was duplicated, all
27  * duplicates are determined in the same way. (If they aren't, then we don't
28  * report it.)
29  */

30 public class RedundantBranch {
31     public final Location location;
32
33     public final int lineNumber;
34
35     public final IsNullValue firstValue, secondValue;
36     
37     public Edge infeasibleEdge;
38
39     /**
40      * Constructor.
41      *
42      * @param location
43      * Location of ref comparison
44      * @param lineNumber
45      * line number of ref comparison
46      * @param firstValue
47      * first value compared
48      * @param secondValue
49      * second value compared
50      */

51     public RedundantBranch(Location location, int lineNumber,
52             IsNullValue firstValue, IsNullValue secondValue) {
53         this.location = location;
54         this.lineNumber = lineNumber;
55         this.firstValue = firstValue;
56         this.secondValue = secondValue;
57     }
58     
59     /**
60      * Constructor.
61      *
62      * @param location
63      * Location of ref comparison
64      * @param lineNumber
65      * line number of ref comparison
66      * @param firstValue
67      * first value compared
68      */

69     public RedundantBranch(Location location, int lineNumber,
70             IsNullValue firstValue) {
71         this.location = location;
72         this.lineNumber = lineNumber;
73         this.firstValue = firstValue;
74         this.secondValue = null;
75     }
76     
77     /**
78      * Set the edge which has been determined to be infeasible.
79      *
80      * @param infeasibleEdge The infeasibleEdge to set.
81      */

82     public void setInfeasibleEdge(Edge infeasibleEdge) {
83         this.infeasibleEdge = infeasibleEdge;
84     }
85
86     @Override JavaDoc
87          public String JavaDoc toString() {
88         return location.toString() + ": line " + lineNumber;
89     }
90 }
91
Popular Tags