001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 package org.activemq.management; 019 020 021 /** 022 * A range statistic implementation 023 * 024 * @version $Revision: 1.1.1.1 $ 025 */ 026 public class RangeStatisticImpl extends StatisticImpl { 027 private long highWaterMark; 028 private long lowWaterMark; 029 private long current; 030 031 public RangeStatisticImpl(String name, String unit, String description) { 032 super(name, unit, description); 033 } 034 035 public void reset() { 036 super.reset(); 037 current = 0; 038 lowWaterMark = 0; 039 highWaterMark = 0; 040 } 041 042 public long getHighWaterMark() { 043 return highWaterMark; 044 } 045 046 public long getLowWaterMark() { 047 return lowWaterMark; 048 } 049 050 public long getCurrent() { 051 return current; 052 } 053 054 public void setCurrent(long current) { 055 this.current = current; 056 if (current > highWaterMark) { 057 highWaterMark = current; 058 } 059 if (current < lowWaterMark || lowWaterMark == 0) { 060 lowWaterMark = current; 061 } 062 updateSampleTime(); 063 } 064 065 protected void appendFieldDescription(StringBuffer buffer) { 066 buffer.append(" current: "); 067 buffer.append(Long.toString(current)); 068 buffer.append(" lowWaterMark: "); 069 buffer.append(Long.toString(lowWaterMark)); 070 buffer.append(" highWaterMark: "); 071 buffer.append(Long.toString(highWaterMark)); 072 super.appendFieldDescription(buffer); 073 } 074 }