1 package csdl.jblanket.report.element; 2 3 import java.io.PrintWriter ; 4 import java.util.Iterator ; 5 import java.util.Set ; 6 import java.util.TreeSet ; 7 8 42 public class MethodSetElement implements Comparable { 43 44 45 private String className; 46 47 private String packageName; 48 49 50 private String timeStamp; 51 52 53 private Set testedMethodSet; 54 55 private Set untestedMethodSet; 56 57 private Set untestableMethodSet; 58 59 private Set onelineMethodSet; 60 61 private Set constructorMethodSet; 62 63 private Set excludedIndividualMethodSet; 64 65 71 public MethodSetElement(String packageName, String className) { 72 73 this.packageName = packageName; 74 this.className = className; 75 76 this.testedMethodSet = new TreeSet (); 77 this.untestedMethodSet = new TreeSet (); 78 this.untestableMethodSet = new TreeSet (); 79 this.onelineMethodSet = new TreeSet (); 80 this.constructorMethodSet = new TreeSet (); 81 this.excludedIndividualMethodSet = new TreeSet (); 82 } 83 84 89 public String getPackageName() { 90 return this.packageName; 91 } 92 93 98 public String getClassName() { 99 return this.className; 100 } 101 102 107 public int getTestedSize() { 108 return this.testedMethodSet.size(); 109 } 110 111 116 public int getUntestedSize() { 117 return this.untestedMethodSet.size(); 118 } 119 120 125 public int getUntestableSize() { 126 return this.untestableMethodSet.size(); 127 } 128 129 134 public int getOnelineSize() { 135 return this.onelineMethodSet.size(); 136 } 137 138 143 public int getConstructorSize() { 144 return this.constructorMethodSet.size(); 145 } 146 147 152 public int getExcludedIndividualSize() { 153 return this.excludedIndividualMethodSet.size(); 154 } 155 156 161 public void setTimeStamp(String timeStamp) { 162 this.timeStamp = timeStamp; 163 } 164 165 170 public void addTestMethod(MethodElement method) { 171 172 if (!this.excludedIndividualMethodSet.contains(method)) { 174 this.testedMethodSet.add(method); 175 } 176 } 177 178 183 public void addUntestMethod(MethodElement method) { 184 185 if (!this.excludedIndividualMethodSet.contains(method)) { 187 this.untestedMethodSet.add(method); 188 } 189 } 190 191 196 public void addUntestableMethod(MethodElement method) { 197 198 if (!this.excludedIndividualMethodSet.contains(method)) { 200 this.untestableMethodSet.add(method); 201 } 202 } 203 204 209 public void addOneLineMethod(MethodElement method) { 210 211 if (!this.excludedIndividualMethodSet.contains(method)) { 213 this.onelineMethodSet.add(method); 214 } 215 } 216 217 222 public void addConstructorMethod(MethodElement method) { 223 224 if (!this.excludedIndividualMethodSet.contains(method)) { 226 this.constructorMethodSet.add(method); 227 } 228 } 229 230 235 public void addExcludedIndividualMethod(MethodElement method) { 236 this.excludedIndividualMethodSet.add(method); 237 238 this.testedMethodSet.remove(method); 240 this.untestedMethodSet.remove(method); 241 this.onelineMethodSet.remove(method); 242 this.constructorMethodSet.remove(method); 243 } 244 245 250 public String toString() { 251 StringBuffer buffer = new StringBuffer (); 252 buffer.append(" <MethodSet name=\"" + this.className + "\""); 253 buffer.append(" package=\"" + this.packageName + "\""); 254 buffer.append(" tested=\"" + this.testedMethodSet.size() + "\""); 255 buffer.append(" untested=\"" + this.untestedMethodSet.size() + "\""); 256 buffer.append(" untestable=\"" + this.untestableMethodSet.size() + "\""); 257 buffer.append(" oneline=\"" + this.onelineMethodSet.size() + "\""); 258 buffer.append(" constructor=\"" + this.constructorMethodSet.size() + "\""); 259 buffer.append(" excludedindividual=\"" + this.excludedIndividualMethodSet.size() + "\""); 260 buffer.append(" timestamp=\"" + this.timeStamp + "\" >\n"); 261 262 if (this.testedMethodSet.size() > 0) { 263 buffer.append(" <tested>\n"); 264 for (Iterator i = this.testedMethodSet.iterator(); i.hasNext(); ) { 265 buffer.append("" + i.next() + "\n"); 266 } 267 buffer.append(" </tested>\n"); 268 } 269 else { 270 buffer.append(" <tested/>\n"); 271 } 272 273 if (this.untestedMethodSet.size() > 0) { 274 buffer.append(" <untested>\n"); 275 for (Iterator i = this.untestedMethodSet.iterator(); i.hasNext(); ) { 276 buffer.append("" + i.next() + "\n"); 277 } 278 buffer.append(" </untested>\n"); 279 } 280 else { 281 buffer.append(" <untested/>\n"); 282 } 283 284 if (this.untestedMethodSet.size() > 0) { 285 buffer.append(" <untestable>\n"); 286 for (Iterator i = this.untestableMethodSet.iterator(); i.hasNext(); ) { 287 buffer.append("" + i.next() + "\n"); 288 } 289 buffer.append(" </untestable>\n"); 290 } 291 else { 292 buffer.append(" <untestable/>\n"); 293 } 294 295 if (this.onelineMethodSet.size() > 0) { 296 buffer.append(" <oneline>\n"); 297 for (Iterator i = this.onelineMethodSet.iterator(); i.hasNext(); ) { 298 buffer.append("" + i.next() + "\n"); 299 } 300 buffer.append(" </oneline>\n"); 301 } 302 else { 303 buffer.append(" <oneline/>\n"); 304 } 305 306 if (this.constructorMethodSet.size() > 0) { 307 buffer.append(" <constructor>\n"); 308 for (Iterator i = this.constructorMethodSet.iterator(); i.hasNext(); ) { 309 buffer.append("" + i.next() + "\n"); 310 } 311 buffer.append(" </constructor>\n"); 312 } 313 else { 314 buffer.append(" <constructor/>\n"); 315 } 316 317 if (this.excludedIndividualMethodSet.size() > 0) { 318 buffer.append(" <excludedindividual>\n"); 319 for (Iterator i = this.excludedIndividualMethodSet.iterator(); i.hasNext(); ) { 320 buffer.append("" + i.next() + "\n"); 321 } 322 buffer.append(" </excludedindividual>\n"); 323 } 324 else { 325 buffer.append(" <excludedindividual/>\n"); 326 } 327 328 buffer.append(" </MethodSet>"); 329 330 return buffer.toString(); 331 } 332 333 338 public void write(PrintWriter writer) { 339 340 writer.write(" <MethodSet name=\"" + this.className + "\""); 341 writer.write(" package=\"" + this.packageName + "\""); 342 writer.write(" tested=\"" + this.testedMethodSet.size() + "\""); 343 writer.write(" untested=\"" + this.untestedMethodSet.size() + "\""); 344 writer.write(" untestable=\"" + this.untestableMethodSet.size() + "\""); 345 writer.write(" oneline=\"" + this.onelineMethodSet.size() + "\""); 346 writer.write(" constructor=\"" + this.constructorMethodSet.size() + "\""); 347 writer.write(" excludedindividual=\"" + this.excludedIndividualMethodSet.size() + "\""); 348 writer.write(" timestamp=\"" + this.timeStamp + "\" >\n"); 349 350 if (this.testedMethodSet.size() > 0) { 351 writer.write(" <tested>\n"); 352 for (Iterator i = this.testedMethodSet.iterator(); i.hasNext(); ) { 353 writer.write("" + i.next() + "\n"); 354 } 355 writer.write(" </tested>\n"); 356 } 357 else { 358 writer.write(" <tested/>\n"); 359 } 360 361 if (this.untestedMethodSet.size() > 0) { 362 writer.write(" <untested>\n"); 363 for (Iterator i = this.untestedMethodSet.iterator(); i.hasNext(); ) { 364 writer.write("" + i.next() + "\n"); 365 } 366 writer.write(" </untested>\n"); 367 } 368 else { 369 writer.write(" <untested/>\n"); 370 } 371 372 if (this.untestableMethodSet.size() > 0) { 373 writer.write(" <untestable>\n"); 374 for (Iterator i = this.untestableMethodSet.iterator(); i.hasNext(); ) { 375 writer.write("" + i.next() + "\n"); 376 } 377 writer.write(" </untestable>\n"); 378 } 379 else { 380 writer.write(" <untestable/>\n"); 381 } 382 383 if (this.onelineMethodSet.size() > 0) { 384 writer.write(" <oneline>\n"); 385 for (Iterator i = this.onelineMethodSet.iterator(); i.hasNext(); ) { 386 writer.write("" + i.next() + "\n"); 387 } 388 writer.write(" </oneline>\n"); 389 } 390 else { 391 writer.write(" <oneline/>\n"); 392 } 393 394 if (this.constructorMethodSet.size() > 0) { 395 writer.write(" <constructor>\n"); 396 for (Iterator i = this.constructorMethodSet.iterator(); i.hasNext(); ) { 397 writer.write("" + i.next() + "\n"); 398 } 399 writer.write(" </constructor>\n"); 400 } 401 else { 402 writer.write(" <constructor/>\n"); 403 } 404 405 if (this.excludedIndividualMethodSet.size() > 0) { 406 writer.write(" <excludedindividual>\n"); 407 for (Iterator i = this.excludedIndividualMethodSet.iterator(); i.hasNext(); ) { 408 writer.write("" + i.next() + "\n"); 409 } 410 writer.write(" </excludedindividual>\n"); 411 } 412 else { 413 writer.write(" <excludedindividual/>\n"); 414 } 415 416 writer.write(" </MethodSet>"); 417 } 418 419 427 public int compareTo(Object obj) { 428 429 if (this.packageName.compareTo(((MethodSetElement) obj).getPackageName()) != 0) { 430 return this.packageName.compareTo(((MethodSetElement) obj).getPackageName()); 431 } 432 else { 433 return this.className.compareTo(((MethodSetElement) obj).getClassName()); 434 } 435 } 436 } | Popular Tags |