com.sun.jaw.snmp.common
Class SnmpInt

java.lang.Object
  |
  +--com.sun.jaw.snmp.common.SnmpValue
        |
        +--com.sun.jaw.snmp.common.SnmpInt
Direct Known Subclasses:
SnmpUnsignedInt

public class SnmpInt
extends SnmpValue

The SnmpInt class represents an SNMP integer.

See Also:
Serialized Form

Field Summary
protected  long value
          This is where the value is stored.
 
Constructor Summary
SnmpInt(boolean v)
          Constructs a new SnmpInt from the specified boolean value.
SnmpInt(Enumerated v)
          Constructs a new SnmpInt from the specified Enumerated value.
SnmpInt(int v)
          Constructs a new SnmpInt from the specified integer value.
SnmpInt(java.lang.Integer v)
          Constructs a new SnmpInt from the specified Integer value.
SnmpInt(long v)
          Constructs a new SnmpInt from the specified long value.
SnmpInt(java.lang.Long v)
          Constructs a new SnmpInt from the specified Long value.
 
Method Summary
static void appendToOid(SnmpOid source, SnmpOid dest)
          Appends an SnmpOid representing an SnmpInt to another oid.
 java.lang.Object clone()
          Clones the SnmpInt object, making a copy of its data.
 SnmpValue duplicate()
          Performs a clone action.
 java.lang.String getTypeName()
          Returns a textual description of the type object.
 int intValue()
          Converts the integer value to its integer form.
 long longValue()
          Returns the long value of this SnmpInt.
static int nextOid(long[] index, int start)
          Scans an index oid, skips the integer value and returns the position of the next value.
 java.lang.Integer toInteger()
          Converts the integer value to its Integer form.
 java.lang.Long toLong()
          Converts the integer value to its Long form.
 SnmpOid toOid()
          Converts the integer value to its SnmpOid form.
static SnmpOid toOid(long[] index, int start)
          Extracts the integer from an index oid and returns its value converted as an SnmpOid.
 java.lang.String toString()
          Converts the integer value to its String form.
 
Methods inherited from class com.sun.jaw.snmp.common.SnmpValue
toAsn1String
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected long value
This is where the value is stored. This long is signed.
Constructor Detail

SnmpInt

public SnmpInt(int v)
        throws java.lang.IllegalArgumentException
Constructs a new SnmpInt from the specified integer value.
Parameters:
v - The initialization value.
Throws:
java.lang.IllegalArgumentException - The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.

SnmpInt

public SnmpInt(java.lang.Integer v)
        throws java.lang.IllegalArgumentException
Constructs a new SnmpInt from the specified Integer value.
Parameters:
v - The initialization value.
Throws:
java.lang.IllegalArgumentException - The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.

SnmpInt

public SnmpInt(long v)
        throws java.lang.IllegalArgumentException
Constructs a new SnmpInt from the specified long value.
Parameters:
v - The initialization value.
Throws:
java.lang.IllegalArgumentException - The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.

SnmpInt

public SnmpInt(java.lang.Long v)
        throws java.lang.IllegalArgumentException
Constructs a new SnmpInt from the specified Long value.
Parameters:
v - The initialization value.
Throws:
java.lang.IllegalArgumentException - The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.

SnmpInt

public SnmpInt(Enumerated v)
        throws java.lang.IllegalArgumentException
Constructs a new SnmpInt from the specified Enumerated value.
Parameters:
v - The initialization value.
Throws:
java.lang.IllegalArgumentException - The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.
See Also:
Enumerated

SnmpInt

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) }
 
Parameters:
v - The initialization value.
Method Detail

longValue

public long longValue()
Returns the long value of this SnmpInt.
Returns:
The value.

toLong

public java.lang.Long toLong()
Converts the integer value to its Long form.
Returns:
The Long representation of the value.

intValue

public int intValue()
Converts the integer value to its integer form.
Returns:
The integer representation of the value.

toInteger

public java.lang.Integer toInteger()
Converts the integer value to its Integer form.
Returns:
The Integer representation of the value.

toString

public java.lang.String toString()
Converts the integer value to its String form.
Returns:
The String representation of the value.
Overrides:
toString in class java.lang.Object

toOid

public SnmpOid toOid()
Converts the integer value to its SnmpOid form.
Returns:
The oid representation of the value.
Overrides:
toOid in class SnmpValue

toOid

public static SnmpOid toOid(long[] index,
                            int start)
                     throws SnmpStatusException
Extracts the integer from an index oid and returns its value converted as an SnmpOid.
Parameters:
index - The index array.
start - The position in the index array.
Returns:
The oid representing the integer value.
Throws:
SnmpStatusException - There is no integer value available at start position.

nextOid

public static int nextOid(long[] index,
                          int start)
                   throws SnmpStatusException
Scans an index oid, skips the integer value and returns the position of the next value.
Parameters:
index - The index array.
start - The position in the index array.
Returns:
The position of the next value.
Throws:
SnmpStatusException - There is no integer value available at start position.

appendToOid

public static void appendToOid(SnmpOid source,
                               SnmpOid dest)
Appends an SnmpOid representing an SnmpInt to another oid.
Parameters:
source - An oid representing an SnmpInt value.
dest - Where source should be appened.

duplicate

public final SnmpValue duplicate()
Performs a clone action. This provides a workaround for the SnmpValue interface.
Returns:
The SnmpValue clone.
Overrides:
duplicate in class SnmpValue

clone

public final java.lang.Object clone()
Clones the SnmpInt object, making a copy of its data.
Returns:
The Object clone.
Overrides:
clone in class java.lang.Object

getTypeName

public java.lang.String getTypeName()
Returns a textual description of the type object.
Returns:
ASN.1 textual description.
Overrides:
getTypeName in class SnmpValue