|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.data.document.mongodb.convert.AbstractMongoConverter org.springframework.data.document.mongodb.convert.MappingMongoConverter
public class MappingMongoConverter
MongoConverter
that uses a MappingContext
to do sophisticated mapping of domain objects to
DBObject
.
Field Summary | |
---|---|
protected org.springframework.context.ApplicationContext |
applicationContext
|
static java.lang.String |
CUSTOM_TYPE_KEY
|
protected static org.apache.commons.logging.Log |
log
|
protected org.springframework.data.mapping.model.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> |
mappingContext
|
protected MongoDbFactory |
mongoDbFactory
|
protected org.springframework.expression.spel.standard.SpelExpressionParser |
spelExpressionParser
|
protected boolean |
useFieldAccessOnly
|
Fields inherited from class org.springframework.data.document.mongodb.convert.AbstractMongoConverter |
---|
conversionService |
Constructor Summary | |
---|---|
MappingMongoConverter(MongoDbFactory mongoDbFactory,
org.springframework.data.mapping.model.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> mappingContext)
Creates a new MappingMongoConverter given the new MongoDbFactory and MappingContext . |
Method Summary | ||
---|---|---|
void |
addCustomTypeKeyIfNecessary(org.springframework.data.util.TypeInformation<?> type,
java.lang.Object value,
com.mongodb.DBObject dbObject)
Adds custom type information to the given DBObject if necessary. |
|
org.bson.types.ObjectId |
convertObjectId(java.lang.Object id)
Returns the ObjectId instance for the given id. |
|
|
convertObjectId(org.bson.types.ObjectId id,
java.lang.Class<T> targetType)
Converts the given ObjectId to the given target type. |
|
protected com.mongodb.DBRef |
createDBRef(java.lang.Object target,
DBRef dbref)
|
|
protected java.lang.Class<?> |
findTypeToBeUsed(com.mongodb.DBObject dbObject)
Returns the type to be used to convert the DBObject given to. |
|
org.springframework.data.mapping.model.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> |
getMappingContext()
|
|
protected java.lang.Object |
getValueInternal(MongoPersistentProperty prop,
com.mongodb.DBObject dbo,
org.springframework.expression.spel.support.StandardEvaluationContext ctx,
java.lang.String spelExpr)
|
|
org.springframework.data.util.TypeInformation<?> |
getValueType(org.springframework.data.util.TypeInformation<?> type)
Returns the type type information of the actual value to be stored. |
|
boolean |
isUseFieldAccessOnly()
|
|
|
read(java.lang.Class<S> clazz,
com.mongodb.DBObject dbo)
Ready from the native MongoDB DBObject representation to an instance of the class T. |
|
protected
|
read(org.springframework.data.util.TypeInformation<S> type,
com.mongodb.DBObject dbo)
|
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
|
|
void |
setMongoDbFactory(MongoDbFactory mongoDbFactory)
|
|
void |
setUseFieldAccessOnly(boolean useFieldAccessOnly)
|
|
protected
|
unwrapList(com.mongodb.BasicDBList dbList,
org.springframework.data.util.TypeInformation<T> targetType)
|
|
void |
write(java.lang.Object obj,
com.mongodb.DBObject dbo)
Root entry method into write conversion. |
|
protected com.mongodb.DBObject |
writeCollectionInternal(MongoPersistentProperty property,
java.lang.Object obj)
|
|
protected void |
writeInternal(java.lang.Object obj,
com.mongodb.DBObject dbo)
Internal write conversion method which should be used for nested invocations. |
|
protected void |
writeInternal(java.lang.Object obj,
com.mongodb.DBObject dbo,
MongoPersistentEntity<?> entity)
|
|
protected void |
writeMapInternal(java.util.Map<java.lang.Object,java.lang.Object> obj,
com.mongodb.DBObject dbo,
org.springframework.data.util.TypeInformation<?> propertyType)
|
|
protected void |
writePropertyInternal(MongoPersistentProperty prop,
java.lang.Object obj,
com.mongodb.DBObject dbo)
|
Methods inherited from class org.springframework.data.document.mongodb.convert.AbstractMongoConverter |
---|
afterPropertiesSet, getConversionService, getCustomTarget, maybeConvertArray, maybeConvertList, maybeConvertObject, setCustomConverters |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CUSTOM_TYPE_KEY
protected static final org.apache.commons.logging.Log log
protected final org.springframework.data.mapping.model.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> mappingContext
protected final org.springframework.expression.spel.standard.SpelExpressionParser spelExpressionParser
protected org.springframework.context.ApplicationContext applicationContext
protected boolean useFieldAccessOnly
protected MongoDbFactory mongoDbFactory
Constructor Detail |
---|
public MappingMongoConverter(MongoDbFactory mongoDbFactory, org.springframework.data.mapping.model.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> mappingContext)
MappingMongoConverter
given the new MongoDbFactory
and MappingContext
.
mongoDbFactory
- mappingContext
- Method Detail |
---|
public org.springframework.data.mapping.model.MappingContext<? extends MongoPersistentEntity<?>,MongoPersistentProperty> getMappingContext()
getMappingContext
in interface MongoConverter
public void setMongoDbFactory(MongoDbFactory mongoDbFactory)
public boolean isUseFieldAccessOnly()
public void setUseFieldAccessOnly(boolean useFieldAccessOnly)
public <T> T convertObjectId(org.bson.types.ObjectId id, java.lang.Class<T> targetType)
MongoConverter
ObjectId
to the given target type.
convertObjectId
in interface MongoConverter
T
- the actual type to createid
- the source ObjectId
targetType
- the target type to convert the ObjectId
to
public org.bson.types.ObjectId convertObjectId(java.lang.Object id)
MongoConverter
ObjectId
instance for the given id.
convertObjectId
in interface MongoConverter
public <S> S read(java.lang.Class<S> clazz, com.mongodb.DBObject dbo)
MongoReader
DBObject
into it. So in case there's no real valid data inside
DBObject
for the given type, just return an empty instance of the given type.
read
in interface MongoReader<java.lang.Object>
clazz
- the type of the return valuedbo
- theDBObject
protected <S> S read(org.springframework.data.util.TypeInformation<S> type, com.mongodb.DBObject dbo)
public void write(java.lang.Object obj, com.mongodb.DBObject dbo)
DBObject
. Shouldn't be called for
nested conversions.
write
in interface MongoWriter<java.lang.Object>
obj
- The object to convert to a DBObjectdbo
- The DBObject to use for writing.MongoWriter.write(java.lang.Object, com.mongodb.DBObject)
protected void writeInternal(java.lang.Object obj, com.mongodb.DBObject dbo)
obj
- dbo
- protected void writeInternal(java.lang.Object obj, com.mongodb.DBObject dbo, MongoPersistentEntity<?> entity)
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
protected void writePropertyInternal(MongoPersistentProperty prop, java.lang.Object obj, com.mongodb.DBObject dbo)
protected com.mongodb.DBObject writeCollectionInternal(MongoPersistentProperty property, java.lang.Object obj)
protected void writeMapInternal(java.util.Map<java.lang.Object,java.lang.Object> obj, com.mongodb.DBObject dbo, org.springframework.data.util.TypeInformation<?> propertyType)
public void addCustomTypeKeyIfNecessary(org.springframework.data.util.TypeInformation<?> type, java.lang.Object value, com.mongodb.DBObject dbObject)
DBObject
if necessary. That is if the value is not the same as
the one given. This is usually the case if you store a subtype of the actual declared type of the property.
type
- value
- dbObject
- public org.springframework.data.util.TypeInformation<?> getValueType(org.springframework.data.util.TypeInformation<?> type)
type
-
protected com.mongodb.DBRef createDBRef(java.lang.Object target, DBRef dbref)
protected java.lang.Object getValueInternal(MongoPersistentProperty prop, com.mongodb.DBObject dbo, org.springframework.expression.spel.support.StandardEvaluationContext ctx, java.lang.String spelExpr)
protected java.lang.Class<?> findTypeToBeUsed(com.mongodb.DBObject dbObject)
DBObject
or the type hint found can't be converted into a Class
as the type might not
be available.
dbObject
-
DBObject
into or null if there's no type
found.protected <T> java.util.List<?> unwrapList(com.mongodb.BasicDBList dbList, org.springframework.data.util.TypeInformation<T> targetType)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |