KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > management > RangeStatisticImpl


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.management;
19
20
21 /**
22  * A range statistic implementation
23  *
24  * @version $Revision: 1.2 $
25  */

26 public class RangeStatisticImpl extends StatisticImpl {
27     private long highWaterMark;
28     private long lowWaterMark;
29     private long current;
30
31     public RangeStatisticImpl(String JavaDoc name, String JavaDoc unit, String JavaDoc description) {
32         super(name, unit, description);
33     }
34
35     public void reset() {
36         super.reset();
37         current = 0;
38         lowWaterMark = 0;
39         highWaterMark = 0;
40     }
41
42     public long getHighWaterMark() {
43         return highWaterMark;
44     }
45
46     public long getLowWaterMark() {
47         return lowWaterMark;
48     }
49
50     public long getCurrent() {
51         return current;
52     }
53
54     public void setCurrent(long current) {
55         this.current = current;
56         if (current > highWaterMark) {
57             highWaterMark = current;
58         }
59         if (current < lowWaterMark || lowWaterMark == 0) {
60             lowWaterMark = current;
61         }
62         updateSampleTime();
63     }
64
65     protected void appendFieldDescription(StringBuffer JavaDoc buffer) {
66         buffer.append(" current: ");
67         buffer.append(Long.toString(current));
68         buffer.append(" lowWaterMark: ");
69         buffer.append(Long.toString(lowWaterMark));
70         buffer.append(" highWaterMark: ");
71         buffer.append(Long.toString(highWaterMark));
72         super.appendFieldDescription(buffer);
73     }
74 }
75
Popular Tags