com.mongodb
Class ServerAddress

java.lang.Object
  extended by com.mongodb.ServerAddress
Direct Known Subclasses:
DBAddress

public class ServerAddress
extends Object

mongo server address


Constructor Summary
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
 
Method Summary
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()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServerAddress

public ServerAddress()
              throws UnknownHostException
Creates a ServerAddress with default host and port

Throws:
UnknownHostException

ServerAddress

public ServerAddress(String host)
              throws UnknownHostException
Creates a ServerAddress with default port

Parameters:
host - hostname
Throws:
UnknownHostException

ServerAddress

public ServerAddress(String host,
                     int port)
              throws UnknownHostException
Creates a ServerAddress

Parameters:
host - hostname
port - mongod port
Throws:
UnknownHostException

ServerAddress

public ServerAddress(InetAddress addr)
Creates a ServerAddress with default port

Parameters:
addr - host address

ServerAddress

public ServerAddress(InetAddress addr,
                     int port)
Creates a ServerAddress

Parameters:
addr - host address
port - mongod port

ServerAddress

public ServerAddress(InetSocketAddress addr)
Creates a ServerAddress

Parameters:
addr - inet socket address containing hostname and port
Method Detail

sameHost

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

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getHost

public String getHost()
Gets the hostname

Returns:
hostname

getPort

public int getPort()
Gets the port number

Returns:
port

getSocketAddress

public InetSocketAddress getSocketAddress()
Gets the underlying socket address

Returns:
socket address

toString

public String toString()
Overrides:
toString in class Object

defaultHost

public static String 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