public class

SnmpEngineId

extends Object
implements Serializable
java.lang.Object
   ↳ com.sun.jmx.snmp.SnmpEngineId

Class Overview

This class is handling an SnmpEngineId data. It copes with binary as well as String representation of an engine Id. A string format engine is an hex string starting with 0x.

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

Summary

Public Methods
static SnmpEngineId createEngineId(String str, String separator)
Idem { @link com.sun.jmx.snmp.SnmpEngineId#createEngineId(java.lang.String) } with the ability to provide your own separator.
static SnmpEngineId createEngineId(InetAddress addr, int port, int iana)
Generates a unique engine Id.
static SnmpEngineId createEngineId(InetAddress addr)
Generates an engine Id based on an InetAddress.
static SnmpEngineId createEngineId(int port)
Generates a unique engine Id.
static SnmpEngineId createEngineId(int iana, InetAddress addr)
Generates an engine Id based on an InetAddress.
static SnmpEngineId createEngineId()
Generates an engine Id that is unique to the host the agent is running on.
static SnmpEngineId createEngineId(int port, int iana)
Generates a unique engine Id.
static SnmpEngineId createEngineId(InetAddress address, int port)
Generates a unique engine Id.
static SnmpEngineId createEngineId(byte[] arr)
Generates an engine Id based on the passed array.
static SnmpEngineId createEngineId(String str)

Generates a unique engine Id.

boolean equals(Object a)
Tests SnmpEngineId instance equality.
byte[] getBytes()
Returns a binary engine Id.
String getReadableId()
If a string of the format <address>:<port>:<IANA number> has been provided at creation time, this string is returned.
int hashCode()
Returns a hash code value for the object.
SnmpOid toOid()
Translates an engine Id in an SnmpOid format.
String toString()
Returns a string format engine Id.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static SnmpEngineId createEngineId (String str, String separator)

Idem { @link com.sun.jmx.snmp.SnmpEngineId#createEngineId(java.lang.String) } with the ability to provide your own separator. This allows IPv6 address format handling (eg: providing @ as separator).

Parameters
str The string to parse.
separator the separator to use. If null is provided, the default separator ":" is used.
Returns
  • The generated engine Id or null if the passed string is null.
Throws
UnknownHostException if the host name contained in the textual format is unknown.
IllegalArgumentException when :
  • octet string lower than 5 bytes.
  • octet string greater than 32 bytes.
  • octet string = all zeros.
  • octet string = all 'ff'H.
  • octet strings with very first bit = 0 and length != 12 octets
  • An IPv6 address format is used in conjonction with the ":" separator

public static SnmpEngineId createEngineId (InetAddress addr, int port, int iana)

Generates a unique engine Id. The engine Id unicity is based on the host IP address and port. The IP address is the passed one, it handles IPv4 and IPv6 hosts. The creation algorithm uses the passed IANA number.

Parameters
addr The IP address the SNMPv3 Adaptor Server is listening to.
port The TCP/IP port the SNMPv3 Adaptor Server is listening to.
iana Your enterprise IANA number.
Returns
  • The generated engine Id.
Throws
UnknownHostException if the provided InetAddress is null.

public static SnmpEngineId createEngineId (InetAddress addr)

Generates an engine Id based on an InetAddress. Handles IPv4 and IPv6 addresses. The creation algorithm uses the sun IANA number (42).

Parameters
addr The IP address the SNMPv3 Adaptor Server is listening to.
Returns
  • The generated engine Id.
Throws
UnknownHostException if the provided InetAddress is null.

public static SnmpEngineId createEngineId (int port)

Generates a unique engine Id. The engine Id unicity is based on the host IP address and port. The IP address used is the localhost one. The creation algorithm uses the SUN Microsystems IANA number (42).

Parameters
port The TCP/IP port the SNMPv3 Adaptor Server is listening to.
Returns
  • The generated engine Id.
Throws
UnknownHostException if the local host name used to calculate the id is unknown.

public static SnmpEngineId createEngineId (int iana, InetAddress addr)

Generates an engine Id based on an InetAddress. Handles IPv4 and IPv6 addresses. The creation algorithm uses the passed IANA number.

Parameters
iana Your enterprise IANA number.
addr The IP address the SNMPv3 Adaptor Server is listening to.
Returns
  • The generated engine Id.
Throws
UnknownHostException if the provided InetAddress is null.

public static SnmpEngineId createEngineId ()

Generates an engine Id that is unique to the host the agent is running on. The engine Id unicity is system time based. The creation algorithm uses the SUN Microsystems IANA number (42).

Returns
  • The generated engine Id.

public static SnmpEngineId createEngineId (int port, int iana)

Generates a unique engine Id. The engine Id unicity is based on the host IP address and port. The IP address is the localhost one. The creation algorithm uses the passed IANA number.

Parameters
port The TCP/IP port the SNMPv3 Adaptor Server is listening to.
iana Your enterprise IANA number.
Returns
  • The generated engine Id.
Throws
UnknownHostException if the local host name used to calculate the id is unknown.

public static SnmpEngineId createEngineId (InetAddress address, int port)

Generates a unique engine Id. The engine Id unicity is based on the host IP address and port. The IP address used is the passed one. The creation algorithm uses the SUN Microsystems IANA number (42).

Parameters
address The IP address the SNMPv3 Adaptor Server is listening to.
port The TCP/IP port the SNMPv3 Adaptor Server is listening to.
Returns
  • The generated engine Id.
Throws
if the provided address is null.
IllegalArgumentException

public static SnmpEngineId createEngineId (byte[] arr)

Generates an engine Id based on the passed array.

Returns
  • The created engine Id or null if given arr is null or its length == 0;
Throws
IllegalArgumentException when:
  • octet string lower than 5 bytes.
  • octet string greater than 32 bytes.
  • octet string = all zeros.
  • octet string = all 'ff'H.
  • octet strings with very first bit = 0 and length != 12 octets

public static SnmpEngineId createEngineId (String str)

Generates a unique engine Id. Hexadecimal strings as well as a textual description are supported. The textual format is as follow:
<address>:<port>:<IANA number>

The allowed formats :

  • <address>:<port>:<IANA number>
    All these parameters are used to generate the Id. WARNING, this method is not compliant with IPv6 address format. Use { @link com.sun.jmx.snmp.SnmpEngineId#createEngineId(java.lang.String,java.lang.String) } instead.
  • <address>:<port>
    The IANA number will be the SUN Microsystems one (42).
  • address
    The port 161 will be used to generate the Id. IANA number will be the SUN Microsystems one (42).
  • :port
    The host to use is localhost. IANA number will be the SUN Microsystems one (42).
  • ::<IANA number>    
    The port 161 and localhost will be used to generate the Id.
  • :<port>:<IANA number>
    The host to use is localhost.
  • <address>::<IANA number>
    The port 161 will be used to generate the Id.
  • ::    
    The port 161, localhost and the SUN Microsystems IANA number will be used to generate the Id.

Parameters
str The string to parse.
Returns
  • The generated engine Id or null if the passed string is null.
Throws
UnknownHostException if the host name contained in the textual format is unknown.
IllegalArgumentException when :
  • octet string lower than 5 bytes.
  • octet string greater than 32 bytes.
  • octet string = all zeros.
  • octet string = all 'ff'H.
  • octet strings with very first bit = 0 and length != 12 octets
  • An IPv6 address format is used in conjonction with the ":" separator

public boolean equals (Object a)

Tests SnmpEngineId instance equality. Two SnmpEngineId are equal if they have the same value.

Parameters
a the reference object with which to compare.
Returns
  • true if the two SnmpEngineId are equals, false otherwise.

public byte[] getBytes ()

Returns a binary engine Id.

Returns
  • Binary value.

public String getReadableId ()

If a string of the format <address>:<port>:<IANA number> has been provided at creation time, this string is returned.

Returns
  • The Id as a readable string or null if not provided.

public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Returns
  • a hash code value for this object.

public SnmpOid toOid ()

Translates an engine Id in an SnmpOid format. This is useful when dealing with USM MIB indexes. The oid format is : ...... Eg: "0x8000002a05819dcb6e00001f96" ==> 13.128.0.0.42.5.129.157.203.110.0.0.31.150

Returns
  • SnmpOid The oid.

public String toString ()

Returns a string format engine Id.

Returns
  • String format value.