KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quilt > cover > stmt > Ephemera


1 /* Ephemera.java */
2 package org.quilt.cover.stmt;
3
4 import java.util.List JavaDoc;
5 import java.util.Vector JavaDoc;
6
7 /**
8  *
9  * @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 JavaDoc 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 JavaDoc methodEnds;
22
23     /** Names of methods that have been instrumented */
24     private List JavaDoc methodNames;
25     
26     /** Constructor, initializes class name */
27     Ephemera (String JavaDoc name) {
28         className = name;
29         counterCount = 0;
30         methodEnds = new Vector JavaDoc();
31         methodNames = new Vector JavaDoc();
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 JavaDoc meName, int count) {
42         if (meName == null) {
43             throw new IllegalArgumentException JavaDoc("null name");
44         }
45         if (count < 0) {
46             throw new IllegalArgumentException JavaDoc("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.println(
55             "Ephemera.setEndCount INTERNAL ERROR: methodEnds/Names is null");
56         } else {
57             methodNames.add(meName);
58             methodEnds.add(new Integer JavaDoc(count));
59         }
60         counterCount = count;
61     }
62     /** @return class name for debugging */
63     String JavaDoc getClassName() {
64         return className;
65     }
66     /** @return cumulative counter count */
67     int getCounterCount() {
68         return counterCount;
69     }
70     /** @return a list of names of methods seen so far */
71     List JavaDoc getMethodNames () {
72         return methodNames;
73     }
74     /** @return a list of cumulative counter counts after instrumenting */
75     List JavaDoc getMethodEnds () {
76         return methodEnds;
77     }
78 }
79
Popular Tags