01: /*
02: * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun in the LICENSE file that accompanied this code.
10: *
11: * This code is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * version 2 for more details (a copy is included in the LICENSE file that
15: * accompanied this code).
16: *
17: * You should have received a copy of the GNU General Public License version
18: * 2 along with this work; if not, write to the Free Software Foundation,
19: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package sun.jvmstat.perfdata.monitor;
27:
28: import sun.jvmstat.monitor.*;
29: import sun.management.counter.Units;
30: import sun.management.counter.Variability;
31: import java.nio.IntBuffer;
32:
33: /**
34: * Class for monitoring a PerfData Integer instrument.
35: *
36: * @author Brian Doherty
37: * @version 1.8, 05/05/07
38: * @since 1.5
39: */
40: public class PerfIntegerMonitor extends AbstractMonitor implements
41: IntegerMonitor {
42:
43: /**
44: * The buffer containing the data for the integer instrument.
45: */
46: IntBuffer ib;
47:
48: /**
49: * Constructor to create an IntegerMonitor object for the integer
50: * instrument represented by the data in the given buffer.
51: *
52: * @param name the name of the integer instrument
53: * @param u the units of measure attribute
54: * @param v the variability attribute
55: * @param supported support level indicator
56: * @param ib the buffer containing the integer instrument data.
57: */
58: public PerfIntegerMonitor(String name, Units u, Variability v,
59: boolean supported, IntBuffer ib) {
60: super (name, u, v, supported);
61: this .ib = ib;
62: }
63:
64: /**
65: * {@inheritDoc}
66: * The object returned contains an Integer object containing the
67: * current value of the IntegerInstrument.
68: *
69: * @return Object - the current value of the the IntegerInstrument. The
70: * return type is guaranteed to be of type Integer.
71: */
72: public Object getValue() {
73: return new Integer(ib.get(0));
74: }
75:
76: /**
77: * Return the current value of the IntegerInstrument as an int.
78: *
79: * @return int - a the current value of the IntegerInstrument.
80: */
81: public int intValue() {
82: return ib.get(0);
83: }
84: }
|