java::net::NetworkInterface Class Reference

Inheritance diagram for java::net::NetworkInterface:

Inheritance graph
java::lang::Object
[legend]
Collaboration diagram for java::net::NetworkInterface:

Collaboration graph
java::lang::Objectjava::lang::ObjectRefjava::lang::Interfacejava::lang::Comparable
[legend]

List of all members.


Detailed Description

This class represents a Network Interface made up of a name, and a list of IP addresses assigned to this interface.

It is used to identify the local interface on which a multicast group is joined.

Interfaces are normally known by names such as "le0".

Since:
1.4

Public Member Functions

 NetworkInterface ()
virtual String getName () const
 Get the name of this network interface.
virtual Ref< ListgetInetAddresses () const
 Convenience method to return an Enumeration with all or a subset of the InetAddresses bound to this network interface.
virtual String getDisplayName () const
 Get the display name of this network interface.
virtual jboolean equals (const Object &obj) const
 Compares this object against the specified object.
virtual jint hashCode () const
 Returns a hash code value for the object.
virtual String toString () const
 Returns a string representation of the object.

Static Public Member Functions

static Ref
< NetworkInterface
getByName (const String &name)
 Searches for the network interface with the specified name.
static Ref
< NetworkInterface
getByInetAddress (const InetAddress &addr)
 Convenience method to search for a network interface that has the specified Internet Protocol (IP) address bound to it.
static Ref< ListgetNetworkInterfaces ()
 Returns all the interfaces on this machine.

Protected Member Functions

 NetworkInterface (const ObjectRef &impl)
 Returns an NetworkInterface object with index set to 0 and name to null.

Constructor & Destructor Documentation

java::net::NetworkInterface::NetworkInterface (  ) 

java::net::NetworkInterface::NetworkInterface ( const ObjectRef impl  )  [protected]

Returns an NetworkInterface object with index set to 0 and name to null.

Setting such an interface on a MulticastSocket will cause the kernel to choose one interface for sending multicast packets.


Member Function Documentation

virtual String java::net::NetworkInterface::getName (  )  const [virtual]

Get the name of this network interface.

Returns:
the name of this network interface

virtual Ref<List> java::net::NetworkInterface::getInetAddresses (  )  const [virtual]

Convenience method to return an Enumeration with all or a subset of the InetAddresses bound to this network interface.

If there is a security manager, its checkConnect method is called for each InetAddress. Only InetAddresses where the checkConnect doesn't throw a SecurityException will be returned in the Enumeration.

Returns:
a list object with all or a subset of the InetAddresses bound to this network interface

virtual String java::net::NetworkInterface::getDisplayName (  )  const [virtual]

Get the display name of this network interface.

A display name is a human readable String describing the network device.

Returns:
the display name of this network interface, or null if no display name is available.

static Ref<NetworkInterface> java::net::NetworkInterface::getByName ( const String name  )  [static]

Searches for the network interface with the specified name.

Parameters:
name The name of the network interface.
Returns:
A NetworkInterface with the specified name, or null if there is no network interface with the specified name.
Exceptions:
SocketException If an I/O error occurs.
NullPointerException If the specified name is null.

static Ref<NetworkInterface> java::net::NetworkInterface::getByInetAddress ( const InetAddress addr  )  [static]

Convenience method to search for a network interface that has the specified Internet Protocol (IP) address bound to it.

If the specified IP address is bound to multiple network interfaces it is not defined which network interface is returned.

Parameters:
addr The InetAddress to search with.
Returns:
A NetworkInterface or null if there is no network interface with the specified IP address.
Exceptions:
SocketException If an I/O error occurs.
NullPointerException If the specified address is null.

static Ref<List> java::net::NetworkInterface::getNetworkInterfaces (  )  [static]

Returns all the interfaces on this machine.

Returns null if no network interfaces could be found on this machine.

NOTE: can use getNetworkInterfaces()+getInetAddresses() to obtain all IP addresses for this node

Returns:
a list of NetworkInterfaces found on this machine
Exceptions:
SocketException if an I/O error occurs.

virtual jboolean java::net::NetworkInterface::equals ( const Object obj  )  const [virtual]

Compares this object against the specified object.

The result is true if and only if the argument is not null and it represents the same NetworkInterface as this object.

Two instances of NetworkInterface represent the same NetworkInterface if both name and addrs are the same for both.

Parameters:
obj the object to compare against.
Returns:
true if the objects are the same; false otherwise.
See also:
java.net.InetAddress::getAddress()

Reimplemented from java::lang::Object.

virtual jint java::net::NetworkInterface::hashCode (  )  const [virtual]

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:

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 Java<font size="-2">TM</font> programming language.)

Returns:
a hash code value for this object.

Reimplemented from java::lang::Object.

virtual String java::net::NetworkInterface::toString (  )  const [virtual]

Returns a string representation of the object.

In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `</code>', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: <blockquote>

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
</blockquote>

Returns:
a string representation of the object.

Reimplemented from java::lang::Object.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:44 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3