com.sun.management.snmp
Class SnmpEngineId

java.lang.Object
  extended by com.sun.management.snmp.SnmpEngineId
All Implemented Interfaces:
Serializable

public class SnmpEngineId
extends Object
implements Serializable

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.

Since:
Java DMK 5.1
See Also:
Serialized Form

Method Summary
static SnmpEngineId createEngineId()
          Generates an engine Id that is unique to the host the agent is running on.
static SnmpEngineId createEngineId(byte[] arr)
          Generates an engine Id based on the passed array.
static SnmpEngineId createEngineId(InetAddress addr)
          Generates an engine Id based on an InetAddress.
static SnmpEngineId createEngineId(InetAddress address, int port)
          Generates a unique engine Id.
static SnmpEngineId createEngineId(InetAddress addr, int port, int iana)
          Generates a unique engine Id.
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(int port, int iana)
          Generates a unique engine Id.
static SnmpEngineId createEngineId(String str)
          Generates a unique engine Id.
static SnmpEngineId createEngineId(String str, String separator)
          Idem createEngineId(java.lang.String) with the ability to provide your own separator.
 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()
           
 SnmpOid toOid()
          Translates an engine Id in an SnmpOid format.
 String toString()
          Returns a string format engine Id.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getReadableId

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.

toString

public String toString()
Returns a string format engine Id.

Overrides:
toString in class Object
Returns:
String format value.

getBytes

public byte[] getBytes()
Returns a binary engine Id.

Returns:
Binary value.

createEngineId

public static SnmpEngineId createEngineId(byte[] arr)
                                   throws IllegalArgumentException
Generates an engine Id based on the passed array.

Returns:
The created engine Id or null if given array is null or its length == 0;
Throws:
IllegalArgumentException. - Thrown 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
IllegalArgumentException

createEngineId

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.

toOid

public SnmpOid toOid()
Translates an engine Id in an SnmpOid format. This is useful when dealing with USM MIB indexes. The oid format is : ...... e.g. "0x8000002a05819dcb6e00001f96" ==> 13.128.0.0.42.5.129.157.203.110.0.0.31.150

Returns:
SnmpOid The oid.

createEngineId

public static SnmpEngineId createEngineId(String str)
                                   throws IllegalArgumentException,
                                          UnknownHostException

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 :

Parameters:
str - The string to parse.
Returns:
The generated engine Id or null if the passed string is null.
Throws:
UnknownHostException. - Thrown if the host name contained in the textual format is unknown.
IllegalArgumentException. - Thrown 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 conjunction with the ":" separator
IllegalArgumentException
UnknownHostException

createEngineId

public static SnmpEngineId createEngineId(String str,
                                          String separator)
                                   throws IllegalArgumentException,
                                          UnknownHostException
Idem createEngineId(java.lang.String) with the ability to provide your own separator. This allows IPv6 address format handling (e.g. 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. - Thrown if the host name contained in the textual format is unknown.
IllegalArgumentException. - Thrown 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 conjunction with the ":" separator
IllegalArgumentException
UnknownHostException

createEngineId

public static SnmpEngineId createEngineId(int port)
                                   throws UnknownHostException
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 SnmpV3AdaptorServer is listening to.
Returns:
The generated engine Id.
Throws:
UnknownHostException. - Thrown if the local host name used to calculate the id is unknown.
UnknownHostException

createEngineId

public static SnmpEngineId createEngineId(InetAddress address,
                                          int port)
                                   throws IllegalArgumentException
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 SnmpV3AdaptorServer is listening to.
port - The TCP/IP port the SnmpV3AdaptorServer is listening to.
Returns:
The generated engine Id.
Throws:
UnknownHostException. - Thrown if the provided address is null.
IllegalArgumentException

createEngineId

public static SnmpEngineId createEngineId(int port,
                                          int iana)
                                   throws UnknownHostException
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 SnmpV3AdaptorServer is listening to.
iana - Your enterprise IANA number.
Returns:
The generated engine Id.
Throws:
UnknownHostException. - Thrown if the local host name used to calculate the id is unknown.
UnknownHostException

createEngineId

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 SnmpV3AdaptorServer is listening to.
port - The TCP/IP port the SnmpV3AdaptorServer is listening to.
iana - Your enterprise IANA number.
Returns:
The generated engine Id.
Throws:
UnknownHostException. - Thrown if the provided InetAddress is null.

createEngineId

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 SnmpV3AdaptorServer is listening to.
Returns:
The generated engine Id.
Throws:
UnknownHostException. - Thrown if the provided InetAddress is null.

createEngineId

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 SnmpV3AdaptorServer is listening to.
Returns:
The generated engine Id.
Throws:
UnknownHostException. - Thrown if the provided InetAddress is null.

equals

public boolean equals(Object a)
Tests SnmpEngineId instance equality. Two SnmpEngineId are equal if they have the same value.

Overrides:
equals in class Object
Returns:
true if the two SnmpEngineId are equals, false otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

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.