1 29 30 31 package snmp; 32 33 import java.math.*; 34 35 36 37 41 public class SNMPUInteger32 extends SNMPInteger 42 { 43 private static BigInteger maxValue = new BigInteger("4294967295"); 45 46 47 50 51 public SNMPUInteger32() 52 { 53 this(0); } 55 56 57 58 59 62 63 public SNMPUInteger32(long newValue) 64 { 65 tag = SNMPBERCodec.SNMPUINTEGER32; 66 67 value = new BigInteger(new Long (newValue).toString()); 68 69 value = value.mod(maxValue); 71 } 72 73 74 80 81 protected SNMPUInteger32(byte[] enc) 82 throws SNMPBadValueException 83 { 84 tag = SNMPBERCodec.SNMPUINTEGER32; 85 86 extractValueFromBEREncoding(enc); 87 88 value = value.mod(maxValue); 90 } 91 92 93 94 95 96 102 103 public void setValue(Object newValue) 104 throws SNMPBadValueException 105 { 106 if (newValue instanceof BigInteger) 107 { 108 value = (BigInteger)newValue; 109 value = value.mod(maxValue); } 111 else if (newValue instanceof Integer ) 112 { 113 value = value = new BigInteger(newValue.toString()); 114 value = value.mod(maxValue); } 116 else if (newValue instanceof String ) 117 { 118 value = value = new BigInteger((String )newValue); 119 value = value.mod(maxValue); } 121 else 122 throw new SNMPBadValueException(" Unsigned Integer: bad object supplied to set value "); 123 } 124 125 126 127 128 } | Popular Tags |