Package uk.ac.manchester.spinnaker.utils
Class InetFactory
java.lang.Object
uk.ac.manchester.spinnaker.utils.InetFactory
public abstract class InetFactory extends Object
Convenience methods for creating IPv4 Addresses.
- Author:
- Christian-B
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InetFactory.Inet6NotSupportedException
Specific Exception to show IPv6 is not supported. -
Method Summary
Modifier and Type Method Description static Inet4Address
getByAddress(byte[] addr)
Creates a IPv4 address from the bytes representing the raw address.static Inet4Address
getByAddressQuietly(byte[] addr)
Creates a IPv4 address from the bytes representing the raw address.static Inet4Address
getByName(String host)
Creates a IPv4 address from a host name.static Inet4Address
getByNameQuietly(String host)
Creates a IPv4 address from a host name.
-
Method Details
-
getByAddress
public static Inet4Address getByAddress(byte[] addr) throws UnknownHostException, InetFactory.Inet6NotSupportedExceptionCreates a IPv4 address from the bytes representing the raw address.- Parameters:
addr
- An array of bytes of length 4- Returns:
addr
as an IPv4 address- Throws:
InetFactory.Inet6NotSupportedException
- If theaddr
would translate to a valid IPv6 address; this is not supported by SpinnakerUnknownHostException
- if IP address is of illegal length
-
getByAddressQuietly
Creates a IPv4 address from the bytes representing the raw address.- Parameters:
addr
- An array of bytes of length 4- Returns:
addr
as an IPv4 address- Throws:
RuntimeException
- if IP address is of illegal length or otherwise isn't supported.
-
getByName
public static Inet4Address getByName(String host) throws UnknownHostException, InetFactory.Inet6NotSupportedExceptionCreates a IPv4 address from a host name.- Parameters:
host
- the specified host name- Returns:
host
as an IPv4 address- Throws:
InetFactory.Inet6NotSupportedException
- If thehost
would translate to a valid IPv6 address; this is not supported by SpinnakerUnknownHostException
- if no IP address for the host could be found, or if a scope_id was specified for a global IPv6 address.
-
getByNameQuietly
Creates a IPv4 address from a host name.- Parameters:
host
- the specified host name- Returns:
host
as an IPv4 address- Throws:
RuntimeException
- if IP address is isn't supported as an IPv4 address.
-