com.mongodb
Class MongoURI

java.lang.Object
  extended by com.mongodb.MongoURI

public class MongoURI
extends Object

Represents a URI which can be used to create a Mongo instance. The URI describes the hosts to be used and options.


Field Summary
static String MONGODB_PREFIX
           
 
Constructor Summary
MongoURI(String uri)
          Creates a MongoURI described by a String.
 
Method Summary
 Mongo connect()
          creates a Mongo instance based on the URI
 DBCollection connectCollection(DB db)
          returns the URI's Collection from a given DB object
 DBCollection connectCollection(Mongo m)
          returns the URI's Collection from a given Mongo instance
 DB connectDB()
          returns the DB object from a newly created Mongo instance based on this URI
 DB connectDB(Mongo m)
          returns the URI's DB object from a given Mongo instance
 String getCollection()
          Gets the collection name
 String getDatabase()
          Gets the database name
 List<String> getHosts()
          Gets the list of hosts
 MongoOptions getOptions()
          Gets the options
 char[] getPassword()
          Gets the password
 String getUsername()
          Gets the username
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MONGODB_PREFIX

public static final String MONGODB_PREFIX
See Also:
Constant Field Values
Constructor Detail

MongoURI

public MongoURI(String uri)
Creates a MongoURI described by a String. examples mongodb://127.0.0.1 mongodb://fred:foobar@127.0.0.1/

Parameters:
uri - the URI
MongoDB Doc Links
Method Detail

getUsername

public String getUsername()
Gets the username

Returns:

getPassword

public char[] getPassword()
Gets the password

Returns:

getHosts

public List<String> getHosts()
Gets the list of hosts

Returns:

getDatabase

public String getDatabase()
Gets the database name

Returns:

getCollection

public String getCollection()
Gets the collection name

Returns:

getOptions

public MongoOptions getOptions()
Gets the options

Returns:

connect

public Mongo connect()
              throws MongoException,
                     UnknownHostException
creates a Mongo instance based on the URI

Returns:
Throws:
MongoException
UnknownHostException

connectDB

public DB connectDB()
             throws MongoException,
                    UnknownHostException
returns the DB object from a newly created Mongo instance based on this URI

Returns:
Throws:
MongoException
UnknownHostException

connectDB

public DB connectDB(Mongo m)
returns the URI's DB object from a given Mongo instance

Parameters:
m -
Returns:

connectCollection

public DBCollection connectCollection(DB db)
returns the URI's Collection from a given DB object

Parameters:
db -
Returns:

connectCollection

public DBCollection connectCollection(Mongo m)
returns the URI's Collection from a given Mongo instance

Parameters:
m -
Returns:

toString

public String toString()
Overrides:
toString in class Object