1 19 20 package ca.mcgill.sable.soot.attributes; 21 22 import java.util.*; 23 24 public class SootAttributesHandler { 25 26 private ArrayList attrList; 27 private String fileName; 28 private HashMap projList; 29 private long valuesSetTime; 30 private boolean update = true; 31 private ArrayList keyList; 32 private ArrayList typesToShow; 33 private boolean showAllTypes = true; 34 35 private static final String NEWLINE = "\n\r"; 36 37 public SootAttributesHandler() { 38 39 } 40 41 public void setAttrList(ArrayList attrList) { 42 this.attrList = new ArrayList(); 43 this.attrList.addAll(attrList); 44 } 45 46 public String getJimpleAttributes(int lnNum) { 47 StringBuffer sb = new StringBuffer (); 48 if (getAttrList() == null) return sb.toString(); 49 Iterator it = getAttrList().iterator(); 50 51 while (it.hasNext()) { 52 SootAttribute sa = (SootAttribute)it.next(); 53 if (sa.attrForJimpleLn(lnNum)) { 54 if (showAllTypes){ 55 sb.append(sa.getAllTextAttrs("\n")); 56 } 57 else { 58 Iterator typesIt = typesToShow.iterator(); 59 while (typesIt.hasNext()){ 60 sb.append(sa.getTextAttrsForType("\n", (String )typesIt.next())); 61 } 62 63 } 64 65 } 66 } 67 String result = sb.toString(); 68 result = result.trim(); 69 if (result.length() == 0 ) return null; 70 return result; 71 } 72 73 public ArrayList getJimpleLinks(int lnNum){ 74 Iterator it = getAttrList().iterator(); 75 ArrayList list = new ArrayList(); 76 while (it.hasNext()){ 77 SootAttribute sa = (SootAttribute)it.next(); 78 if (sa.attrForJimpleLn(lnNum)){ 79 list = sa.getAllLinkAttrs(); 80 } 81 } 82 return list; 83 } 84 85 public String getJavaAttribute(int lnNum) { 86 StringBuffer sb = new StringBuffer (); 87 if (getAttrList() == null) return sb.toString(); 88 Iterator it = getAttrList().iterator(); 89 while (it.hasNext()) { 90 SootAttribute sa = (SootAttribute)it.next(); 91 if (sa.attrForJavaLn(lnNum)) { 92 if (showAllTypes){ 93 sb.append(sa.getAllTextAttrs("<br>")); 94 } 95 else { 96 Iterator typesIt = typesToShow.iterator(); 97 while (typesIt.hasNext()){ 98 sb.append(sa.getTextAttrsForType("<br>", (String )typesIt.next())); 99 } 100 } 101 } 102 } 103 return sb.toString(); 104 } 105 106 public ArrayList getJavaLinks(int lnNum){ 107 ArrayList list = new ArrayList(); 108 if (getAttrList() == null) return list; 109 Iterator it = getAttrList().iterator(); 110 while (it.hasNext()){ 111 SootAttribute sa = (SootAttribute)it.next(); 112 if (sa.attrForJavaLn(lnNum)){ 113 if (sa.getAllLinkAttrs() != null){ 114 115 list.addAll(sa.getAllLinkAttrs()); 116 } 117 } 118 } 119 return list; 120 } 121 122 123 127 public HashMap getProjList() { 128 return projList; 129 } 130 131 135 public void setProjList(HashMap projList) { 136 this.projList = projList; 137 } 138 139 143 public ArrayList getAttrList() { 144 return attrList; 145 } 146 147 151 public String getFileName() { 152 return fileName; 153 } 154 155 159 public void setFileName(String fileName) { 160 this.fileName = fileName; 161 } 162 163 166 public long getValuesSetTime() { 167 return valuesSetTime; 168 } 169 170 173 public void setValuesSetTime(long l) { 174 valuesSetTime = l; 175 } 176 177 180 public boolean isUpdate() { 181 return update; 182 } 183 184 187 public void setUpdate(boolean b) { 188 update = b; 189 } 190 191 194 public ArrayList getKeyList() { 195 if (keyList == null) return keyList; 196 if (isShowAllTypes()){ 197 return keyList; 198 } 199 else { 200 ArrayList typeList = new ArrayList(); 201 Iterator kIt = keyList.iterator(); 202 while (kIt.hasNext()){ 203 AnalysisKey key = (AnalysisKey)kIt.next(); 204 if (getTypesToShow().contains(key.getType())){ 205 typeList.add(key); 206 } 207 } 208 return typeList; 209 } 210 } 211 212 215 public void setKeyList(ArrayList list) { 216 keyList = list; 217 } 218 219 222 public ArrayList getTypesToShow() { 223 return typesToShow; 224 } 225 226 229 public void setTypesToShow(ArrayList list) { 230 typesToShow = list; 231 } 232 233 236 public boolean isShowAllTypes() { 237 return showAllTypes; 238 } 239 240 243 public void setShowAllTypes(boolean b) { 244 showAllTypes = b; 245 } 246 247 } 248 | Popular Tags |