KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > dava > toolkits > base > renamer > heuristicSet


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2005 Nomair A. Naeem
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 package soot.dava.toolkits.base.renamer;
21
22 import java.util.*;
23 import soot.*;
24
25 public class heuristicSet {
26     HashMap set;
27
28     public heuristicSet() {
29         set = new HashMap();
30     }
31
32     private heuristicTuple getTuple(Local var) {
33         return (heuristicTuple) set.get(var);
34     }
35
36     public void add(Local var, int bits) {
37         heuristicTuple temp = new heuristicTuple(bits);
38         set.put(var, temp);
39     }
40
41     public void addCastString(Local var, String JavaDoc castString){
42         heuristicTuple retrieved = getTuple(var);
43         retrieved.addCastString(castString);
44     }
45     
46     public List getCastStrings(Local var){
47         heuristicTuple retrieved = getTuple(var);
48         return retrieved.getCastStrings();
49     }
50     
51     public void setFieldName(Local var, String JavaDoc fieldName) {
52         heuristicTuple retrieved = getTuple(var);
53         retrieved.setFieldName(fieldName);
54     }
55
56     public List getFieldName(Local var) {
57         heuristicTuple retrieved = getTuple(var);
58         return retrieved.getFieldName();
59     }
60
61     public void setObjectClassName(Local var, String JavaDoc objectClassName) {
62         heuristicTuple retrieved = getTuple(var);
63         retrieved.setObjectClassName(objectClassName);
64     }
65
66     public List getObjectClassName(Local var) {
67         heuristicTuple retrieved = getTuple(var);
68         return retrieved.getObjectClassName();
69     }
70
71     public void setMethodName(Local var, String JavaDoc methodName) {
72         heuristicTuple retrieved = getTuple(var);
73         retrieved.setMethodName(methodName);
74     }
75
76     public List getMethodName(Local var) {
77         heuristicTuple retrieved = getTuple(var);
78         return retrieved.getMethodName();
79     }
80
81     public void setHeuristic(Local var, int bitIndex) {
82         heuristicTuple retrieved = getTuple(var);
83         retrieved.setHeuristic(bitIndex);
84     }
85
86     public boolean getHeuristic(Local var, int bitIndex) {
87         heuristicTuple retrieved = getTuple(var);
88         return retrieved.getHeuristic(bitIndex);
89     }
90
91     public boolean isAnyHeuristicSet(Local var) {
92         heuristicTuple retrieved = getTuple(var);
93         return retrieved.isAnyHeuristicSet();
94     }
95
96     public void print() {
97         Iterator it = set.keySet().iterator();
98         while (it.hasNext()) {
99             Object JavaDoc local = it.next();
100             heuristicTuple temp = (heuristicTuple) set.get(local);
101             String JavaDoc tuple = temp.getPrint();
102             System.out.println(local + " " + tuple + " DefinedType: "
103                     + ((Local) local).getType());
104         }
105     }
106
107     public Iterator getLocalsIterator() {
108         return set.keySet().iterator();
109     }
110     
111     public boolean contains(Local var){
112         if(set.get(var) != null)
113             return true;
114         else
115             return false;
116     }
117 }
Popular Tags