001: /* Soot - a J*va Optimization Framework
002: * Copyright (C) 2005 Nomair A. Naeem
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the
016: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017: * Boston, MA 02111-1307, USA.
018: */
019:
020: package soot.dava.toolkits.base.renamer;
021:
022: import java.util.*;
023:
024: public class heuristicTuple {
025: BitSet heuristics;
026: int bitSetSize;
027: Vector<String> methodName; //local is assigned the result of this method call
028: Vector<String> objectClassName; //local is initialized with a new invocation of this class
029: Vector<String> fieldName; //local is initialized with a field
030: Vector<String> castStrings; //local is casted to a type
031:
032: public heuristicTuple(int bits) {
033: heuristics = new BitSet(bits);
034: this .methodName = new Vector<String>();
035: this .objectClassName = new Vector<String>();
036: this .fieldName = new Vector<String>();
037: this .castStrings = new Vector<String>();
038: bitSetSize = bits;
039: }
040:
041: public void addCastString(String castString) {
042: this .castStrings.add(castString);
043: setHeuristic(infoGatheringAnalysis.CAST);
044: }
045:
046: public List<String> getCastStrings() {
047: return castStrings;
048: }
049:
050: public void setFieldName(String fieldName) {
051: this .fieldName.add(fieldName);
052: setHeuristic(infoGatheringAnalysis.FIELDASSIGN);
053: }
054:
055: public List<String> getFieldName() {
056: return fieldName;
057: }
058:
059: public void setObjectClassName(String objectClassName) {
060: this .objectClassName.add(objectClassName);
061: setHeuristic(infoGatheringAnalysis.CLASSNAME);
062: }
063:
064: public List<String> getObjectClassName() {
065: return objectClassName;
066: }
067:
068: public void setMethodName(String methodName) {
069: this .methodName.add(methodName);
070: setHeuristic(infoGatheringAnalysis.METHODNAME);
071: if (methodName.startsWith("get")
072: || methodName.startsWith("set"))
073: setHeuristic(infoGatheringAnalysis.GETSET);
074: }
075:
076: public List<String> getMethodName() {
077: return methodName;
078: }
079:
080: public void setHeuristic(int bitIndex) {
081: heuristics.set(bitIndex);
082: }
083:
084: public boolean getHeuristic(int bitIndex) {
085: return heuristics.get(bitIndex);
086: }
087:
088: public boolean isAnyHeuristicSet() {
089: return !heuristics.isEmpty();
090: }
091:
092: public String getPrint() {
093: String temp = "BitSet: ";
094: for (int i = 0; i < bitSetSize; i++) {
095: if (getHeuristic(i))//i bit is set
096: temp = temp.concat("1");
097: else
098: temp = temp.concat("0");
099: }
100:
101: temp = temp.concat(" Field: " + fieldName.toString());
102:
103: temp = temp.concat(" Method: ");
104: Iterator<String> it = getMethodName().iterator();
105: while (it.hasNext()) {
106: temp = temp.concat(it.next() + " , ");
107: }
108:
109: temp = temp.concat(" Class: " + objectClassName.toString());
110:
111: //System.out.println("TUPLE:"+temp);
112: return temp;
113: }
114:
115: }
|