FileDocCategorySizeDatePackage
SnmpCounter64.javaAPI DocJava SE 5 API5650Fri Aug 26 14:55:02 BST 2005com.sun.jmx.snmp

SnmpCounter64

public class SnmpCounter64 extends SnmpValue
Represents an SNMP 64bits counter.

This API is a Sun Microsystems internal API and is subject to change without notice.

version
4.8 12/19/03
author
Sun Microsystems, Inc

Fields Summary
static final String
name
Name of the type.
private long
value
This is where the value is stored. This long is positive.
Constructors Summary
public SnmpCounter64(long v)
Constructs a new SnmpCounter64 from the specified long value.

param
v The initialization value.
exception
IllegalArgumentException The specified value is negative or larger than Long.MAX_VALUE.


	// NOTE:
	// The max value for a counter64 variable is 2^64 - 1.
	// The max value for a Long is 2^63 - 1.
	// All the allowed values for a conuter64 variable cannot be covered !!!
	//
	if ((v < 0) || (v > Long.MAX_VALUE)) {
	    throw new IllegalArgumentException() ;
	}
	value = v ;
    
public SnmpCounter64(Long v)
Constructs a new SnmpCounter64 from the specified Long value.

param
v The initialization value.
exception
IllegalArgumentException The specified value is negative or larger than Long.MAX_VALUE.

	this(v.longValue()) ;
    
Methods Summary
public static voidappendToOid(SnmpOid source, SnmpOid dest)
Appends an SnmpOid representing an SnmpCounter64 to another OID.

param
source An OID representing an SnmpCounter64 value.
param
dest Where source should be appended.

	if (source.getLength() != 1) {
	    throw new IllegalArgumentException() ;
	}
	dest.append(source) ;
    
public final synchronized java.lang.Objectclone()
Clones the SnmpCounter64 object, making a copy of its data.

return
The object clone.

        SnmpCounter64  newclone = null ;
        try {
	    newclone = (SnmpCounter64) super.clone() ;
	    newclone.value = value ;
        } catch (CloneNotSupportedException e) {
	    throw new InternalError() ; // vm bug.
        }
        return newclone ;
    
public final synchronized SnmpValueduplicate()
Performs a clone action. This provides a workaround for the SnmpValue interface.

return
The SnmpValue clone.

	return (SnmpValue)clone() ;
    
public final java.lang.StringgetTypeName()
Returns a textual description of the type object.

return
ASN.1 textual description.

        return name ;
    
public intintValue()
Converts the counter value to its integer form.

return
The integer representation of the value.

	return (int)value ;
    
public longlongValue()
Returns the counter value of this SnmpCounter64.

return
The value.

	return value ;
    
public static intnextOid(long[] index, int start)
Scans an index OID, skips the counter value and returns the position of the next value.

param
index The index array.
param
start The position in the index array.
return
The position of the next value.
exception
SnmpStatusException There is no counter value available at the start position.

	if (start >= index.length) {
	    throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
	}
	else {
	    return start + 1 ;
	}
    
public java.lang.IntegertoInteger()
Converts the counter value to its Integer form.

return
The Integer representation of the value.

	return new Integer((int)value) ;
    
public java.lang.LongtoLong()
Converts the counter value to its Long form.

return
The Long representation of the value.

	return new Long(value) ;
    
public SnmpOidtoOid()
Converts the counter value to its SnmpOid form.

return
The OID representation of the value.

	return new SnmpOid(value) ;
    
public static SnmpOidtoOid(long[] index, int start)
Extracts the counter from an index OID and returns its value converted as an SnmpOid.

param
index The index array.
param
start The position in the index array.
return
The OID representing the counter value.
exception
SnmpStatusException There is no counter value available at the start position.

	try {
	    return new SnmpOid(index[start]) ;
	}
	catch(IndexOutOfBoundsException e) {
	    throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
	}
    
public java.lang.StringtoString()
Converts the counter value to its String form.

return
The String representation of the value.

	return String.valueOf(value) ;