Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.management/share/classes/sun/management/counter/AbstractCounter.java
41155 views
1
/*
2
* Copyright (c) 2003, 2004, 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.management.counter;
27
28
import java.io.IOException;
29
import java.io.ObjectOutputStream;
30
import java.io.ObjectInputStream;
31
32
/**
33
*/
34
public abstract class AbstractCounter implements Counter {
35
36
String name;
37
Units units;
38
Variability variability;
39
int flags;
40
int vectorLength;
41
42
// Flags defined in hotspot implementation
43
class Flags {
44
static final int SUPPORTED = 0x1;
45
}
46
47
protected AbstractCounter(String name, Units units,
48
Variability variability, int flags,
49
int vectorLength) {
50
this.name = name;
51
this.units = units;
52
this.variability = variability;
53
this.flags = flags;
54
this.vectorLength = vectorLength;
55
}
56
57
protected AbstractCounter(String name, Units units,
58
Variability variability, int flags) {
59
this(name, units, variability, flags, 0);
60
}
61
62
/**
63
* Returns the name of the Performance Counter
64
*/
65
public String getName() {
66
return name;
67
}
68
69
/**
70
* Returns the Units for this Performance Counter
71
*/
72
public Units getUnits() {
73
return units;
74
}
75
76
/**
77
* Returns the Variability for this performance Object
78
*/
79
public Variability getVariability() {
80
return variability;
81
}
82
83
/**
84
* Return true if this performance counter is a vector
85
*/
86
public boolean isVector() {
87
return vectorLength > 0;
88
}
89
90
/**
91
* return the length of the vector
92
*/
93
public int getVectorLength() {
94
return vectorLength;
95
}
96
97
public boolean isInternal() {
98
return (flags & Flags.SUPPORTED) == 0;
99
}
100
101
/**
102
* return the flags associated with the counter.
103
*/
104
public int getFlags() {
105
return flags;
106
}
107
108
public abstract Object getValue();
109
110
public String toString() {
111
String result = getName() + ": " + getValue() + " " + getUnits();
112
if (isInternal()) {
113
return result + " [INTERNAL]";
114
} else {
115
return result;
116
}
117
}
118
119
private static final long serialVersionUID = 6992337162326171013L;
120
121
}
122
123