001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.management.j2ee.statistics;
023:
024: import javax.management.j2ee.statistics.BoundedRangeStatistic;
025:
026: /**
027: * This class is the JBoss specific BoundedRangeStatistic implementation
028: *
029: * @author <a href="mailto:mclaugs@comcast.net">Scott McLaughlin</a>
030: * @version $Revision: 57197 $
031: */
032: public class BoundedRangeStatisticImpl extends StatisticImpl implements
033: BoundedRangeStatistic {
034: // -------------------------------------------------------------------------
035: // Constants
036: // -------------------------------------------------------------------------
037:
038: /** @since 4.0.2 */
039: private static final long serialVersionUID = 3607798304045224550L;
040:
041: // -------------------------------------------------------------------------
042: // Members
043: // -------------------------------------------------------------------------
044:
045: protected BoundaryStatisticImpl boundaryStat;
046: protected RangeStatisticImpl rangeStat;
047:
048: // -------------------------------------------------------------------------
049: // Constructors
050: // -------------------------------------------------------------------------
051:
052: /**
053: * Create a named BoundedRangeStatistic with the given upper and lower bounds.
054: *
055: * @param name the name of the statistic
056: * @param units the units of the statistic
057: * @param description the description of the statistic
058: * @param lowerBound the lower bound the statistic will attain
059: * @param upperBound the upper bound the statistic will attain
060: */
061: public BoundedRangeStatisticImpl(String name, String units,
062: String description, long lowerBound, long upperBound) {
063: super (name, units, description);
064: boundaryStat = new BoundaryStatisticImpl(name, units,
065: description, lowerBound, upperBound);
066: rangeStat = new RangeStatisticImpl(name, units, description);
067: }
068:
069: // -------------------------------------------------------------------------
070: // CountStatistic Implementation
071: // -------------------------------------------------------------------------
072:
073: /**
074: * @return The value of Current
075: */
076: public long getCurrent() {
077: return rangeStat.getCurrent();
078: }
079:
080: /**
081: * @return The value of HighWaterMark
082: */
083: public long getHighWaterMark() {
084: return rangeStat.getHighWaterMark();
085: }
086:
087: /**
088: * @return The value of LowWaterMark
089: */
090: public long getLowWaterMark() {
091: return rangeStat.getLowWaterMark();
092: }
093:
094: /**
095: * @return The value of Lower Bound
096: */
097: public long getLowerBound() {
098: return boundaryStat.getLowerBound();
099: }
100:
101: /**
102: * @return The value of Upper Bound
103: */
104: public long getUpperBound() {
105: return boundaryStat.getUpperBound();
106: }
107:
108: /**
109: * @return Debug Information about this Instance
110: */
111: public String toString() {
112: return "BoundedRangeStatistics[ " + rangeStat.toString() + ", "
113: + boundaryStat.toString() + " ]";
114: }
115:
116: // -------------------------------------------------------------------------
117: // Methods
118: // -------------------------------------------------------------------------
119:
120: /**
121: * Adds a hit to this counter
122: */
123: public void add() {
124: rangeStat.add();
125: }
126:
127: /**
128: * Removes a hit to this counter
129: */
130: public void remove() {
131: rangeStat.remove();
132: }
133:
134: /**
135: * Resets the statistics to the initial values
136: */
137: public void reset() {
138: rangeStat.reset();
139: }
140:
141: /**
142: * Set the current value of the RangeStatistic
143: *
144: * @param current the new current value
145: */
146: public void set(long current) {
147: rangeStat.set(current);
148: }
149: }
|