1. /*
  2. * @(#)file SnmpUnsignedInt.java
  3. * @(#)author Sun Microsystems, Inc.
  4. * @(#)version 4.9
  5. * @(#)date 04/09/15
  6. *
  7. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  8. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  9. *
  10. */
  11. package com.sun.jmx.snmp;
  12. /**
  13. * Is the base for all SNMP syntaxes based on unsigned integers.
  14. *
  15. * <p><b>This API is a Sun Microsystems internal API and is subject
  16. * to change without notice.</b></p>
  17. * @version 4.9 12/19/03
  18. * @author Sun Microsystems, Inc
  19. */
  20. public abstract class SnmpUnsignedInt extends SnmpInt {
  21. /**
  22. * The largest value of the type <code>unsigned int</code> (2^32 - 1).
  23. */
  24. public static final long MAX_VALUE = 0x0ffffffffL;
  25. // CONSTRUCTORS
  26. //-------------
  27. /**
  28. * Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified integer value.
  29. * @param v The initialization value.
  30. * @exception IllegalArgumentException The specified value is negative
  31. * or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
  32. */
  33. public SnmpUnsignedInt(int v) throws IllegalArgumentException {
  34. super(v);
  35. }
  36. /**
  37. * Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified <CODE>Integer</CODE> value.
  38. * @param v The initialization value.
  39. * @exception IllegalArgumentException The specified value is negative
  40. * or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
  41. */
  42. public SnmpUnsignedInt(Integer v) throws IllegalArgumentException {
  43. super(v);
  44. }
  45. /**
  46. * Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified long 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(long v) throws IllegalArgumentException {
  52. super(v);
  53. }
  54. /**
  55. * Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified <CODE>Long</CODE> value.
  56. * @param v The initialization value.
  57. * @exception IllegalArgumentException The specified value is negative
  58. * or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
  59. */
  60. public SnmpUnsignedInt(Long v) throws IllegalArgumentException {
  61. super(v);
  62. }
  63. // PUBLIC METHODS
  64. //---------------
  65. /**
  66. * Returns a textual description of the type object.
  67. * @return ASN.1 textual description.
  68. */
  69. public String getTypeName() {
  70. return name ;
  71. }
  72. /**
  73. * This method has been defined to allow the sub-classes
  74. * of SnmpInt to perform their own control at intialization time.
  75. */
  76. boolean isInitValueValid(int v) {
  77. if ((v < 0) || (v > SnmpUnsignedInt.MAX_VALUE)) {
  78. return false;
  79. }
  80. return true;
  81. }
  82. /**
  83. * This method has been defined to allow the sub-classes
  84. * of SnmpInt to perform their own control at intialization time.
  85. */
  86. boolean isInitValueValid(long v) {
  87. if ((v < 0) || (v > SnmpUnsignedInt.MAX_VALUE)) {
  88. return false;
  89. }
  90. return true;
  91. }
  92. // VARIABLES
  93. //----------
  94. /**
  95. * Name of the type.
  96. */
  97. final static String name = "Unsigned32" ;
  98. }