com.sun.management.snmp
Class SnmpInt

java.lang.Object
  extended by com.sun.management.snmp.SnmpValue
      extended by com.sun.management.snmp.SnmpInt
All Implemented Interfaces:
SnmpDataTypeEnums, Serializable, Cloneable
Direct Known Subclasses:
SnmpUnsignedInt

public class SnmpInt
extends SnmpValue

Represents an SNMP integer.

Since:
Java DMK 5.1
See Also:
Serialized Form

Field Summary
protected  long value
          This is where the value is stored.
 
Fields inherited from interface com.sun.management.snmp.SnmpDataTypeEnums
ApplFlag, BitStringTag, BooleanTag, Counter64Tag, CounterTag, CtxtFlag, errEndOfMibViewTag, errNoSuchInstanceTag, errNoSuchObjectTag, GaugeTag, IntegerTag, IpAddressTag, NsapTag, NullTag, ObjectIdentiferTag, ObjectIdentifierTag, OctetStringTag, OpaqueTag, SequenceTag, TableTag, TimeticksTag, UintegerTag, UnknownSyntaxTag
 
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(Integer v)
          Constructs a new SnmpInt from the specified Integer value.
SnmpInt(long v)
          Constructs a new SnmpInt from the specified long value.
SnmpInt(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.
 Object clone()
          Clones the SnmpInt object, making a copy of its data.
 SnmpValue duplicate()
          Performs a clone action.
 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.
 Integer toInteger()
          Converts the integer value to its Integer form.
 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.
 String toString()
          Converts the integer value to its String form.
 
Methods inherited from class com.sun.management.snmp.SnmpValue
isEndOfMibViewValue, isNoSuchInstanceValue, isNoSuchObjectValue, 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 IllegalArgumentException
Constructs a new SnmpInt from the specified integer value.

Parameters:
v - The initialization value.
Throws:
IllegalArgumentException - The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.

SnmpInt

public SnmpInt(Integer v)
        throws IllegalArgumentException
Constructs a new SnmpInt from the specified Integer value.

Parameters:
v - The initialization value.
Throws:
IllegalArgumentException - The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.

SnmpInt

public SnmpInt(long v)
        throws IllegalArgumentException
Constructs a new SnmpInt from the specified long value.

Parameters:
v - The initialization value.
Throws:
IllegalArgumentException - The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.

SnmpInt

public SnmpInt(Long v)
        throws IllegalArgumentException
Constructs a new SnmpInt from the specified Long value.

Parameters:
v - The initialization value.
Throws:
IllegalArgumentException - The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.

SnmpInt

public SnmpInt(Enumerated v)
        throws IllegalArgumentException
Constructs a new SnmpInt from the specified Enumerated value.

Parameters:
v - The initialization value.
Throws:
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 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 Integer toInteger()
Converts the integer value to its Integer form.

Returns:
The Integer representation of the value.

toString

public String toString()
Converts the integer value to its String form.

Overrides:
toString in class Object
Returns:
The String representation of the value.

toOid

public SnmpOid toOid()
Converts the integer value to its SnmpOid form.

Specified by:
toOid in class SnmpValue
Returns:
The OID representation of the value.

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 the 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 the 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 appended.

duplicate

public final SnmpValue duplicate()
Performs a clone action. This provides a workaround for the SnmpValue interface.

Specified by:
duplicate in class SnmpValue
Returns:
The SnmpValue clone.

clone

public final Object clone()
Clones the SnmpInt object, making a copy of its data.

Overrides:
clone in class Object
Returns:
The object clone.

getTypeName

public String getTypeName()
Returns a textual description of the type object.

Specified by:
getTypeName in class SnmpValue
Returns:
ASN.1 textual description.

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.