public class

ServerAddress

extends Object
java.lang.Object
   ↳ com.mongodb.ServerAddress
Known Direct Subclasses

Class Overview

mongo server address

Summary

Public Constructors
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 addr)
Creates a ServerAddress with default port
ServerAddress(InetAddress addr, int port)
Creates a ServerAddress
ServerAddress(InetSocketAddress addr)
Creates a ServerAddress
Public Methods
static String defaultHost()
Returns the default database host: db_ip environment variable, or "127.0.0.1"
static int defaultPort()
Returns the default database port: db_port environment variable, or 27017 as a default
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()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ServerAddress ()

Creates a ServerAddress with default host and port

public ServerAddress (String host)

Creates a ServerAddress with default port

Parameters
host hostname

public ServerAddress (String host, int port)

Creates a ServerAddress

Parameters
host hostname
port mongod port

public ServerAddress (InetAddress addr)

Creates a ServerAddress with default port

Parameters
addr host address

public ServerAddress (InetAddress addr, int port)

Creates a ServerAddress

Parameters
addr host address
port mongod port

public ServerAddress (InetSocketAddress addr)

Creates a ServerAddress

Parameters
addr inet socket address containing hostname and port

Public Methods

public static String defaultHost ()

Returns the default database host: db_ip environment variable, or "127.0.0.1"

public static int defaultPort ()

Returns the default database port: db_port environment variable, or 27017 as a default

public boolean equals (Object other)

public String getHost ()

Gets the hostname

public int getPort ()

Gets the port number

public InetSocketAddress getSocketAddress ()

Gets the underlying socket address

public int hashCode ()

public boolean sameHost (String host)

Determines whether this address is the same as a given host.

Parameters
host the address to compare
Returns
  • if they are the same

public String toString ()