KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > bus > management > counters > Counter


1 package org.objectweb.celtix.bus.management.counters;
2
3 /** class for the performance couter */
4 public class Counter {
5     
6     private String JavaDoc discription;
7     private int value;
8     private float rate;
9     private Boolean JavaDoc runFlag;
10     
11     Counter(String JavaDoc disc) {
12         discription = disc;
13         runFlag = false;
14     }
15     
16     public void reset() {
17         value = 0;
18         runFlag = true;
19     }
20     
21     public int add(int i) {
22         value = value + i;
23         return value;
24     }
25     
26     public final void increase() {
27         if (runFlag) {
28             value++;
29         }
30     }
31     
32     public String JavaDoc getDiscription() {
33         return discription;
34     }
35     
36     float getRate() {
37         return rate;
38     }
39     
40     public int getValue() {
41         return value;
42     }
43     
44     public void stop() {
45         value = 0;
46         runFlag = false;
47     }
48     
49     void setRate(float r) {
50         if (rate < 1 && rate > 0) {
51             rate = r;
52         }
53         // else do nothing
54
}
55     
56     
57 }
58
Popular Tags