Package org.opennms.protocols.snmp
Class SnmpInt32
- java.lang.Object
-
- org.opennms.protocols.snmp.SnmpInt32
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,SnmpSyntax
public class SnmpInt32 extends java.lang.Object implements SnmpSyntax, java.lang.Cloneable, java.io.Serializable
This class defines the SNMP 32-bit signed integer used by the SNMP SMI. This class also serves as a base class for any additional SNMP SMI types that exits now or may be defined in the future.- Author:
- Brian Weaver
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static byte
ASNTYPE
The ASN.1 type as defined by the SNMP SMI specification.
-
Constructor Summary
Constructors Constructor Description SnmpInt32()
Default constructor.SnmpInt32(int value)
Constructs a SnmpInt32 object with the passed value.SnmpInt32(java.lang.Integer value)
Constructs a SnmpInt32 object with the specified value.SnmpInt32(java.lang.String value)
Simple class constructor that attempts to parse the passed string into a valid integer value.SnmpInt32(SnmpInt32 second)
Class copy constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Returns a duplicate of the current object.int
decodeASN(byte[] buf, int offset, AsnEncoder encoder)
Used to decode the integer value from the ASN.1 buffer.SnmpSyntax
duplicate()
Returns a duplicate of the current object.int
encodeASN(byte[] buf, int offset, AsnEncoder encoder)
Used to encode the integer value into an ASN.1 buffer.boolean
equals(java.lang.Object obj)
int
getValue()
Used to access the internal 32-bit signed quantity.int
hashCode()
void
setValue(int value)
Used to set the 32-bit signed quantityvoid
setValue(java.lang.Integer value)
Used to set the 32-bit signed quantitystatic java.lang.Integer
toInteger(SnmpInt32 val)
java.lang.String
toString()
Returns the string representation of the object.byte
typeId()
Used to retreive the ASN.1 type for this object.
-
-
-
Field Detail
-
ASNTYPE
public static final byte ASNTYPE
The ASN.1 type as defined by the SNMP SMI specification.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SnmpInt32
public SnmpInt32()
Default constructor. Builds a SnmpInt32 objeect with a value of zero.
-
SnmpInt32
public SnmpInt32(int value)
Constructs a SnmpInt32 object with the passed value.- Parameters:
value
- The 32-bit signed integer value for the object.
-
SnmpInt32
public SnmpInt32(java.lang.Integer value)
Constructs a SnmpInt32 object with the specified value.- Parameters:
value
- An Integer object containing the 32-bte value.
-
SnmpInt32
public SnmpInt32(SnmpInt32 second)
Class copy constructor. Constructs a new object with the same value as the passed SnmpInt32 object.- Parameters:
second
- The object to get the value from.
-
SnmpInt32
public SnmpInt32(java.lang.String value)
Simple class constructor that attempts to parse the passed string into a valid integer value. If the String argument cannot be parse because it is either invalid or malformed then an exception is generated.- Parameters:
value
- The integer value represented as a String- Throws:
java.lang.NumberFormatException
- Thrown if the passed value cannot be turned into a valid integer.java.lang.NullPointerException
- Thrown if the passed string is a null reference.
-
-
Method Detail
-
getValue
public int getValue()
Used to access the internal 32-bit signed quantity.- Returns:
- The 32-bit value
-
setValue
public void setValue(int value)
Used to set the 32-bit signed quantity- Parameters:
value
- The new value for the object.
-
setValue
public void setValue(java.lang.Integer value)
Used to set the 32-bit signed quantity- Parameters:
value
- The new value for the object
-
typeId
public byte typeId()
Used to retreive the ASN.1 type for this object.- Specified by:
typeId
in interfaceSnmpSyntax
- Returns:
- The ASN.1 value for the SnmpInt32
-
encodeASN
public int encodeASN(byte[] buf, int offset, AsnEncoder encoder) throws AsnEncodingException
Used to encode the integer value into an ASN.1 buffer. The passed encoder defines the method for encoding the data.- Specified by:
encodeASN
in interfaceSnmpSyntax
- Parameters:
buf
- The location to write the encoded dataoffset
- The start of the encoded buffer.encoder
- The ASN.1 encoder object- Returns:
- The byte immediantly after the last encoded byte.
- Throws:
AsnEncodingException
- Thrown if an encoding error occurs
-
decodeASN
public int decodeASN(byte[] buf, int offset, AsnEncoder encoder) throws AsnDecodingException
Used to decode the integer value from the ASN.1 buffer. The passed encoder is used to decode the ASN.1 information and the integer value is stored in the internal object.- Specified by:
decodeASN
in interfaceSnmpSyntax
- Parameters:
buf
- The encoded ASN.1 dataoffset
- The offset of the first byte of dataencoder
- The ASN.1 decoder object.- Returns:
- The byte immediantly after the last decoded byte of information.
- Throws:
AsnDecodingException
- Thrown if an encoding error occurs
-
duplicate
public SnmpSyntax duplicate()
Returns a duplicate of the current object.- Specified by:
duplicate
in interfaceSnmpSyntax
- Returns:
- A newly allocated duplicate object.
-
clone
public java.lang.Object clone()
Returns a duplicate of the current object.- Overrides:
clone
in classjava.lang.Object
- Returns:
- A newly allocated duplicate object.
-
toString
public java.lang.String toString()
Returns the string representation of the object.- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toInteger
public static java.lang.Integer toInteger(SnmpInt32 val)
-
-