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

SnmpInt

public class SnmpInt extends SnmpValue
Represents an SNMP integer.

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

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

Fields Summary
static final String
name
Name of the type.
protected long
value
This is where the value is stored. This long is signed.
Constructors Summary
public SnmpInt(int v)
Constructs a new SnmpInt from the specified integer value.

param
v The initialization value.
exception
IllegalArgumentException The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.

        if ( isInitValueValid(v) == false ) {
            throw new IllegalArgumentException() ;
        }
        value = (long)v ;
    
public SnmpInt(Integer v)
Constructs a new SnmpInt from the specified Integer value.

param
v The initialization value.
exception
IllegalArgumentException The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.

        this(v.intValue()) ;
    
public SnmpInt(long v)
Constructs a new SnmpInt from the specified long value.

param
v The initialization value.
exception
IllegalArgumentException The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.

        if ( isInitValueValid(v) == false ) {
            throw new IllegalArgumentException() ;
        }
        value = v ;
    
public SnmpInt(Long v)
Constructs a new SnmpInt from the specified Long value.

param
v The initialization value.
exception
IllegalArgumentException The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.

        this(v.longValue()) ;
    
public SnmpInt(com.sun.jmx.snmp.Enumerated v)
Constructs a new SnmpInt from the specified Enumerated value.

param
v The initialization value.
exception
IllegalArgumentException The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.
see
Enumerated

        this(v.intValue()) ;
    
public SnmpInt(boolean v)
Constructs a new SnmpInt from the specified boolean value. This constructor applies rfc1903 rule:

TruthValue ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"Represents a boolean value."
SYNTAX INTEGER { true(1), false(2) }

param
v The initialization value.

        value = v ? 1 : 2 ;
    
Methods Summary
public static voidappendToOid(SnmpOid source, SnmpOid dest)
Appends an SnmpOid representing an SnmpInt to another OID.

param
source An OID representing an SnmpInt 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 SnmpInt object, making a copy of its data.

return
The object clone.

        SnmpInt  newclone = null ;
        try {
            newclone = (SnmpInt) 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 java.lang.StringgetTypeName()
Returns a textual description of the type object.

return
ASN.1 textual description.

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

return
The integer representation of the value.

        return (int) value ;
    
booleanisInitValueValid(int v)
This method has been defined to allow the sub-classes of SnmpInt to perform their own control at intialization time.

        if ((v < Integer.MIN_VALUE) || (v > Integer.MAX_VALUE)) {
            return false;
        }
        return true;
    
booleanisInitValueValid(long v)
This method has been defined to allow the sub-classes of SnmpInt to perform their own control at intialization time.

        if ((v < Integer.MIN_VALUE) || (v > Integer.MAX_VALUE)) {
            return false;
        }
        return true;
    
public longlongValue()
Returns the long value of this SnmpInt.

return
The value.

        return value ;
    
public static intnextOid(long[] index, int start)
Scans an index OID, skips the integer 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 integer 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 integer value to its Integer form.

return
The Integer representation of the value.

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

return
The Long representation of the value.

        return new Long(value) ;
    
public SnmpOidtoOid()
Converts the integer 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 integer 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 integer value.
exception
SnmpStatusException There is no integer 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 integer value to its String form.

return
The String representation of the value.

        return String.valueOf(value) ;