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 other) |
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
public ServerAddress(String host) throws UnknownHostException
host
- hostnameUnknownHostException
public ServerAddress(String host, int port) throws UnknownHostException
host
- hostnameport
- mongod portUnknownHostException
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()
public static String defaultHost()
public static int defaultPort()