jdk/src/share/classes/com/sun/jmx/snmp/SnmpInt.java
author prr
Tue, 15 Jul 2014 11:22:14 -0700
changeset 25522 10d789df41bb
parent 25186 63e1a2ec30f5
permissions -rw-r--r--
8049892: Replace uses of 'new Integer()' with appropriate alternative across core classes Reviewed-by: psandoz, prr Contributed-by: otaviopolianasantana@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 10419
diff changeset
     2
 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package com.sun.jmx.snmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import com.sun.jmx.snmp.Enumerated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * Represents an SNMP integer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <p><b>This API is a Sun Microsystems internal API  and is subject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * to change without notice.</b></p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public class SnmpInt extends SnmpValue {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    private static final long serialVersionUID = -7163624758070343373L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    // CONSTRUCTORS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    //-------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * Constructs a new <CODE>SnmpInt</CODE> from the specified integer value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * @param v The initialization value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * @exception IllegalArgumentException The specified value is smaller than <CODE>Integer.MIN_VALUE</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * or larger than <CODE>Integer.MAX_VALUE</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    public SnmpInt(int v) throws IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        if ( isInitValueValid(v) == false ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
            throw new IllegalArgumentException() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        value = (long)v ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * Constructs a new <CODE>SnmpInt</CODE> from the specified <CODE>Integer</CODE> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @param v The initialization value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @exception IllegalArgumentException The specified value is smaller than <CODE>Integer.MIN_VALUE</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * or larger than <CODE>Integer.MAX_VALUE</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public SnmpInt(Integer v) throws IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        this(v.intValue()) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Constructs a new <CODE>SnmpInt</CODE> from the specified long value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @param v The initialization value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @exception IllegalArgumentException The specified value is smaller than <CODE>Integer.MIN_VALUE</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * or larger than <CODE>Integer.MAX_VALUE</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public SnmpInt(long v) throws IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        if ( isInitValueValid(v) == false ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            throw new IllegalArgumentException() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        value = v ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * Constructs a new <CODE>SnmpInt</CODE> from the specified <CODE>Long</CODE> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @param v The initialization value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @exception IllegalArgumentException The specified value is smaller than <CODE>Integer.MIN_VALUE</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * or larger than <CODE>Integer.MAX_VALUE</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public SnmpInt(Long v) throws IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        this(v.longValue()) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Constructs a new <CODE>SnmpInt</CODE> from the specified <CODE>Enumerated</CODE> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @param v The initialization value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @exception IllegalArgumentException The specified value is smaller than <CODE>Integer.MIN_VALUE</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * or larger than <CODE>Integer.MAX_VALUE</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @see Enumerated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public SnmpInt(Enumerated v) throws IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        this(v.intValue()) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Constructs a new <CODE>SnmpInt</CODE> from the specified boolean value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * This constructor applies rfc1903 rule:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * <p><blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * TruthValue ::= TEXTUAL-CONVENTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *     STATUS       current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *     DESCRIPTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *             "Represents a boolean value."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *     SYNTAX       INTEGER { true(1), false(2) }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @param v The initialization value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public SnmpInt(boolean v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        value = v ? 1 : 2 ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    // PUBLIC METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    //---------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Returns the long value of this <CODE>SnmpInt</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @return The value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public long longValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        return value ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Converts the integer value to its <CODE>Long</CODE> form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @return The <CODE>Long</CODE> representation of the value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public Long toLong() {
25186
63e1a2ec30f5 8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
prappo
parents: 14342
diff changeset
   133
        return value;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Converts the integer value to its integer form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @return The integer representation of the value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public int intValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        return (int) value ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Converts the integer value to its <CODE>Integer</CODE> form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @return The <CODE>Integer</CODE> representation of the value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    public Integer toInteger() {
25522
10d789df41bb 8049892: Replace uses of 'new Integer()' with appropriate alternative across core classes
prr
parents: 25186
diff changeset
   149
        return (int)value;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * Converts the integer value to its <CODE>String</CODE> form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @return The <CODE>String</CODE> representation of the value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        return String.valueOf(value) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * Converts the integer value to its <CODE>SnmpOid</CODE> form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @return The OID representation of the value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public SnmpOid toOid() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        return new SnmpOid(value) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * Extracts the integer from an index OID and returns its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * value converted as an <CODE>SnmpOid</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @param index The index array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @param start The position in the index array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @return The OID representing the integer value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @exception SnmpStatusException There is no integer value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * available at the start position.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public static SnmpOid toOid(long[] index, int start) throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            return new SnmpOid(index[start]) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        catch(IndexOutOfBoundsException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Scans an index OID, skips the integer value and returns the position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * of the next value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @param index The index array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @param start The position in the index array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @return The position of the next value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @exception SnmpStatusException There is no integer value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * available at the start position.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public static int nextOid(long[] index, int start) throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        if (start >= index.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            return start + 1 ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Appends an <CODE>SnmpOid</CODE> representing an <CODE>SnmpInt</CODE> to another OID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @param source An OID representing an <CODE>SnmpInt</CODE> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @param dest Where source should be appended.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public static void appendToOid(SnmpOid source, SnmpOid dest) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        if (source.getLength() != 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            throw new IllegalArgumentException() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        dest.append(source) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * Performs a clone action. This provides a workaround for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * <CODE>SnmpValue</CODE> interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @return The <CODE>SnmpValue</CODE> clone.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    final synchronized public SnmpValue duplicate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        return (SnmpValue) clone() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * Clones the <CODE>SnmpInt</CODE> object, making a copy of its data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @return The object clone.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    final synchronized public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        SnmpInt  newclone = null ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            newclone = (SnmpInt) super.clone() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            newclone.value = value ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        } catch (CloneNotSupportedException e) {
10419
12c063b39232 7084245: Update usages of InternalError to use exception chaining
sherman
parents: 5506
diff changeset
   235
            throw new InternalError(e) ; // vm bug.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        return newclone ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * Returns a textual description of the type object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * @return ASN.1 textual description.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    public String getTypeName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        return name ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * This method has been defined to allow the sub-classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * of SnmpInt to perform their own control at intialization time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    boolean isInitValueValid(int v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        if ((v < Integer.MIN_VALUE) || (v > Integer.MAX_VALUE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * This method has been defined to allow the sub-classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * of SnmpInt to perform their own control at intialization time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    boolean isInitValueValid(long v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        if ((v < Integer.MIN_VALUE) || (v > Integer.MAX_VALUE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    // VARIABLES
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    //----------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * Name of the type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    final static String name = "Integer32" ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * This is where the value is stored. This long is signed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    protected long value = 0 ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
}