Spring Data MongoDB - Core

org.springframework.data.mongodb.core.convert
Class QueryMapper

java.lang.Object
  extended by org.springframework.data.mongodb.core.convert.QueryMapper
Direct Known Subclasses:
UpdateMapper

public class QueryMapper
extends Object

A helper class to encapsulate any modifications of a Query object before it gets submitted to the database.

Author:
Jon Brisbin, Oliver Gierke, Patryk Wasik

Constructor Summary
QueryMapper(MongoConverter converter)
          Creates a new QueryMapper with the given MongoConverter.
 
Method Summary
 Object convertId(Object id)
          Converts the given raw id value into either ObjectId or String.
protected  Object delegateConvertToMongoType(Object source, MongoPersistentEntity<?> entity)
          Converts the given source Object to a mongo type with the type information of the original source type omitted.
 com.mongodb.DBObject getMappedObject(com.mongodb.DBObject query, MongoPersistentEntity<?> entity)
          Replaces the property keys used in the given DBObject with the appropriate keys by using the PersistentEntity metadata.
protected  boolean isKeyword(String candidate)
          Returns whether the given String is a MongoDB keyword.
protected  boolean isNestedKeyword(Object candidate)
          Returns whether the given Object is a keyword, i.e. if it's a DBObject with a keyword key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryMapper

public QueryMapper(MongoConverter converter)
Creates a new QueryMapper with the given MongoConverter.

Parameters:
converter - must not be null.
Method Detail

getMappedObject

public com.mongodb.DBObject getMappedObject(com.mongodb.DBObject query,
                                            MongoPersistentEntity<?> entity)
Replaces the property keys used in the given DBObject with the appropriate keys by using the PersistentEntity metadata.

Parameters:
query - must not be null.
entity - can be null.
Returns:

delegateConvertToMongoType

protected Object delegateConvertToMongoType(Object source,
                                            MongoPersistentEntity<?> entity)
Converts the given source Object to a mongo type with the type information of the original source type omitted. Subclasses may overwrite this method to retain the type information of the source type on the resulting mongo type.

Parameters:
source -
entity -
Returns:
the converted mongo type or null if source is null

convertId

public Object convertId(Object id)
Converts the given raw id value into either ObjectId or String.

Parameters:
id -
Returns:

isNestedKeyword

protected boolean isNestedKeyword(Object candidate)
Returns whether the given Object is a keyword, i.e. if it's a DBObject with a keyword key.

Parameters:
candidate -
Returns:

isKeyword

protected boolean isKeyword(String candidate)
Returns whether the given String is a MongoDB keyword. The default implementation will check against the set of registered keywords returned by #getKeywords().

Parameters:
candidate -
Returns:

Spring Data MongoDB - Core

Copyright © 2011-2013-2013 Pivotal. All Rights Reserved.