Package com.mongodb
Class ServerAddress
-
- com.mongodb.ServerAddress
-
- All Implemented Interfaces:
- Direct Known Subclasses:
DBAddress
,UnixServerAddress
@Immutable public class ServerAddress extends implements
Represents the location of a Mongo server - i.e. server name and port number- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ServerAddress()
Creates a ServerAddress with default host and porthost)
Creates a ServerAddress with default porthost, int port)
Creates a ServerAddressinetAddress)
Creates a ServerAddress with default portinetAddress, int port)
Creates a ServerAddressinetSocketAddress)
Creates a ServerAddress
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static
defaultHost()
Returns the default database host: "127.0.0.1"static int
defaultPort()
Returns the default database port: 27017boolean
o)
getHost()
Gets the hostnameint
getPort()
Gets the port numbergetSocketAddress()
Gets the underlying socket address<>
getSocketAddresses()
Gets all underlying socket addressesint
hashCode()
boolean
hostName)
Deprecated.use theequals(Object)
method insteadtoString()
-
-
-
Constructor Detail
-
ServerAddress
public ServerAddress()
Creates a ServerAddress with default host and port
-
ServerAddress
public ServerAddress(@Nullable host)
Creates a ServerAddress with default port- Parameters:
host
- hostname
-
ServerAddress
public ServerAddress( inetAddress)
Creates a ServerAddress with default port- Parameters:
inetAddress
- host address
-
ServerAddress
public ServerAddress( inetAddress, int port)
Creates a ServerAddress- Parameters:
inetAddress
- host addressport
- mongod port
-
ServerAddress
public ServerAddress( inetSocketAddress)
Creates a ServerAddress- Parameters:
inetSocketAddress
- inet socket address containing hostname and port
-
ServerAddress
public ServerAddress(@Nullable host, int port)
Creates a ServerAddress- Parameters:
host
- hostnameport
- mongod port
-
-
Method Detail
-
equals
public boolean equals( o)
- Overrides:
in class
-
hashCode
public int hashCode()
- Overrides:
in class
-
getHost
public getHost()
Gets the hostname- Returns:
- hostname
-
getPort
public int getPort()
Gets the port number- Returns:
- port
-
getSocketAddress
public getSocketAddress()
Gets the underlying socket address- Returns:
- socket address
-
getSocketAddresses
public <> getSocketAddresses()
Gets all underlying socket addresses- Returns:
- array of socket addresses
- Since:
- 3.9
-
toString
public toString()
- Overrides:
in class
-
defaultHost
public static defaultHost()
Returns the default database host: "127.0.0.1"- Returns:
- IP address of default host.
-
defaultPort
public static int defaultPort()
Returns the default database port: 27017- Returns:
- the default port
-
sameHost
public boolean sameHost( hostName)
Deprecated.use theequals(Object)
method insteadDetermines whether this address is the same as a given host.- Parameters:
hostName
- the address to compare- Returns:
- if they are the same
-
-