View Javadoc

1   /*
2    * $Id: Number.java 8077 2007-08-27 20:15:25Z aperepel $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.util.counters.impl;
12  
13  import org.mule.util.counters.CounterFactory.Type;
14  
15  public class Number extends AbstractCounter
16  {
17  
18      private double value = 0.0;
19  
20      public Number(String name)
21      {
22          super(name, Type.NUMBER);
23      }
24  
25      public synchronized double increment()
26      {
27          this.value++;
28          propagate();
29          return this.value;
30      }
31  
32      public synchronized double incrementBy(double value)
33      {
34          this.value += value;
35          propagate();
36          return this.value;
37      }
38  
39      public synchronized double decrement()
40      {
41          this.value--;
42          propagate();
43          return this.value;
44      }
45  
46      public synchronized void setRawValue(double value)
47      {
48          this.value = value;
49          propagate();
50      }
51  
52      public synchronized double nextValue()
53      {
54          return this.value;
55      }
56  
57  }