@Immutable
public class ServerAddress
extends java.lang.Object
Constructor and Description |
---|
ServerAddress()
Creates a ServerAddress with default host and port
|
ServerAddress(java.net.InetAddress addr)
Creates a ServerAddress with default port
|
ServerAddress(java.net.InetAddress addr,
int port)
Creates a ServerAddress
|
ServerAddress(java.net.InetSocketAddress addr)
Creates a ServerAddress
|
ServerAddress(java.lang.String host)
Creates a ServerAddress with default port
|
ServerAddress(java.lang.String host,
int port)
Creates a ServerAddress
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
defaultHost()
Returns the default database host: "127.0.0.1"
|
static int |
defaultPort()
Returns the default database port: 27017
|
boolean |
equals(java.lang.Object o) |
java.lang.String |
getHost()
Gets the hostname
|
int |
getPort()
Gets the port number
|
java.net.InetSocketAddress |
getSocketAddress()
Gets the underlying socket address
|
int |
hashCode() |
boolean |
sameHost(java.lang.String host)
Determines whether this address is the same as a given host.
|
java.lang.String |
toString() |
public ServerAddress() throws java.net.UnknownHostException
java.net.UnknownHostException
- This exception is no longer thrown, but leaving in throws clause so as not to break source
compatibility. The exception will be removed from the declaration in the next major release of the
driver.public ServerAddress(java.lang.String host) throws java.net.UnknownHostException
host
- hostnamejava.net.UnknownHostException
- This exception is no longer thrown, but leaving in throws clause so as not to break source
compatibility. The exception will be removed from the declaration in the next major release of the
driver.public ServerAddress(java.lang.String host, int port) throws java.net.UnknownHostException
host
- hostnameport
- mongod portjava.net.UnknownHostException
- This exception is no longer thrown, but leaving in throws clause so as not to break source
compatibility. The exception will be removed from the declaration in the next major release of the
driver.public ServerAddress(java.net.InetAddress addr)
addr
- host addresspublic ServerAddress(java.net.InetAddress addr, int port)
addr
- host addressport
- mongod portpublic ServerAddress(java.net.InetSocketAddress addr)
addr
- inet socket address containing hostname and portpublic boolean sameHost(java.lang.String host)
host
- the address to comparepublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String getHost()
public int getPort()
public java.net.InetSocketAddress getSocketAddress() throws java.net.UnknownHostException
java.net.UnknownHostException
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String defaultHost()
public static int defaultPort()