@Extensible @ThreadSafety(level=INTERFACE_THREADSAFE) public abstract class NameResolver extends java.lang.Object
InetAddress
class. Subclasses may override these methods to
provide support for caching, improved instrumentation, or other
functionality. Any such methods that are not overridden will get the
JVM-default behavior.Modifier | Constructor and Description |
---|---|
protected |
NameResolver()
Creates a new instance of this default name resolver.
|
Modifier and Type | Method and Description |
---|---|
java.net.InetAddress[] |
getAllByName(java.lang.String host)
Retrieves an array of
InetAddress objects that encapsulate all
known IP addresses associated with the provided host name. |
java.net.InetAddress |
getByName(java.lang.String host)
Retrieves an
InetAddress that encapsulates an IP address associated
with the provided host name. |
java.lang.String |
getCanonicalHostName(java.net.InetAddress inetAddress)
Retrieves the canonical host name for the provided
InetAddress
object. |
java.lang.String |
getHostName(java.net.InetAddress inetAddress)
Retrieves the host name for the provided
InetAddress object. |
java.net.InetAddress |
getLocalHost()
Retrieves the address of the local host.
|
java.net.InetAddress |
getLoopbackAddress()
Retrieves the loopback address for the system.
|
static void |
setJVMSuccessfulLookupCacheTTLSeconds(int seconds)
Sets the length of time in seconds for which the JVM should cache the
results of successful name service lookups.
|
static void |
setJVMUnsuccessfulLookupCacheTTLSeconds(int seconds)
Sets the length of time in seconds for which the JVM should cache the
results of unsuccessful name service lookups (that is, lookups in which no
mapping is found).
|
java.lang.String |
toString()
Retrieves a string representation of this name resolver.
|
abstract void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this name resolver to the provided
buffer.
|
protected NameResolver()
@NotNull public java.net.InetAddress getByName(@Nullable java.lang.String host) throws java.net.UnknownHostException, java.lang.SecurityException
InetAddress
that encapsulates an IP address associated
with the provided host name.host
- The host name for which to retrieve a corresponding
InetAddress
object. It can be a resolvable name or
a textual representation of an IP address. If the provided
name is the textual representation of an IPv6 address, then
it can use either the form described in RFC 2373 or RFC 2732,
or it can be an IPv6 scoped address. If it is null
,
then the returned address should represent an address of the
loopback interface.InetAddress
that encapsulates an IP address associated
with the provided host name.java.net.UnknownHostException
- If the provided name cannot be resolved to
its corresponding IP addresses.java.lang.SecurityException
- If a security manager prevents the name
resolution attempt.@NotNull public java.net.InetAddress[] getAllByName(@Nullable java.lang.String host) throws java.net.UnknownHostException, java.lang.SecurityException
InetAddress
objects that encapsulate all
known IP addresses associated with the provided host name.host
- The host name for which to retrieve the corresponding
InetAddress
objects. It can be a resolvable name or
a textual representation of an IP address. If the provided
name is the textual representation of an IPv6 address, then
it can use either the form described in RFC 2373 or RFC 2732,
or it can be an IPv6 scoped address. If it is null
,
then the returned address should represent an address of the
loopback interface.InetAddress
objects that encapsulate all known
IP addresses associated with the provided host name.java.net.UnknownHostException
- If the provided name cannot be resolved to
its corresponding IP addresses.java.lang.SecurityException
- If a security manager prevents the name
resolution attempt.@NotNull public java.lang.String getHostName(@NotNull java.net.InetAddress inetAddress)
InetAddress
object.inetAddress
- The address for which to retrieve the host name. It
must not be null
.InetAddress
object, or a
textual representation of the IP address if the name cannot be
determined.@NotNull public java.lang.String getCanonicalHostName(@NotNull java.net.InetAddress inetAddress)
InetAddress
object.inetAddress
- The address for which to retrieve the canonical host
name. It must not be null
.InetAddress
object, or a textual representation of the IP address if the name
cannot be determined.@NotNull public java.net.InetAddress getLocalHost() throws java.net.UnknownHostException, java.lang.SecurityException
InetAddress
.java.net.UnknownHostException
- If the local host name cannot be resolved.java.lang.SecurityException
- If a security manager prevents the name
resolution attempt.@NotNull public java.net.InetAddress getLoopbackAddress()
public static void setJVMSuccessfulLookupCacheTTLSeconds(int seconds)
seconds
- The length of time in seconds for which the JVM should
cache the results of successful name service lookups. A
value that is less than zero indicates that values should
be cached forever.public static void setJVMUnsuccessfulLookupCacheTTLSeconds(int seconds)
seconds
- The length of time in seconds for which the JVM should
cache the results of unsuccessful name service lookups. A
value that is less than zero indicates that values should
be cached forever.@NotNull public final java.lang.String toString()
toString
in class java.lang.Object