KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jmx > snmp > SnmpUnsignedInt


1 /*
2  * @(#)file SnmpUnsignedInt.java
3  * @(#)author Sun Microsystems, Inc.
4  * @(#)version 4.9
5  * @(#)date 08/02/09
6  *
7  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
8  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
9  *
10  */

11
12
13 package com.sun.jmx.snmp;
14
15
16
17 /**
18  * Is the base for all SNMP syntaxes based on unsigned integers.
19  *
20  * <p><b>This API is a Sun Microsystems internal API and is subject
21  * to change without notice.</b></p>
22  * @version 4.9 12/19/03
23  * @author Sun Microsystems, Inc
24  */

25
26 public abstract class SnmpUnsignedInt extends SnmpInt {
27
28     /**
29      * The largest value of the type <code>unsigned int</code> (2^32 - 1).
30      */

31     public static final long MAX_VALUE = 0x0ffffffffL;
32
33     // CONSTRUCTORS
34
//-------------
35
/**
36      * Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified integer value.
37      * @param v The initialization value.
38      * @exception IllegalArgumentException The specified value is negative
39      * or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
40      */

41     public SnmpUnsignedInt(int v) throws IllegalArgumentException JavaDoc {
42         super(v);
43     }
44
45     /**
46      * Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified <CODE>Integer</CODE> value.
47      * @param v The initialization value.
48      * @exception IllegalArgumentException The specified value is negative
49      * or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
50      */

51     public SnmpUnsignedInt(Integer JavaDoc v) throws IllegalArgumentException JavaDoc {
52         super(v);
53     }
54
55     /**
56      * Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified long value.
57      * @param v The initialization value.
58      * @exception IllegalArgumentException The specified value is negative
59      * or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
60      */

61     public SnmpUnsignedInt(long v) throws IllegalArgumentException JavaDoc {
62         super(v);
63     }
64   
65     /**
66      * Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified <CODE>Long</CODE> value.
67      * @param v The initialization value.
68      * @exception IllegalArgumentException The specified value is negative
69      * or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
70      */

71     public SnmpUnsignedInt(Long JavaDoc v) throws IllegalArgumentException JavaDoc {
72         super(v);
73     }
74
75     // PUBLIC METHODS
76
//---------------
77
/**
78      * Returns a textual description of the type object.
79      * @return ASN.1 textual description.
80      */

81     public String JavaDoc getTypeName() {
82         return name ;
83     }
84   
85     /**
86      * This method has been defined to allow the sub-classes
87      * of SnmpInt to perform their own control at intialization time.
88      */

89     boolean isInitValueValid(int v) {
90         if ((v < 0) || (v > SnmpUnsignedInt.MAX_VALUE)) {
91             return false;
92         }
93         return true;
94     }
95
96     /**
97      * This method has been defined to allow the sub-classes
98      * of SnmpInt to perform their own control at intialization time.
99      */

100     boolean isInitValueValid(long v) {
101         if ((v < 0) || (v > SnmpUnsignedInt.MAX_VALUE)) {
102             return false;
103         }
104         return true;
105     }
106
107     // VARIABLES
108
//----------
109
/**
110      * Name of the type.
111      */

112     final static String JavaDoc name = "Unsigned32" ;
113 }
114
Popular Tags