1 11 12 13 package com.sun.jmx.snmp; 14 15 16 17 25 26 public class SnmpCounter64 extends SnmpValue { 27 28 36 public SnmpCounter64(long v) throws IllegalArgumentException { 37 38 if ((v < 0) || (v > Long.MAX_VALUE)) { 44 throw new IllegalArgumentException () ; 45 } 46 value = v ; 47 } 48 49 55 public SnmpCounter64(Long v) throws IllegalArgumentException { 56 this(v.longValue()) ; 57 } 58 59 65 public long longValue() { 66 return value ; 67 } 68 69 73 public Long toLong() { 74 return new Long (value) ; 75 } 76 77 81 public int intValue() { 82 return (int)value ; 83 } 84 85 89 public Integer toInteger() { 90 return new Integer ((int)value) ; 91 } 92 93 97 public String toString() { 98 return String.valueOf(value) ; 99 } 100 101 105 public SnmpOid toOid() { 106 return new SnmpOid(value) ; 107 } 108 109 118 public static SnmpOid toOid(long[] index, int start) throws SnmpStatusException { 119 try { 120 return new SnmpOid(index[start]) ; 121 } 122 catch(IndexOutOfBoundsException e) { 123 throw new SnmpStatusException(SnmpStatusException.noSuchName) ; 124 } 125 } 126 127 136 public static int nextOid(long[] index, int start) throws SnmpStatusException { 137 if (start >= index.length) { 138 throw new SnmpStatusException(SnmpStatusException.noSuchName) ; 139 } 140 else { 141 return start + 1 ; 142 } 143 } 144 145 150 public static void appendToOid(SnmpOid source, SnmpOid dest) { 151 if (source.getLength() != 1) { 152 throw new IllegalArgumentException () ; 153 } 154 dest.append(source) ; 155 } 156 157 162 final synchronized public SnmpValue duplicate() { 163 return (SnmpValue)clone() ; 164 } 165 166 170 final synchronized public Object clone() { 171 SnmpCounter64 newclone = null ; 172 try { 173 newclone = (SnmpCounter64) super.clone() ; 174 newclone.value = value ; 175 } catch (CloneNotSupportedException e) { 176 throw new InternalError () ; } 178 return newclone ; 179 } 180 181 185 final public String getTypeName() { 186 return name ; 187 } 188 189 194 final static String name = "Counter64" ; 195 196 200 private long value = 0 ; 201 } 202 | Popular Tags |