Package com.mongodb
Class MongoNamespace
java.lang.Object
com.mongodb.MongoNamespace
A MongoDB namespace, which includes a database name and collection name.
- Since:
- 3.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The collection name in which to execute a command. -
Constructor Summary
ConstructorDescriptionMongoNamespace
(String fullName) Construct an instance for the given full name.MongoNamespace
(String databaseName, String collectionName) Construct an instance from the given database name and collection name. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkCollectionNameValidity
(String collectionName) Check the validity of the given collection name.static void
checkDatabaseNameValidity
(String databaseName) Check the validity of the given database name.boolean
Gets the collection name.Gets the database name.Gets the full name, which is the database name and the collection name, separated by a period.int
hashCode()
toString()
Returns the standard MongoDB representation of a namespace, which is<database>.<collection>
.
-
Field Details
-
COMMAND_COLLECTION_NAME
The collection name in which to execute a command.- See Also:
-
-
Constructor Details
-
MongoNamespace
Construct an instance for the given full name. The database name is the string preceding the first"."
character.- Parameters:
fullName
- the non-null full namespace- See Also:
-
MongoNamespace
public MongoNamespace(@BsonProperty("db") String databaseName, @BsonProperty("coll") String collectionName) Construct an instance from the given database name and collection name.- Parameters:
databaseName
- the valid database namecollectionName
- the valid collection name- See Also:
-
-
Method Details
-
checkDatabaseNameValidity
Check the validity of the given database name. A valid database name is non-null, non-empty, and does not contain any of the following characters:'\0', '/', '\\', ' ', '"', '.'
. The server may impose additional restrictions on database names.- Parameters:
databaseName
- the database name- Throws:
IllegalArgumentException
- if the database name is invalid- Since:
- 3.4
- MongoDB documentation
- Naming Restrictions
-
checkCollectionNameValidity
Check the validity of the given collection name. A valid collection name is non-null and non-empty. The server may impose additional restrictions on collection names.- Parameters:
collectionName
- the collection name- Throws:
IllegalArgumentException
- if the collection name is invalid- Since:
- 3.4
- MongoDB documentation
- Naming Restrictions
-
getDatabaseName
Gets the database name.- Returns:
- the database name
-
getCollectionName
Gets the collection name.- Returns:
- the collection name
-
getFullName
Gets the full name, which is the database name and the collection name, separated by a period.- Returns:
- the full name
-
equals
-
toString
Returns the standard MongoDB representation of a namespace, which is<database>.<collection>
. -
hashCode
public int hashCode()
-