Package com.mongodb
Class MongoNamespace
-
- com.mongodb.MongoNamespace
-
@Immutable public final class MongoNamespace extends
A MongoDB namespace, which includes a database name and collection name.- Since:
- 3.0
-
-
Field Summary
Fields Modifier and Type Field Description static
COMMAND_COLLECTION_NAME
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
collectionName)
Check the validity of the given collection name.static void
databaseName)
Check the validity of the given database name.boolean
o)
getCollectionName()
Gets the collection name.getDatabaseName()
Gets the database name.getFullName()
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 Detail
-
COMMAND_COLLECTION_NAME
public static final COMMAND_COLLECTION_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MongoNamespace
public MongoNamespace( fullName)
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:
checkDatabaseNameValidity(String)
,checkCollectionNameValidity(String)
-
MongoNamespace
public MongoNamespace(@BsonProperty("db") databaseName, @BsonProperty("coll") collectionName)
Construct an instance from the given database name and collection name.- Parameters:
databaseName
- the valid database namecollectionName
- the valid collection name- See Also:
checkDatabaseNameValidity(String)
,checkCollectionNameValidity(String)
-
-
Method Detail
-
checkDatabaseNameValidity
public static void checkDatabaseNameValidity( databaseName)
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:
- if the database name is invalid
- Since:
- 3.4
- MongoDB documentation
-
checkCollectionNameValidity
public static void checkCollectionNameValidity( collectionName)
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:
- if the collection name is invalid
- Since:
- 3.4
- MongoDB documentation
-
getDatabaseName
@BsonProperty("db") public getDatabaseName()
Gets the database name.- Returns:
- the database name
-
getCollectionName
@BsonProperty("coll") public getCollectionName()
Gets the collection name.- Returns:
- the collection name
-
getFullName
public getFullName()
Gets the full name, which is the database name and the collection name, separated by a period.- Returns:
- the full name
-
equals
public boolean equals( o)
- Overrides:
in class
-
toString
public toString()
Returns the standard MongoDB representation of a namespace, which is<database>.<collection>
.- Overrides:
in class
- Returns:
- string representation of the namespace.
-
hashCode
public int hashCode()
- Overrides:
in class
-
-