KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > management > j2ee > statistics > BoundedRangeStatisticImpl


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.management.j2ee.statistics;
23
24 import javax.management.j2ee.statistics.BoundedRangeStatistic JavaDoc;
25
26 /**
27  * This class is the JBoss specific BoundedRangeStatistic implementation
28  *
29  * @author <a HREF="mailto:mclaugs@comcast.net">Scott McLaughlin</a>
30  * @version $Revision: 37459 $
31  */

32 public class BoundedRangeStatisticImpl
33         extends StatisticImpl
34         implements BoundedRangeStatistic JavaDoc
35 {
36    // -------------------------------------------------------------------------
37
// Constants
38
// -------------------------------------------------------------------------
39

40    /** @since 4.0.2 */
41    private static final long serialVersionUID = 3607798304045224550L;
42    
43    // -------------------------------------------------------------------------
44
// Members
45
// -------------------------------------------------------------------------
46

47    protected BoundaryStatisticImpl boundaryStat;
48    protected RangeStatisticImpl rangeStat;
49
50    // -------------------------------------------------------------------------
51
// Constructors
52
// -------------------------------------------------------------------------
53

54    /**
55     * Create a named BoundedRangeStatistic with the given upper and lower bounds.
56     *
57     * @param name the name of the statistic
58     * @param units the units of the statistic
59     * @param description the description of the statistic
60     * @param lowerBound the lower bound the statistic will attain
61     * @param upperBound the upper bound the statistic will attain
62     */

63    public BoundedRangeStatisticImpl(String JavaDoc name, String JavaDoc units, String JavaDoc description,
64                                     long lowerBound, long upperBound)
65    {
66       super(name, units, description);
67       boundaryStat = new BoundaryStatisticImpl(name, units, description,
68               lowerBound, upperBound);
69       rangeStat = new RangeStatisticImpl(name, units, description);
70    }
71
72    // -------------------------------------------------------------------------
73
// CountStatistic Implementation
74
// -------------------------------------------------------------------------
75

76    /**
77     * @return The value of Current
78     */

79    public long getCurrent()
80    {
81       return rangeStat.getCurrent();
82    }
83
84    /**
85     * @return The value of HighWaterMark
86     */

87    public long getHighWaterMark()
88    {
89       return rangeStat.getHighWaterMark();
90    }
91
92    /**
93     * @return The value of LowWaterMark
94     */

95    public long getLowWaterMark()
96    {
97       return rangeStat.getLowWaterMark();
98    }
99
100    /**
101     * @return The value of Lower Bound
102     */

103    public long getLowerBound()
104    {
105       return boundaryStat.getLowerBound();
106    }
107
108    /**
109     * @return The value of Upper Bound
110     */

111    public long getUpperBound()
112    {
113       return boundaryStat.getUpperBound();
114    }
115
116    /**
117     * @return Debug Information about this Instance
118     */

119    public String JavaDoc toString()
120    {
121       return "BoundedRangeStatistics[ " + rangeStat.toString() + ", " + boundaryStat.toString() + " ]";
122    }
123
124    // -------------------------------------------------------------------------
125
// Methods
126
// -------------------------------------------------------------------------
127

128    /**
129     * Adds a hit to this counter
130     */

131    public void add()
132    {
133       rangeStat.add();
134    }
135
136    /**
137     * Removes a hit to this counter
138     */

139    public void remove()
140    {
141       rangeStat.remove();
142    }
143
144    /**
145     * Resets the statistics to the initial values
146     */

147    public void reset()
148    {
149       rangeStat.reset();
150    }
151
152    /**
153     * Set the current value of the RangeStatistic
154     *
155     * @param current the new current value
156     */

157    public void set(long current)
158    {
159       rangeStat.set(current);
160    }
161 }
162
Popular Tags