KickJava   Java API By Example, From Geeks To Geeks.

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


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 soot.*;
23 import java.util.*;
24
25 public class heuristicTuple{
26     BitSet heuristics;
27     int bitSetSize;
28     Vector methodName; //local is assigned the result of this method call
29
Vector objectClassName; //local is initialized with a new invocation of this class
30
Vector fieldName; //local is initialized with a field
31
Vector castStrings; //local is casted to a type
32

33     public heuristicTuple(int bits){
34         heuristics =new BitSet(bits);
35         this.methodName= new Vector();
36         this.objectClassName = new Vector();
37         this.fieldName = new Vector();
38         this.castStrings = new Vector();
39         bitSetSize=bits;
40     }
41
42     public void addCastString(String JavaDoc castString){
43         this.castStrings.add(castString);
44         setHeuristic(infoGatheringAnalysis.CAST);
45     }
46     
47     public List getCastStrings(){
48         return castStrings;
49     }
50     
51     public void setFieldName(String JavaDoc fieldName){
52     this.fieldName.add(fieldName);
53     setHeuristic(infoGatheringAnalysis.FIELDASSIGN);
54     }
55     
56     public List getFieldName(){
57     return fieldName;
58     }
59
60     public void setObjectClassName(String JavaDoc objectClassName){
61     this.objectClassName.add(objectClassName);
62     setHeuristic(infoGatheringAnalysis.CLASSNAME);
63     }
64     
65     public List getObjectClassName(){
66     return objectClassName;
67     }
68
69     public void setMethodName(String JavaDoc methodName){
70         this.methodName.add(methodName);
71         setHeuristic(infoGatheringAnalysis.METHODNAME);
72         if(methodName.startsWith("get") || methodName.startsWith("set"))
73             setHeuristic(infoGatheringAnalysis.GETSET);
74     }
75     
76     public List getMethodName(){
77     return methodName;
78     }
79
80     public void setHeuristic(int bitIndex){
81     heuristics.set(bitIndex);
82     }
83
84     public boolean getHeuristic(int bitIndex){
85     return heuristics.get(bitIndex);
86     }
87
88     public boolean isAnyHeuristicSet(){
89     return !heuristics.isEmpty();
90     }
91
92
93     public String JavaDoc getPrint(){
94     String JavaDoc temp ="BitSet: ";
95     for(int i=0;i<bitSetSize;i++){
96         if(getHeuristic(i))//i bit is set
97
temp=temp.concat("1");
98         else
99         temp=temp.concat("0");
100     }
101
102     temp=temp.concat(" Field: "+fieldName.toString());
103
104     temp=temp.concat(" Method: ");
105     Iterator it = getMethodName().iterator();
106     while(it.hasNext()){
107         temp = temp.concat((String JavaDoc)it.next()+" , ");
108     }
109
110     temp=temp.concat(" Class: "+objectClassName.toString());
111
112     //System.out.println("TUPLE:"+temp);
113
return temp;
114     }
115
116 }
Popular Tags