01: /* Ephemera.java */
02: package org.quilt.cover.stmt;
03:
04: import java.util.List;
05: import java.util.Vector;
06:
07: /**
08: *
09: * @author < a href="mailto:jddixon@users.sourceforge.net">Jim Dixon</a>
10: */
11:
12: class Ephemera {
13:
14: /** Name of the class we are collecting information on */
15: private String className;
16:
17: /** Number of counters added so far */
18: private static int counterCount;
19:
20: /** Counter index at the end of each instrumented method */
21: private List methodEnds;
22:
23: /** Names of methods that have been instrumented */
24: private List methodNames;
25:
26: /** Constructor, initializes class name */
27: Ephemera(String name) {
28: className = name;
29: counterCount = 0;
30: methodEnds = new Vector();
31: methodNames = new Vector();
32: }
33:
34: /**
35: * Used by GraphXformers to report the cumulative number of
36: * counter vertices added after instrumenting method n.
37: *
38: * @param n Method index.
39: * @param count Cumulative number of counter vertices added.
40: */
41: void setEndCount(String meName, int count) {
42: if (meName == null) {
43: throw new IllegalArgumentException("null name");
44: }
45: if (count < 0) {
46: throw new IllegalArgumentException("negative count");
47: }
48: if (count < counterCount) {
49: System.out.println("Ephemera.setEndCount WARNING: "
50: + "count now " + counterCount
51: + " but resetting to " + count);
52: }
53: if (methodEnds == null || methodNames == null) {
54: System.out
55: .println("Ephemera.setEndCount INTERNAL ERROR: methodEnds/Names is null");
56: } else {
57: methodNames.add(meName);
58: methodEnds.add(new Integer(count));
59: }
60: counterCount = count;
61: }
62:
63: /** @return class name for debugging */
64: String getClassName() {
65: return className;
66: }
67:
68: /** @return cumulative counter count */
69: int getCounterCount() {
70: return counterCount;
71: }
72:
73: /** @return a list of names of methods seen so far */
74: List getMethodNames() {
75: return methodNames;
76: }
77:
78: /** @return a list of cumulative counter counts after instrumenting */
79: List getMethodEnds() {
80: return methodEnds;
81: }
82: }
|