@Immutable public class ServerAddress extends Object implements Serializable
| Constructor and Description |
|---|
ServerAddress()
Creates a ServerAddress with default host and port
|
ServerAddress(InetAddress inetAddress)
Creates a ServerAddress with default port
|
ServerAddress(InetAddress inetAddress,
int port)
Creates a ServerAddress
|
ServerAddress(InetSocketAddress inetSocketAddress)
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 hostName)
Determines whether this address is the same as a given host.
|
String |
toString() |
public ServerAddress()
public ServerAddress(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 ServerAddress(String host, int port)
host - hostnameport - mongod portpublic String getHost()
public int getPort()
public InetSocketAddress getSocketAddress()
public static String defaultHost()
public static int defaultPort()
public boolean sameHost(String hostName)
hostName - the address to compare