Serializable
DBAddress
, UnixServerAddress
@Immutable public class ServerAddress extends Object implements Serializable
Constructor | Description |
---|---|
ServerAddress() |
Creates a ServerAddress with default host and port
|
ServerAddress(String host) |
Creates a ServerAddress with default port
|
ServerAddress(String host,
int port) |
Creates a ServerAddress
|
ServerAddress(InetAddress inetAddress) |
Creates a ServerAddress with default port
|
ServerAddress(InetAddress inetAddress,
int port) |
Creates a ServerAddress
|
ServerAddress(InetSocketAddress inetSocketAddress) |
Creates a ServerAddress
|
Modifier and Type | Method | 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 hostName) |
Deprecated.
use the
equals(Object) method instead |
String |
toString() |
public ServerAddress()
public ServerAddress(@Nullable String host)
host
- hostnamepublic ServerAddress(InetAddress inetAddress)
inetAddress
- host addresspublic ServerAddress(InetAddress inetAddress, int port)
inetAddress
- host addressport
- mongod portpublic ServerAddress(InetSocketAddress inetSocketAddress)
inetSocketAddress
- inet socket address containing hostname and portpublic String getHost()
public int getPort()
public InetSocketAddress getSocketAddress()
public static String defaultHost()
public static int defaultPort()
@Deprecated public boolean sameHost(String hostName)
equals(Object)
method insteadhostName
- the address to compare