Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


com.tangosol.net
Class InetAddressHelper

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.net.InetAddressHelper


public abstract class InetAddressHelper
extends Base

Helper class that encapsulates common InetAddress functionality.


Nested Class Summary
static class InetAddressHelper.RoutableFilter
          The RoutableFilter evaulates to true for any InetAddress which is externally routable.
static class InetAddressHelper.SubnetMaskFilter
          SubnetMaskFilter evaulates to true for any address with matches the pattern for the masked bits

 

Field Summary
static java.lang.reflect.Method METHOD_GET_MTU
          Method for obtaining the MTU from a NetworkInterface in 1.6+ JVMs.
static boolean PreferIPv4Stack
          The value of system property "java.net.preferIPv4Stack".
static boolean PreferIPv6Addresses
          The value of system property "java.net.preferIPv6Addresses".

 

Constructor Summary
InetAddressHelper()
           

 

Method Summary
static int compare(java.net.InetAddress addrA, java.net.InetAddress addrB)
          Compare two InetAddresses for ordering purposes.
static java.util.List getAllLocalAddresses()
          Return a list of all InetAddress objects bound to all the network interfaces on this machine.
static java.util.Map getAllLocalMTUs()
          Return a map of all InetAddress and MTUs bound to all the network interfaces on this machine.
static java.net.InetAddress getByAddress(byte[] abAddr)
          Return an InetAddress object given the raw IP address.
static java.net.InetAddress getLocalAddress(Filter filter)
          Obtain the "best" local host address which matches the supplied filter.
static java.net.InetAddress getLocalAddress(java.lang.String sAddr)
          Return the local InetAddress represented by the specified string.
static java.net.InetAddress getLocalHost()
          Obtain the local host address.
static int getLocalMTU(java.net.InetAddress addr)
          Return the MTU for the specified local address.
static int getLocalMTU(java.net.NetworkInterface ni)
          Return the MTU for the specified NetworkInterface.
static java.net.InetSocketAddress getSocketAddress(java.lang.String sAddr, int nPort)
          Return the InetSocketAddress represented by the specified string.
static boolean isAnyLocalAddress(java.net.InetAddress addr)
          Deprecated. As of Coherence 3.0, replaced by InetAddress.isAnyLocalAddress()
static boolean isLinkLocalAddress(java.net.InetAddress addr)
          Deprecated. As of Coherence 3.0, replaced by InetAddress.isLinkLocalAddress()
static boolean isLocalAddress(java.net.InetAddress addr)
          Return true if the specified address is a local address.
static boolean isLoopbackAddress(java.net.InetAddress addr)
          Deprecated. As of Coherence 3.0, replaced by InetAddress.isLoopbackAddress()
static boolean isSiteLocalAddress(java.net.InetAddress addr)
          Deprecated. As of Coherence 3.0, replaced by InetAddress.isSiteLocalAddress()
protected static void setSubnetMask(byte[] ab, int cBits)
          Set the specified number of bits of a byte array representing a subnet mask.
static long toLong(java.net.InetAddress addr)
          Converts an IPv4 compatible address to a long value.
static java.lang.String toString(byte[] ab)
          Converts a byte array to a raw IP address string representation.
static java.lang.String toString(java.net.InetAddress addr)
          Format an IP address string representing the specified InetAddress object.
static boolean virtuallyEqual(byte[] abAddr1, byte[] abAddr2)
          Compare specified raw IP addresses taking into account IPv4-compatible IPv6 addresses.

 

Field Detail

PreferIPv4Stack

public static final boolean PreferIPv4Stack
The value of system property "java.net.preferIPv4Stack".
See Also:
Networking IPv6 User Guide

PreferIPv6Addresses

public static final boolean PreferIPv6Addresses
The value of system property "java.net.preferIPv6Addresses".
See Also:
Networking IPv6 User Guide

METHOD_GET_MTU

public static final java.lang.reflect.Method METHOD_GET_MTU
Method for obtaining the MTU from a NetworkInterface in 1.6+ JVMs.

Constructor Detail

InetAddressHelper

public InetAddressHelper()

Method Detail

getLocalAddress

public static java.net.InetAddress getLocalAddress(Filter filter)
                                            throws java.net.UnknownHostException
Obtain the "best" local host address which matches the supplied filter.
Parameters:
filter - the filter to match
Returns:
the InetAddress
Throws:
java.net.UnknownHostException - if no match can be found

getLocalAddress

public static java.net.InetAddress getLocalAddress(java.lang.String sAddr)
                                            throws java.net.UnknownHostException
Return the local InetAddress represented by the specified string.
Parameters:
sAddr - the string address, either hostname, literal ip, or subnet and mask
Returns:
the InetAddress
Throws:
java.net.UnknownHostException - if the string cannot be resolved to a local address

getLocalHost

public static java.net.InetAddress getLocalHost()
                                         throws java.net.UnknownHostException
Obtain the local host address. If at all possible, ensure that the returned address is not a loopback, wildcard or a link local address.
Returns:
the InetAddress that is the best fit for the local host address
Throws:
java.net.UnknownHostException
See Also:
Sun's Bug Parade

compare

public static int compare(java.net.InetAddress addrA,
                          java.net.InetAddress addrB)
