Path: blob/master/src/java.management/share/classes/sun/management/counter/AbstractCounter.java
41155 views
/*1* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.management.counter;2627import java.io.IOException;28import java.io.ObjectOutputStream;29import java.io.ObjectInputStream;3031/**32*/33public abstract class AbstractCounter implements Counter {3435String name;36Units units;37Variability variability;38int flags;39int vectorLength;4041// Flags defined in hotspot implementation42class Flags {43static final int SUPPORTED = 0x1;44}4546protected AbstractCounter(String name, Units units,47Variability variability, int flags,48int vectorLength) {49this.name = name;50this.units = units;51this.variability = variability;52this.flags = flags;53this.vectorLength = vectorLength;54}5556protected AbstractCounter(String name, Units units,57Variability variability, int flags) {58this(name, units, variability, flags, 0);59}6061/**62* Returns the name of the Performance Counter63*/64public String getName() {65return name;66}6768/**69* Returns the Units for this Performance Counter70*/71public Units getUnits() {72return units;73}7475/**76* Returns the Variability for this performance Object77*/78public Variability getVariability() {79return variability;80}8182/**83* Return true if this performance counter is a vector84*/85public boolean isVector() {86return vectorLength > 0;87}8889/**90* return the length of the vector91*/92public int getVectorLength() {93return vectorLength;94}9596public boolean isInternal() {97return (flags & Flags.SUPPORTED) == 0;98}99100/**101* return the flags associated with the counter.102*/103public int getFlags() {104return flags;105}106107public abstract Object getValue();108109public String toString() {110String result = getName() + ": " + getValue() + " " + getUnits();111if (isInternal()) {112return result + " [INTERNAL]";113} else {114return result;115}116}117118private static final long serialVersionUID = 6992337162326171013L;119120}121122123