blob: c73073755d0bed40e335b9461d2f9fc11ff1e383 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * 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
26package sun.jvmstat.perfdata.monitor;
27
28import sun.jvmstat.monitor.*;
29import sun.management.counter.Units;
30import sun.management.counter.Variability;
31import java.nio.LongBuffer;
32
33/**
34 * Class for monitoring a PerfData Long instrument.
35 *
36 * @author Brian Doherty
37 * @since 1.5
38 */
39public class PerfLongMonitor extends AbstractMonitor implements LongMonitor {
40
41 /**
42 * The buffer containing the data for the long instrument.
43 */
44 LongBuffer lb;
45
46 /**
47 * Constructor to create a LongMonitor object for the long instrument
48 * represented by the data in the given buffer.
49 *
50 * @param name the name of the long instrument
51 * @param u the units of measure attribute
52 * @param v the variability attribute
53 * @param supported support level indicator
54 * @param lb the buffer containing the long instrument data.
55 */
56 public PerfLongMonitor(String name, Units u, Variability v,
57 boolean supported, LongBuffer lb) {
58 super(name, u, v, supported);
59 this.lb = lb;
60 }
61
62 /**
63 * {@inheritDoc}
64 * The object returned contains a Long object containing the
65 * current value of the LongInstrument.
66 *
67 * @return Object - the current value of the the LongInstrument. The
68 * return type is guaranteed to be of type Long.
69 */
70 public Object getValue() {
71 return new Long(lb.get(0));
72 }
73
74 /**
75 * Return the current value of the LongInstrument as an long.
76 *
77 * @return long - the current value of the LongInstrument
78 */
79 public long longValue() {
80 return lb.get(0);
81 }
82}