1 29 30 31 package snmp; 32 33 34 35 import java.math.*; 36 37 43 44 45 public class SNMPCounter64 extends SNMPInteger 46 { 47 private static BigInteger maxValue = new BigInteger("18446744070000000000"); 49 50 51 53 54 public SNMPCounter64() 55 { 56 this(0); } 58 59 60 public SNMPCounter64(long newValue) 61 { 62 tag = SNMPBERCodec.SNMPCOUNTER64; 63 64 value = new BigInteger(new Long (newValue).toString()); 65 66 value = value.mod(maxValue); 68 } 69 70 71 72 73 78 79 protected SNMPCounter64(byte[] enc) 80 throws SNMPBadValueException 81 { 82 tag = SNMPBERCodec.SNMPCOUNTER64; 83 84 extractValueFromBEREncoding(enc); 85 86 value = value.mod(maxValue); 88 } 89 90 91 92 97 98 99 public void setValue(Object newValue) 100 throws SNMPBadValueException 101 { 102 if (newValue instanceof BigInteger) 103 { 104 value = (BigInteger)newValue; 105 value = value.mod(maxValue); } 107 else if (newValue instanceof Integer ) 108 { 109 value = value = new BigInteger(newValue.toString()); 110 value = value.mod(maxValue); } 112 else if (newValue instanceof String ) 113 { 114 value = value = new BigInteger((String )newValue); 115 value = value.mod(maxValue); } 117 else 118 throw new SNMPBadValueException(" Counter64: bad object supplied to set value "); 119 } 120 121 122 123 124 } | Popular Tags |