org.opennms.netmgt.poller
Class InetNetworkInterface

java.lang.Object
  extended by org.opennms.netmgt.poller.InetNetworkInterface
All Implemented Interfaces:
Serializable, NetworkInterface<InetAddress>
Direct Known Subclasses:
DefaultCollectionAgent

public class InetNetworkInterface
extends Object
implements NetworkInterface<InetAddress>, Serializable

The NetworkInterface class is designed to be a well defined front for passing interfaces to a service monitor. There are many different types of network in use today including IPv4, IPv6, IPX, and others. To accommodate the possible differences this class provides the basic information that a monitor can use to determine the type of interface and its expected address type.

In addition to providing typing and address information, the interface allows for the monitor to associate key-value pairs with an interface. This can be used to save state information between the various invocations if necessary. The attributes may be shared with other monitors concurrently, so a monitor must be careful to choose unique keys to prevent namespace collisions.

Author:
Mike Davidson , Weave , OpenNMS
See Also:
Serialized Form

Field Summary
protected  InetAddress m_address
          Interface address
 
Fields inherited from interface org.opennms.netmgt.poller.NetworkInterface
TYPE_INET, TYPE_UNKNOWN
 
Constructor Summary
InetNetworkInterface(InetAddress address)
          Constructor for InetNetworkInterface.
 
Method Summary
 InetAddress getAddress()
           Returns the address information for the interface.
<V> V
getAttribute(String property)
           This method is used to return the object that is associated with the property name.
 InetAddress getInetAddress()
          getInetAddress
 int getType()
           Returns the interface type for the network interface.
 Object setAttribute(String property, Object value)
           This method is used to associate an object value with a textual key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_address

protected InetAddress m_address
Interface address

Constructor Detail

InetNetworkInterface

public InetNetworkInterface(InetAddress address)

Constructor for InetNetworkInterface.

Parameters:
address - a InetAddress object.
Method Detail

getType

public int getType()

Returns the interface type for the network interface.

Specified by:
getType in interface NetworkInterface<InetAddress>
Returns:
a int.

getAddress

public InetAddress getAddress()

Returns the address information for the interface. If the interface then this should be either an InetAddress or an object for specialized address types.

Specified by:
getAddress in interface NetworkInterface<InetAddress>
Returns:
a Object object.

getInetAddress

public InetAddress getInetAddress()

getInetAddress

Returns:
a InetAddress object.

getAttribute

public <V> V getAttribute(String property)

This method is used to return the object that is associated with the property name. This is very similar to the java.util.Map get() method, but requires that the lookup be performed using a String name. The object may be of any instance that the monitor previous stored.

If there is no matching object for the property key, then a null pointer is returned to the application.

This method is used to return the object that is associated with the property name. This is very similar to the java.util.Map get() method, but requires that the lookup be performed using a String name. The object may be of any instance that the monitor previous stored.

If there is no matching object for the property key, then a null pointer is returned to the application.

Specified by:
getAttribute in interface NetworkInterface<InetAddress>
Parameters:
property - The key for the lookup.
Returns:
The resulting value for the key, null if no value exist.
Throws:
IllegalArgumentException - Thrown if the passed key is empty or null.
See Also:
Map.get(java.lang.Object)

setAttribute

public Object setAttribute(String property,
                           Object value)

This method is used to associate an object value with a textual key. If a previous value was associated with the key then the old value is returned to the caller. This is identical to the behavior defined by the java.util.Map put() method. The only restriction is that the key must be a java string instance.

This method is used to associate an object value with a textual key. If a previous value was associated with the key then the old value is returned to the caller. This is identical to the behavior defined by the java.util.Map put() method. The only restriction is that the key must be a java string instance.

Specified by:
setAttribute in interface NetworkInterface<InetAddress>
Parameters:
property - The key
value - The value to associate with the key
Returns:
The object that was previously associated with the key. Null is returned if there was no previous value associated.
Throws:
IllegalArgumentException - Thrown if the property name is empty or null.
See Also:
Map.put(java.lang.Object, java.lang.Object)


Copyright © 2011. All Rights Reserved.