Compare two InetAddresses for ordering purposes.
Parameters:
addrA - the first address to compare
addrB - the second address to compare
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second

getLocalMTU

public static int getLocalMTU(java.net.InetAddress addr)
Return the MTU for the specified local address.
Parameters:
addr - the local address
Returns:
the MTU of the specified address, or 0 if the MTU can not be identified

getLocalMTU

public static int getLocalMTU(java.net.NetworkInterface ni)
Return the MTU for the specified NetworkInterface.
Parameters:
ni - the network interface
Returns:
the MTU of the specified address, or 0 if the MTU can not be identified

getAllLocalAddresses

public static java.util.List getAllLocalAddresses()
Return a list of all InetAddress objects bound to all the network interfaces on this machine.
Returns:
a list of InetAddress objects

getAllLocalMTUs

public static java.util.Map getAllLocalMTUs()
Return a map of all InetAddress and MTUs bound to all the network interfaces on this machine. If the MTU cannot be obtained a null value will be used.
Returns:
a map of Integer MTU values keyed by the corresponding InetAddress

getSocketAddress

public static java.net.InetSocketAddress getSocketAddress(java.lang.String sAddr,
                                                          int nPort)
                                                   throws java.net.UnknownHostException
Return the InetSocketAddress represented by the specified string.
Parameters:
sAddr - a legal address string
nPort - a default port to use if sAddr does not contain one
Returns:
a non-null InetSocketAddress object
Throws:
java.net.UnknownHostException

isLocalAddress

public static boolean isLocalAddress(java.net.InetAddress addr)
Return true if the specified address is a local address.
Parameters:
addr - the address to check
Returns:
true if the address is a local address

isLoopbackAddress

@Deprecated
public static boolean isLoopbackAddress(java.net.InetAddress addr)
Deprecated. As of Coherence 3.0, replaced by InetAddress.isLoopbackAddress()
Check whether or not the specified address is a loopback address.
Parameters:
addr - the InetAddress
Returns:
true iff the address is a loopback address

isAnyLocalAddress

@Deprecated
public static boolean isAnyLocalAddress(java.net.InetAddress addr)
Deprecated. As of Coherence 3.0, replaced by InetAddress.isAnyLocalAddress()
Check whether or not the specified address is a wildcard address.
Parameters:
addr - the InetAddress
Returns:
true iff the address is a wildcard address

isLinkLocalAddress

@Deprecated
public static boolean isLinkLocalAddress(java.net.InetAddress addr)
Deprecated. As of Coherence 3.0, replaced by InetAddress.isLinkLocalAddress()
Check whether or not the specified address is a link local address.
Parameters:
addr - the InetAddress
Returns:
true iff the address is a link local address

isSiteLocalAddress

@Deprecated
public static boolean isSiteLocalAddress(java.net.InetAddress addr)
Deprecated. As of Coherence 3.0, replaced by InetAddress.isSiteLocalAddress()
Check whether or not the specified address is a site local address.
Parameters:
addr - the InetAddress
Returns:
true iff the address is a site local address

getByAddress

public static java.net.InetAddress getByAddress(byte[] abAddr)
                                         throws java.net.UnknownHostException
Return an InetAddress object given the raw IP address.
Parameters:
abAddr - the raw IP address in network byte order
Returns:
the InetAddress object
Throws:
java.net.UnknownHostException

virtuallyEqual

public static boolean virtuallyEqual(byte[] abAddr1,
                                     byte[] abAddr2)
Compare specified raw IP addresses taking into account IPv4-compatible IPv6 addresses. Two addresses are considered virtually equal if they have the same protocol (length) and are equal, or if one of them is an IPv6 address that is IPv4-compatible and its IPv4 representation is equal to the other IPv4 address.
Parameters:
abAddr1 - first IP address
abAddr2 - second IP address
Returns:
true iff the addresses are compatible

toLong

public static long toLong(java.net.InetAddress addr)
Converts an IPv4 compatible address to a long value.
Parameters:
addr - an instance of InetAddress to convert to a long
Returns:
a long value holding the IPv4 address

toString

public static java.lang.String toString(byte[] ab)
Converts a byte array to a raw IP address string representation. The format of the address string is one of the following:
Parameters:
ab - the byte array holding the IP address
Returns:
the IP address string
See Also:
InetAddress.getHostAddress(), Inet6Address

toString

public static java.lang.String toString(java.net.InetAddress addr)
Format an IP address string representing the specified InetAddress object. The main difference if this method over the addr.toString() call is that this implementation avoids a call to the addr.getHostName() method, which could be very expensive due to the reverse DNS lookup.
For IPv6 addresses this method produces an alternative form of "x:x:x:x:x:x:d.d.d.d" and a compressed form of "::d.d.d.d" for IPv4 compatible addresses (instead of the default form "x:x:x:x:x:x:x:x").
Parameters:
addr - the address for which to format the IP address string
Returns:
the IP address string
See Also:
InetAddress.getHostAddress(), Inet6Address

setSubnetMask

protected static void setSubnetMask(byte[] ab,
                                    int cBits)
Set the specified number of bits of a byte array representing a subnet mask.
Parameters:
ab - the array to fill
cBits - the number of bits to set

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.