01: package org.objectweb.celtix.bus.management.counters;
02:
03: /** class for the performance couter */
04: public class Counter {
05:
06: private String discription;
07: private int value;
08: private float rate;
09: private Boolean runFlag;
10:
11: Counter(String 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 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: }
|