public class MongoDatabaseImpl extends Object implements MongoDatabase
MongoDatabase
interface.Modifier and Type | Field and Description |
---|---|
static Document |
EMPTY_QUERY
An empty query document.
|
protected Client |
myClient
The client for interacting with MongoDB.
|
ADMIN_NAME, CONFIG_NAME, LOCAL_NAME, TEST_NAME
Constructor and Description |
---|
MongoDatabaseImpl(Client client,
String name)
Create a new MongoDatabaseClient.
|
Modifier and Type | Method and Description |
---|---|
boolean |
drop()
Drops the database.
|
MongoCollection |
getCollection(String name)
Returns the MongoCollection with the specified name.
|
String |
getName()
Returns the name of the database.
|
List<String> |
listCollections()
Returns the list of the collections contained within the database.
|
Document |
runAdminCommand(String command)
Runs an administrative command against the 'admin' database.
|
Document |
runAdminCommand(String command,
DocumentAssignable options)
Runs an administrative command against the 'admin' database.
|
Document |
runAdminCommand(String commandName,
String commandValue,
DocumentAssignable options)
Runs an administrative command against the 'admin' database.
|
Document |
runCommand(String command)
Runs a command against the database.
|
Document |
runCommand(String command,
DocumentAssignable options)
Runs a command against the database.
|
Document |
runCommand(String commandName,
String commandValue,
DocumentAssignable options)
Runs a command against the database.
|
void |
runCommandAsync(Callback<Document> reply,
String command)
Runs a command against the database.
|
void |
runCommandAsync(Callback<Document> reply,
String command,
DocumentAssignable options)
Runs a command against the database.
|
void |
runCommandAsync(Callback<Document> reply,
String commandName,
String commandValue,
DocumentAssignable options)
Runs a command against the database.
|
Future<Document> |
runCommandAsync(String command)
Runs a command against the database.
|
Future<Document> |
runCommandAsync(String command,
DocumentAssignable options)
Runs a command against the database.
|
Future<Document> |
runCommandAsync(String commandName,
String commandValue,
DocumentAssignable options)
Runs a command against the database.
|
public static final Document EMPTY_QUERY
protected final Client myClient
public boolean drop()
Overridden to issue a "dropDatabase" command.
drop
in interface MongoDatabase
MongoDatabase.drop()
public MongoCollection getCollection(String name)
Overridden to create a new MongoCollectionImpl
.
getCollection
in interface MongoDatabase
name
- The name of the collection.MongoCollection
.MongoDatabase.getCollection(String)
public String getName()
getName
in interface MongoDatabase
public List<String> listCollections()
Overridden to query the system.namespace collection for the names of all of the collections.
listCollections
in interface MongoDatabase
MongoDatabase.listCollections()
public Document runAdminCommand(String command) throws MongoDbException
Overridden to call runCommand(String)
on the 'admin' database.
runAdminCommand
in interface MongoDatabase
command
- The name of the command to run.MongoDbException
- On an error issuing the command or in running the commandrunCommandAsync(String, DocumentAssignable)
public Document runAdminCommand(String command, DocumentAssignable options) throws MongoDbException
Overridden to call the
runCommandAsync(String, DocumentAssignable)
method.
runAdminCommand
in interface MongoDatabase
command
- The name of the command to run.options
- Optional (may be null) options for the command.MongoDbException
- On an error issuing the command or in running the commandrunCommandAsync(String, DocumentAssignable)
public Document runAdminCommand(String commandName, String commandValue, DocumentAssignable options) throws MongoDbException
Overridden to call the
runCommandAsync(String, String, DocumentAssignable)
method.
runAdminCommand
in interface MongoDatabase
commandName
- The name of the command to run.commandValue
- The name of the command to run.options
- Optional (may be null) options for the command.MongoDbException
- On an error issuing the command or in running the commandrunCommandAsync(String, String, DocumentAssignable)
public Document runCommand(String command) throws MongoDbException
Overridden to call the
runCommandAsync(String, DocumentAssignable)
method with
null
options.
runCommand
in interface MongoDatabase
command
- The name of the command to run.MongoDbException
- On an error issuing the command or in running the commandrunCommandAsync(String, DocumentAssignable)
public Document runCommand(String command, DocumentAssignable options) throws MongoDbException
Overridden to call the
runCommandAsync(String, DocumentAssignable)
method.
runCommand
in interface MongoDatabase
command
- The name of the command to run.options
- Optional (may be null) options for the command.MongoDbException
- On an error issuing the command or in running the commandrunCommandAsync(String, DocumentAssignable)
public Document runCommand(String commandName, String commandValue, DocumentAssignable options) throws MongoDbException
Overridden to call the
runCommandAsync(String, String, DocumentAssignable)
method.
runCommand
in interface MongoDatabase
commandName
- The name of the command to run.commandValue
- The name of the command to run.options
- Optional (may be null) options for the command.MongoDbException
- On an error issuing the command or in running the commandrunCommandAsync(String, String, DocumentAssignable)
public void runCommandAsync(Callback<Document> reply, String command) throws MongoDbException
Overridden to call the
runCommandAsync(Callback, String, DocumentAssignable)
method
with null
for the options.
runCommandAsync
in interface MongoDatabase
reply
- Callback
that will be notified of the command results.command
- The name of the command to run.MongoDbException
- On an error issuing the command or in running the commandrunCommandAsync(Callback, String, DocumentAssignable)
public void runCommandAsync(Callback<Document> reply, String command, DocumentAssignable options) throws MongoDbException
Overridden to build a Command
message and send it to the server.
runCommandAsync
in interface MongoDatabase
reply
- Callback
that will be notified of the command results.command
- The name of the command to run.options
- Optional (may be null) options for the command.MongoDbException
- On an error issuing the command or in running the commandpublic void runCommandAsync(Callback<Document> reply, String commandName, String commandValue, DocumentAssignable options) throws MongoDbException
Overridden to build a Command
message and send it to the server.
runCommandAsync
in interface MongoDatabase
reply
- Callback
that will be notified of the command results.commandName
- The name of the command to run.commandValue
- The name of the command to run.options
- Optional (may be null) options for the command.MongoDbException
- On an error issuing the command or in running the commandpublic Future<Document> runCommandAsync(String command) throws MongoDbException
Overridden to call the
runCommandAsync(Callback, String, DocumentAssignable)
method
with null
options.
runCommandAsync
in interface MongoDatabase
command
- The name of the command to run.MongoDbException
- On an error issuing the command or in running the commandrunCommandAsync(Callback, String, DocumentAssignable)
public Future<Document> runCommandAsync(String command, DocumentAssignable options) throws MongoDbException
Overridden to call the
runCommandAsync(Callback, String, DocumentAssignable)
method.
runCommandAsync
in interface MongoDatabase
command
- The name of the command to run.options
- Optional (may be null) options for the command.MongoDbException
- On an error issuing the command or in running the commandrunCommandAsync(Callback, String, DocumentAssignable)
public Future<Document> runCommandAsync(String commandName, String commandValue, DocumentAssignable options) throws MongoDbException
Overridden to call the
runCommandAsync(Callback, String, String, DocumentAssignable)
method.
runCommandAsync
in interface MongoDatabase
commandName
- The name of the command to run.commandValue
- The name of the command to run.options
- Optional (may be null) options for the command.MongoDbException
- On an error issuing the command or in running the commandrunCommandAsync(Callback, String, String, DocumentAssignable)
Copyright © 2011-2012 Allanbank Consulting, Inc.. All Rights Reserved.