1 /* |
|
2 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package sun.jvmstat.perfdata.monitor; |
|
27 |
|
28 import sun.jvmstat.monitor.*; |
|
29 import java.nio.LongBuffer; |
|
30 |
|
31 /** |
|
32 * Class for monitoring a PerfData Long instrument. |
|
33 * |
|
34 * @author Brian Doherty |
|
35 * @since 1.5 |
|
36 */ |
|
37 public class PerfLongMonitor extends AbstractMonitor implements LongMonitor { |
|
38 |
|
39 /** |
|
40 * The buffer containing the data for the long instrument. |
|
41 */ |
|
42 LongBuffer lb; |
|
43 |
|
44 /** |
|
45 * Constructor to create a LongMonitor object for the long instrument |
|
46 * represented by the data in the given buffer. |
|
47 * |
|
48 * @param name the name of the long instrument |
|
49 * @param u the units of measure attribute |
|
50 * @param v the variability attribute |
|
51 * @param supported support level indicator |
|
52 * @param lb the buffer containing the long instrument data. |
|
53 */ |
|
54 public PerfLongMonitor(String name, Units u, Variability v, |
|
55 boolean supported, LongBuffer lb) { |
|
56 super(name, u, v, supported); |
|
57 this.lb = lb; |
|
58 } |
|
59 |
|
60 /** |
|
61 * {@inheritDoc} |
|
62 * The object returned contains a Long object containing the |
|
63 * current value of the LongInstrument. |
|
64 * |
|
65 * @return Object - the current value of the LongInstrument. The |
|
66 * return type is guaranteed to be of type Long. |
|
67 */ |
|
68 public Object getValue() { |
|
69 return Long.valueOf(lb.get(0)); |
|
70 } |
|
71 |
|
72 /** |
|
73 * Return the current value of the LongInstrument as an long. |
|
74 * |
|
75 * @return long - the current value of the LongInstrument |
|
76 */ |
|
77 public long longValue() { |
|
78 return lb.get(0); |
|
79 } |
|
80 } |
|