1 19 20 package ca.mcgill.sable.soot.attributes; 21 22 import java.util.*; 23 24 25 public class SootAttribute { 26 27 private int javaEndLn; 28 private int javaStartLn; 29 private int jimpleEndLn; 30 private int jimpleStartLn; 31 private int jimpleStartPos; 32 private int jimpleEndPos; 33 private int javaStartPos; 34 private int javaEndPos; 35 36 private ArrayList colorList; 37 private ArrayList textList; 38 39 private ArrayList linkList; 40 41 private int jimpleLength; 42 private int javaLength; 43 44 45 public ArrayList getAnalysisTypes(){ 46 ArrayList types = new ArrayList(); 47 if (getTextList() != null){ 48 Iterator it = getTextList().iterator(); 49 while (it.hasNext()){ 50 TextAttribute ta = (TextAttribute)it.next(); 51 if (!types.contains(ta.getType())){ 52 types.add(ta.getType()); 53 } 54 } 55 } 56 if (getLinkList() != null){ 57 Iterator lit = getLinkList().iterator(); 58 while (lit.hasNext()){ 59 LinkAttribute la = (LinkAttribute)lit.next(); 60 if (!types.contains(la.getType())){ 61 types.add(la.getType()); 62 } 63 } 64 } 65 66 if (getColorList() != null){ 67 Iterator cit = getColorList().iterator(); 68 while (cit.hasNext()){ 69 ColorAttribute ca = (ColorAttribute)cit.next(); 70 if (!types.contains(ca.type())){ 71 types.add(ca.type()); 72 } 73 } 74 } 75 return types; 76 } 77 78 public void addColorAttr(ColorAttribute color){ 79 if (getColorList() == null){ 80 setColorList(new ArrayList()); 81 } 82 getColorList().add(color); 83 84 } 85 86 private static final String NEWLINE = "\n"; 87 88 public void addLinkAttr(LinkAttribute link){ 89 if (getLinkList() == null){ 90 setLinkList(new ArrayList()); 91 } 92 getLinkList().add(link); 93 TextAttribute ta = new TextAttribute(); 94 ta.setInfo(link.getLabel()); 95 ta.setType(link.getType()); 96 addTextAttr(ta); 97 } 98 99 public ArrayList getAllLinkAttrs(){ 100 return getLinkList(); 101 } 102 103 public void addTextAttr(TextAttribute text){ 104 if (getTextList() == null){ 105 setTextList(new ArrayList()); 106 } 107 text.setInfo(formatText(text.getInfo())); 108 getTextList().add(text); 109 } 110 111 public String formatText(String text){ 112 text = text.replaceAll("<", "<"); 113 text = text.replaceAll(">", ">"); 114 text = text.replaceAll("&", "&"); 115 return text; 116 } 117 118 public StringBuffer getAllTextAttrs(String lineSep){ 119 StringBuffer sb = new StringBuffer (); 120 if (getTextList() != null){ 121 Iterator it = getTextList().iterator(); 122 while (it.hasNext()){ 123 TextAttribute ta = (TextAttribute)it.next(); 124 String next = ta.getInfo(); 125 if (lineSep.equals("<br>")){ 126 next = convertHTMLTags(next); 128 } 129 sb.append(next); 130 sb.append(lineSep); 131 } 132 } 133 return sb; 134 } 135 136 public StringBuffer getTextAttrsForType(String lineSep, String type){ 137 StringBuffer sb = new StringBuffer (); 138 139 if (getTextList() != null){ 140 Iterator it = getTextList().iterator(); 141 while (it.hasNext()){ 142 TextAttribute ta = (TextAttribute)it.next(); 143 if (ta.getType().equals(type)){ 144 String next = ta.getInfo(); 145 if (lineSep.equals("<br>")){ 146 next = convertHTMLTags(next); 148 } 149 sb.append(next); 150 sb.append(lineSep); 151 } 152 } 153 } 154 return sb; 155 } 156 157 public String convertHTMLTags(String next){ 158 if (next == null) return null; 159 else { 160 next = next.replaceAll("<", "<"); 161 next = next.replaceAll(">", ">"); 162 return next; 163 } 164 } 165 166 167 public boolean attrForJimpleLn(int jimple_ln) { 171 if (getJimpleStartLn() == jimple_ln) return true; 172 else return false; 173 } 174 175 public boolean attrForJavaLn(int java_ln) { 176 if (getJavaStartLn() == java_ln) return true; 177 else return false; 178 } 179 180 public SootAttribute() { 181 } 182 183 184 185 188 public int getJimpleEndPos() { 189 return jimpleEndPos; 190 } 191 192 195 public int getJimpleStartPos() { 196 return jimpleStartPos; 197 } 198 199 200 203 public void setJimpleEndPos(int i) { 204 jimpleEndPos = i; 205 } 206 207 210 public void setJimpleStartPos(int i) { 211 jimpleStartPos = i; 212 } 213 214 217 public ArrayList getTextList() { 218 return textList; 219 } 220 221 224 public void setTextList(ArrayList list) { 225 textList = list; 226 } 227 228 229 230 233 public ArrayList getLinkList() { 234 return linkList; 235 } 236 237 240 public void setLinkList(ArrayList list) { 241 linkList = list; 242 } 243 244 247 public int getJavaEndPos() { 248 return javaEndPos; 249 } 250 251 254 public int getJavaStartPos() { 255 return javaStartPos; 256 } 257 258 261 public void setJavaEndPos(int i) { 262 javaEndPos = i; 263 } 264 265 268 public void setJavaStartPos(int i) { 269 javaStartPos = i; 270 } 271 272 273 274 277 public int getJavaEndLn() { 278 return javaEndLn; 279 } 280 281 284 public int getJavaStartLn() { 285 return javaStartLn; 286 } 287 288 291 public int getJimpleEndLn() { 292 return jimpleEndLn; 293 } 294 295 298 public int getJimpleStartLn() { 299 return jimpleStartLn; 300 } 301 302 305 public void setJavaEndLn(int i) { 306 javaEndLn = i; 307 } 308 309 312 public void setJavaStartLn(int i) { 313 javaStartLn = i; 314 } 315 316 319 public void setJimpleEndLn(int i) { 320 jimpleEndLn = i; 321 } 322 323 326 public void setJimpleStartLn(int i) { 327 jimpleStartLn = i; 328 } 329 330 331 334 public int getJavaLength() { 335 return javaLength; 336 } 337 338 341 public int getJimpleLength() { 342 return jimpleLength; 343 } 344 345 348 public void setJavaLength(int i) { 349 javaLength = i; 350 } 351 352 355 public void setJimpleLength(int i) { 356 jimpleLength = i; 357 } 358 359 362 public ArrayList getColorList() { 363 return colorList; 364 } 365 366 369 public void setColorList(ArrayList list) { 370 colorList = list; 371 } 372 373 } 374 | Popular Tags |