Path: blob/master/src/java.management/share/classes/sun/management/counter/Variability.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;2627/**28* Provides a typesafe enumeration for the Variability attribute for29* instrumentation objects.30*31* @author Brian Doherty32*/33public class Variability implements java.io.Serializable {3435/* The enumeration values for this typesafe enumeration must be36* kept in synchronization with the Variability enum in the perfData.hpp file37* in the HotSpot source base.38*/3940private static final int NATTRIBUTES = 4;41private static Variability[] map = new Variability[NATTRIBUTES];4243private String name;44private int value;4546/**47* An invalid Variablity value.48*/49public static final Variability INVALID = new Variability("Invalid",0);5051/**52* Variability attribute representing Constant counters.53*/54public static final Variability CONSTANT = new Variability("Constant",1);5556/**57* Variability attribute representing a Monotonically changing counters.58*/59public static final Variability MONOTONIC = new Variability("Monotonic",2);6061/**62* Variability attribute representing Variable counters.63*/64public static final Variability VARIABLE = new Variability("Variable",3);6566/**67* Returns a string describing this Variability attribute.68*69* @return String - a descriptive string for this enum.70*/71public String toString() {72return name;73}7475/**76* Returns the integer representation of this Variability attribute.77*78* @return int - an integer representation of this Variability attribute.79*/80public int intValue() {81return value;82}8384/**85* Maps an integer value its corresponding Variability attribute.86* If the integer value does not have a corresponding Variability enum87* value, the {@link Variability#INVALID} is returned88*89* @param value an integer representation of a Variability attribute90* @return Variability - The Variability object for the given91* <code>value</code> or {@link Variability#INVALID}92* if out of range.93*/94public static Variability toVariability(int value) {9596if (value < 0 || value >= map.length || map[value] == null) {97return INVALID;98}99100return map[value];101}102103private Variability(String name, int value) {104this.name = name;105this.value = value;106map[value]=this;107}108109private static final long serialVersionUID = 6992337162326171013L;110}111112113