KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > jimple > toolkits > annotation > arraycheck > BoolValue


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2000 Feng Qian
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 /*
21  * Modified by the Sable Research Group and others 1997-1999.
22  * See the 'credits' file distributed with Soot for the complete list of
23  * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
24  */

25
26 package soot.jimple.toolkits.annotation.arraycheck;
27
28 import soot.toolkits.graph.*;
29
30 class BoolValue
31 {
32     private boolean isRectangular;
33
34     private static BoolValue trueValue = new BoolValue(true);
35     private static BoolValue falseValue = new BoolValue(false);
36
37     public BoolValue(boolean v)
38     {
39     isRectangular = v;
40     }
41
42     public static BoolValue v(boolean v)
43     {
44     if (v)
45         return trueValue;
46     else
47         return falseValue;
48     }
49
50     public boolean getValue()
51     {
52     return isRectangular;
53     }
54
55     public boolean or(BoolValue other)
56     {
57     if (other.getValue())
58         isRectangular = true;
59
60     return isRectangular;
61     }
62
63     public boolean or(boolean other)
64     {
65     if (other)
66         isRectangular = true;
67     return isRectangular;
68     }
69
70     public boolean and(BoolValue other)
71     {
72         if (!other.getValue())
73         isRectangular = false;
74
75     return isRectangular;
76     }
77
78     public boolean and(boolean other)
79     {
80     if (!other)
81         isRectangular = false;
82
83     return isRectangular;
84     }
85
86     public int hashCode()
87     {
88     if (isRectangular)
89         return 1;
90     else
91         return 0;
92     }
93
94     public boolean equals(Object JavaDoc other)
95     {
96     if (other instanceof BoolValue)
97     {
98         return isRectangular == ((BoolValue)other).getValue();
99     }
100
101     return false;
102     }
103
104     public String JavaDoc toString()
105     {
106         return "["+isRectangular+"]";
107     }
108 }
109
110
111
Popular Tags