Package com.tangosol.net
Class InetAddressHelper
- java.lang.Object
-
- com.oracle.coherence.common.net.InetAddresses
-
- com.tangosol.net.InetAddressHelper
-
public abstract class InetAddressHelper extends com.oracle.coherence.common.net.InetAddresses
Helper class that encapsulates common InetAddress functionality.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InetAddressHelper.RoutableFilter
The RoutableFilter evaluates to true for any InetAddress which is externally routable.static class
InetAddressHelper.SubnetMaskFilter
SubnetMaskFilter evaluates to true for any address with matches the pattern for the masked bits
-
Constructor Summary
Constructors Constructor Description InetAddressHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static String[]
getAddressDescriptions(Collection colAddresses)
Return an array of strings representing addresses in the specified collection.static InetAddress
getLocalAddress(Filter filter)
Obtain the "best" local host address which matches the supplied filter.static Collection<InetAddress>
getRoutableAddresses(InetAddress addrLocal, boolean fLocalSrc, Collection<InetAddress> colDest, boolean fLocalDest)
Return the set of addresses from the specified destination addresses which appear to be routable from addrLocal.static boolean
isAnyLocalAddress(InetAddress addr)
Deprecated.As of Coherence 3.0, replaced byInetAddress.isAnyLocalAddress()
static boolean
isLinkLocalAddress(InetAddress addr)
Deprecated.As of Coherence 3.0, replaced byInetAddress.isLinkLocalAddress()
static boolean
isLoopbackAddress(InetAddress addr)
Deprecated.As of Coherence 3.0, replaced byInetAddress.isLoopbackAddress()
static boolean
isSiteLocalAddress(InetAddress addr)
Deprecated.As of Coherence 3.0, replaced byInetAddress.isSiteLocalAddress()
static String
toString(byte[] ab)
Converts a byte array to a raw IP address string representation.static String
toString(int nPort)
Format a port string representing the specified port number.static String
toString(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.-
Methods inherited from class com.oracle.coherence.common.net.InetAddresses
checkLocalAddress, compare, generateMagic, getAddress, getAllLocalAddresses, getAllLocalMTUs, getByAddress, getLocalAddress, getLocalAddress, getLocalAddresses, getLocalBindableAddresses, getLocalHost, getLocalMTU, getLocalMTU, getLocalMTU, getLocalPeer, getLocalSubnetAddress, getLocalSubnetLength, getPort, getRoutes, getSocketAddress, hasNatLocalAddress, isAnyLocalAddress, isEphemeral, isHostName, isInSubnet, isLocalAddress, isLocalBindableAddress, isLocalReachableAddress, isNatLocalAddress, isNatLocalAddress, isNatLocalAddress, isNatLocalAddress, setAddress, setPort, setSubnetMask, toLong
-
-
-
-
Method Detail
-
getLocalAddress
public static InetAddress getLocalAddress(Filter filter) throws UnknownHostException
Obtain the "best" local host address which matches the supplied filter.- Parameters:
filter
- the filter to match- Returns:
- the InetAddress
- Throws:
UnknownHostException
- if no match can be found
-
getAddressDescriptions
public static String[] getAddressDescriptions(Collection colAddresses)
Return an array of strings representing addresses in the specified collection.- Parameters:
colAddresses
- the collection of addresses- Returns:
- an array of strings representing addresses in the specified collection
-
getRoutableAddresses
public static Collection<InetAddress> getRoutableAddresses(InetAddress addrLocal, boolean fLocalSrc, Collection<InetAddress> colDest, boolean fLocalDest)
Return the set of addresses from the specified destination addresses which appear to be routable from addrLocal. May return null if no routable addresses are found.If the addrLocal is null, or fLocalSrc is true, then all local addresses are used to compare to the set of destination addresses.
- Parameters:
addrLocal
- the local address to compare to the destination addresses; may be nullfLocalSrc
- whether the source should be considered local to this machinecolDest
- the full collection of candidate destination addresses; may contain non-routable local only addressesfLocalDest
- whether the destination is local to this machine- Returns:
- the set of addresses from the specified destination addresses which appear to be routable from the source addresses, or null if no addresses are found
- Since:
- 12.2.1
-
isLoopbackAddress
@Deprecated public static boolean isLoopbackAddress(InetAddress addr)
Deprecated.As of Coherence 3.0, replaced byInetAddress.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(InetAddress addr)
Deprecated.As of Coherence 3.0, replaced byInetAddress.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(InetAddress addr)
Deprecated.As of Coherence 3.0, replaced byInetAddress.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(InetAddress addr)
Deprecated.As of Coherence 3.0, replaced byInetAddress.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
-
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 addressabAddr2
- second IP address- Returns:
- true iff the addresses are compatible
-
toString
public static 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:- "d.d.d.d" for IPv4 address
- "::d.d.d.d" for IPv4 compatible IPv6 address
- "x:x:x:x:x:x:d.d.d.d" for IPv6 mapped IPv4 address
- Parameters:
ab
- the byte array holding the IP address- Returns:
- the IP address string
- See Also:
InetAddress.getHostAddress()
,Inet6Address
-
toString
public static String toString(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
-
toString
public static String toString(int nPort)
Format a port string representing the specified port number.If nPort is an extended 32 bit port, then the output will be of the form "port.sub-port"
- Parameters:
nPort
- the port- Returns:
- the port string
- Since:
- 12.2.1
- See Also:
InetSocketAddress32
-
-