1 22 package org.jboss.management.j2ee.statistics; 23 24 import javax.management.j2ee.statistics.RangeStatistic ; 25 26 33 public class RangeStatisticImpl 34 extends StatisticImpl 35 implements RangeStatistic 36 { 37 41 42 private static final long serialVersionUID = -7893492477598566197L; 43 44 48 protected long current; 49 protected long highWaterMark; 50 protected long lowWaterMark; 51 52 56 59 public RangeStatisticImpl(String pName, String pUnit, String pDescription) 60 { 61 super(pName, pUnit, pDescription); 62 } 63 64 68 71 public long getCurrent() 72 { 73 return current; 74 } 75 76 79 public long getHighWaterMark() 80 { 81 return highWaterMark; 82 } 83 84 87 public long getLowWaterMark() 88 { 89 return lowWaterMark; 90 } 91 92 95 public String toString() 96 { 97 StringBuffer tmp = new StringBuffer (); 98 tmp.append('['); 99 tmp.append("low: "); 100 tmp.append(lowWaterMark); 101 tmp.append(", high: "); 102 tmp.append(highWaterMark); 103 tmp.append(", current: "); 104 tmp.append(current); 105 tmp.append(']'); 106 tmp.append(super.toString()); 107 return tmp.toString(); 108 } 109 110 114 117 public void add() 118 { 119 set(++current); 120 } 121 122 125 public void remove() 126 { 127 if (current > 0) 128 { 129 set(--current); 130 } 131 } 132 133 136 public void reset() 137 { 138 current = 0; 139 highWaterMark = 0; 140 lowWaterMark = 0; 141 super.reset(); 142 } 143 144 public void set(long current) 145 { 146 this.current = current; 147 if (current < lowWaterMark) 148 { 149 lowWaterMark = current; 150 } 151 if (current > highWaterMark) 152 { 153 highWaterMark = current; 154 } 155 super.set(); 156 } 157 } 158 | Popular Tags |