Constructor and Description |
---|
ServerAddress()
Creates a ServerAddress with default host and port
|
ServerAddress(InetAddress addr)
Creates a ServerAddress with default port
|
ServerAddress(InetAddress addr,
int port)
Creates a ServerAddress
|
ServerAddress(InetSocketAddress addr)
Creates a ServerAddress
|
ServerAddress(String host)
Creates a ServerAddress with default port
|
ServerAddress(String host,
int port)
Creates a ServerAddress
|
Modifier and Type | Method and Description |
---|---|
static String |
defaultHost()
Returns the default database host: "127.0.0.1"
|
static int |
defaultPort()
Returns the default database port: 27017
|
boolean |
equals(Object o) |
String |
getHost()
Gets the hostname
|
int |
getPort()
Gets the port number
|
InetSocketAddress |
getSocketAddress()
Gets the underlying socket address
|
int |
hashCode() |
boolean |
sameHost(String host)
Determines whether this address is the same as a given host.
|
String |
toString() |
public ServerAddress() throws UnknownHostException
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(String host) throws UnknownHostException
host
- hostnameUnknownHostException
- 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(String host, int port) throws UnknownHostException
host
- hostnameport
- mongod portUnknownHostException
- 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(InetAddress addr)
addr
- host addresspublic ServerAddress(InetAddress addr, int port)
addr
- host addressport
- mongod portpublic ServerAddress(InetSocketAddress addr)
addr
- inet socket address containing hostname and portpublic boolean sameHost(String host)
host
- the address to comparepublic String getHost()
public int getPort()
public InetSocketAddress getSocketAddress() throws UnknownHostException
UnknownHostException
public static String defaultHost()
public static int defaultPort()