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.LongBuffer;
32:
33: /**
34: * Class for monitoring a PerfData Long instrument.
35: *
36: * @author Brian Doherty
37: * @version 1.8, 05/05/07
38: * @since 1.5
39: */
40: public class PerfLongMonitor extends AbstractMonitor implements
41: LongMonitor {
42:
43: /**
44: * The buffer containing the data for the long instrument.
45: */
46: LongBuffer lb;
47:
48: /**
49: * Constructor to create a LongMonitor object for the long instrument
50: * represented by the data in the given buffer.
51: *
52: * @param name the name of the long instrument
53: * @param u the units of measure attribute
54: * @param v the variability attribute
55: * @param supported support level indicator
56: * @param lb the buffer containing the long instrument data.
57: */
58: public PerfLongMonitor(String name, Units u, Variability v,
59: boolean supported, LongBuffer lb) {
60: super (name, u, v, supported);
61: this .lb = lb;
62: }
63:
64: /**
65: * {@inheritDoc}
66: * The object returned contains a Long object containing the
67: * current value of the LongInstrument.
68: *
69: * @return Object - the current value of the the LongInstrument. The
70: * return type is guaranteed to be of type Long.
71: */
72: public Object getValue() {
73: return new Long(lb.get(0));
74: }
75:
76: /**
77: * Return the current value of the LongInstrument as an long.
78: *
79: * @return long - the current value of the LongInstrument
80: */
81: public long longValue() {
82: return lb.get(0);
83: }
84: }
|