01: package com.jamonapi;
02:
03: /**
04: * Simple counter class used to track activity stats
05: *
06: * Created on December 16, 2005, 9:11 PM
07: */
08:
09: /**
10: *
11: * @author ssouza
12: */
13: final class Counter {
14:
15: private double count;
16: private boolean enabled = true;
17:
18: public void setCount(double value) {
19: if (enabled) {
20: count = value;
21: }
22: }
23:
24: /* (non-Javadoc)
25: * @see com.jamonapi.CounterInf#getCount()
26: */
27: public double getCount() {
28: if (enabled) {
29: return count;
30: } else
31: return 0;
32:
33: }
34:
35: /* (non-Javadoc)
36: * @see com.jamonapi.CounterInf#decrement()
37: */
38: public void decrement() {
39: if (enabled) {
40: --count;
41: }
42: }
43:
44: /* (non-Javadoc)
45: * @see com.jamonapi.CounterInf#increment()
46: */
47: public void increment() {
48: if (enabled) {
49: ++count;
50: }
51: }
52:
53: /* (non-Javadoc)
54: * @see com.jamonapi.CounterInf#incrementAndReturn()
55: */
56: public double incrementAndReturn() {
57: if (enabled) {
58: return ++count;
59: } else
60: return 0;
61: }
62:
63: public void enable(boolean enable) {
64: this .enabled = enable;
65: }
66:
67: public boolean isEnabled() {
68: return enabled;
69: }
70:
71: }
|