APIdia Launch Partner
Top Description Fields Constructors Methods
java.net

public final Class InterfaceAddress

extends Object
Class Inheritance
Imports
java.util.Objects

This class represents a Network Interface address. In the case of IPv4, this comprises the IP address, a subnet mask, and a broadcast address if the interface supports broadcast. In the case of IPv6, it comprises the IP address and a network prefix length.
Since
1.6
See Also
java.net.NetworkInterface

Field Summary

Modifier and TypeField and Description
private InetAddress
private Inet4Address
private short

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the objects are the same; false otherwise.
equals
(Object
the object to compare against.
obj
)

Overrides java.lang.Object.equals.

Compares this object against the specified object.

public InetAddress

Returns:

the InetAddress for this address.
getAddress
()

Returns an InetAddress for this address.

public InetAddress

Returns:

the InetAddress representing the broadcast address or null if there is no broadcast address.
getBroadcast
()

Returns an InetAddress for the broadcast address for this InterfaceAddress.

public short

Returns:

a short representing the prefix length for the subnet of that address.
getNetworkPrefixLength
()

Returns the network prefix length for this address.

public int

Returns:

a hash code value for this Interface address.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hashcode for this Interface address.

public String

Returns:

a string representation of this Interface address.
toString
()

Overrides java.lang.Object.toString.

Converts this Interface address to a String.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

addressback to summary
private InetAddress address
broadcastback to summary
private Inet4Address broadcast
maskLengthback to summary
private short maskLength

Constructor Detail

InterfaceAddressback to summary
private InterfaceAddress()

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

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 interface address as this object.

Two instances of InterfaceAddress represent the same address if the InetAddress, the prefix length and the broadcast are the same for both.

Parameters
obj:Object

the object to compare against.

Returns:boolean

true if the objects are the same; false otherwise.

See Also
java.net.InterfaceAddress#hashCode()
getAddressback to summary
public InetAddress getAddress()

Returns an InetAddress for this address.

Returns:InetAddress

the InetAddress for this address.

getBroadcastback to summary
public InetAddress getBroadcast()

Returns an InetAddress for the broadcast address for this InterfaceAddress.

Only IPv4 networks have broadcast address therefore, in the case of an IPv6 network, null will be returned.

Some network interfaces do not support broadcasting and may also return null.

Returns:InetAddress

the InetAddress representing the broadcast address or null if there is no broadcast address.

getNetworkPrefixLengthback to summary
public short getNetworkPrefixLength()

Returns the network prefix length for this address. This is also known as the subnet mask in the context of IPv4 addresses. Typical IPv4 values would be 8 (255.0.0.0), 16 (255.255.0.0) or 24 (255.255.255.0).

Typical IPv6 values would be 128 (::1/128) or 10 (fe80::203:baff:fe27:1243/10)

Returns:short

a short representing the prefix length for the subnet of that address.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hashcode for this Interface address.

Returns:int

a hash code value for this Interface address.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Converts this Interface address to a String. The string returned is of the form: InetAddress / prefix length [ broadcast address ].

Returns:String

a string representation of this Interface address.