Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/jmx/snmp/SnmpUnsignedInt.java
38924 views
/*1* Copyright (c) 1997, 2007, 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*/242526package com.sun.jmx.snmp;27282930/**31* Is the base for all SNMP syntaxes based on unsigned integers.32*33* <p><b>This API is a Sun Microsystems internal API and is subject34* to change without notice.</b></p>35*/3637public abstract class SnmpUnsignedInt extends SnmpInt {3839/**40* The largest value of the type <code>unsigned int</code> (2^32 - 1).41*/42public static final long MAX_VALUE = 0x0ffffffffL;4344// CONSTRUCTORS45//-------------46/**47* Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified integer value.48* @param v The initialization value.49* @exception IllegalArgumentException The specified value is negative50* or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.51*/52public SnmpUnsignedInt(int v) throws IllegalArgumentException {53super(v);54}5556/**57* Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified <CODE>Integer</CODE> value.58* @param v The initialization value.59* @exception IllegalArgumentException The specified value is negative60* or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.61*/62public SnmpUnsignedInt(Integer v) throws IllegalArgumentException {63super(v);64}6566/**67* Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified long value.68* @param v The initialization value.69* @exception IllegalArgumentException The specified value is negative70* or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.71*/72public SnmpUnsignedInt(long v) throws IllegalArgumentException {73super(v);74}7576/**77* Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified <CODE>Long</CODE> value.78* @param v The initialization value.79* @exception IllegalArgumentException The specified value is negative80* or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.81*/82public SnmpUnsignedInt(Long v) throws IllegalArgumentException {83super(v);84}8586// PUBLIC METHODS87//---------------88/**89* Returns a textual description of the type object.90* @return ASN.1 textual description.91*/92public String getTypeName() {93return name ;94}9596/**97* This method has been defined to allow the sub-classes98* of SnmpInt to perform their own control at intialization time.99*/100boolean isInitValueValid(int v) {101if ((v < 0) || (v > SnmpUnsignedInt.MAX_VALUE)) {102return false;103}104return true;105}106107/**108* This method has been defined to allow the sub-classes109* of SnmpInt to perform their own control at intialization time.110*/111boolean isInitValueValid(long v) {112if ((v < 0) || (v > SnmpUnsignedInt.MAX_VALUE)) {113return false;114}115return true;116}117118// VARIABLES119//----------120/**121* Name of the type.122*/123final static String name = "Unsigned32" ;124}125126127