jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/SnmpUnsignedInt.java
changeset 27188 a1aa62221649
parent 27187 020b64fc02df
child 27189 b90845965ee9
equal deleted inserted replaced
27187:020b64fc02df 27188:a1aa62221649
     1 /*
       
     2  * Copyright (c) 1997, 2014, 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 
       
    27 package com.sun.jmx.snmp;
       
    28 
       
    29 
       
    30 
       
    31 /**
       
    32  * Is the base for all SNMP syntaxes based on unsigned integers.
       
    33  *
       
    34  * <p><b>This API is a Sun Microsystems internal API  and is subject
       
    35  * to change without notice.</b></p>
       
    36  */
       
    37 @SuppressWarnings("serial") // JDK implementation class
       
    38 public abstract class SnmpUnsignedInt extends SnmpInt {
       
    39 
       
    40     /**
       
    41      * The largest value of the type <code>unsigned int</code> (2^32 - 1).
       
    42      */
       
    43     public static final long   MAX_VALUE = 0x0ffffffffL;
       
    44 
       
    45     // CONSTRUCTORS
       
    46     //-------------
       
    47     /**
       
    48      * Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified integer value.
       
    49      * @param v The initialization value.
       
    50      * @exception IllegalArgumentException The specified value is negative
       
    51      * or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
       
    52      */
       
    53     public SnmpUnsignedInt(int v) throws IllegalArgumentException {
       
    54         super(v);
       
    55     }
       
    56 
       
    57     /**
       
    58      * Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified <CODE>Integer</CODE> value.
       
    59      * @param v The initialization value.
       
    60      * @exception IllegalArgumentException The specified value is negative
       
    61      * or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
       
    62      */
       
    63     public SnmpUnsignedInt(Integer v) throws IllegalArgumentException {
       
    64         super(v);
       
    65     }
       
    66 
       
    67     /**
       
    68      * Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified long value.
       
    69      * @param v The initialization value.
       
    70      * @exception IllegalArgumentException The specified value is negative
       
    71      * or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
       
    72      */
       
    73     public SnmpUnsignedInt(long v) throws IllegalArgumentException {
       
    74         super(v);
       
    75     }
       
    76 
       
    77     /**
       
    78      * Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified <CODE>Long</CODE> value.
       
    79      * @param v The initialization value.
       
    80      * @exception IllegalArgumentException The specified value is negative
       
    81      * or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
       
    82      */
       
    83     public SnmpUnsignedInt(Long v) throws IllegalArgumentException {
       
    84         super(v);
       
    85     }
       
    86 
       
    87     // PUBLIC METHODS
       
    88     //---------------
       
    89     /**
       
    90      * Returns a textual description of the type object.
       
    91      * @return ASN.1 textual description.
       
    92      */
       
    93     public String getTypeName() {
       
    94         return name ;
       
    95     }
       
    96 
       
    97     /**
       
    98      * This method has been defined to allow the sub-classes
       
    99      * of SnmpInt to perform their own control at intialization time.
       
   100      */
       
   101     boolean isInitValueValid(int v) {
       
   102         if ((v < 0) || (v > SnmpUnsignedInt.MAX_VALUE)) {
       
   103             return false;
       
   104         }
       
   105         return true;
       
   106     }
       
   107 
       
   108     /**
       
   109      * This method has been defined to allow the sub-classes
       
   110      * of SnmpInt to perform their own control at intialization time.
       
   111      */
       
   112     boolean isInitValueValid(long v) {
       
   113         if ((v < 0) || (v > SnmpUnsignedInt.MAX_VALUE)) {
       
   114             return false;
       
   115         }
       
   116         return true;
       
   117     }
       
   118 
       
   119     // VARIABLES
       
   120     //----------
       
   121     /**
       
   122      * Name of the type.
       
   123      */
       
   124     final static String name = "Unsigned32" ;
       
   125 }