|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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 ApplicationContext |
applicationContext
|
static java.lang.String |
CUSTOM_TYPE_KEY
|
protected static Log |
log
|
protected |
mappingContext
|
protected MongoDbFactory |
mongoDbFactory
|
protected SpelExpressionParser |
spelExpressionParser
|
protected boolean |
useFieldAccessOnly
|
private static java.util.List<java.lang.Class<?>> |
VALID_ID_TYPES
|
Fields inherited from class org.springframework.data.document.mongodb.convert.AbstractMongoConverter |
---|
conversionService |
Constructor Summary | |
---|---|
MappingMongoConverter(MongoDbFactory mongoDbFactory,
Creates a new MappingMongoConverter given the new MongoDbFactory and MappingContext . |
Method Summary | ||
---|---|---|
void |
addCustomTypeKeyIfNecessary(
Adds custom type information to the given DBObject if necessary. |
|
ObjectId |
convertObjectId(java.lang.Object id)
Returns the ObjectId instance for the given id. |
|
|
convertObjectId(ObjectId id,
java.lang.Class<T> targetType)
Converts the given ObjectId to the given target type. |
|
protected DBRef |
createDBRef(java.lang.Object target,
DBRef dbref)
|
|
protected java.lang.Class<?> |
findTypeToBeUsed(DBObject dbObject)
Returns the type to be used to convert the DBObject given to. |
|
|
getMappingContext()
|
|
private
|
getMoreConcreteTargetType(DBObject dbObject,
Inspects the a custom class definition stored inside the given DBObject and returns that in case it's a
subtype of the given basic one. |
|
protected java.lang.Object |
getValueInternal(MongoPersistentProperty prop,
DBObject dbo,
StandardEvaluationContext ctx,
java.lang.String spelExpr)
|
|
|
getValueType(
Returns the type type information of the actual value to be stored. |
|
boolean |
isUseFieldAccessOnly()
|
|
protected
|
read(
Ready from the native MongoDB DBObject representation to an instance of the class T. |
|
|
read(java.lang.Class<S> clazz,
DBObject dbo)
Ready from the native MongoDB DBObject representation to an instance of the class T. |
|
private
|
read(MongoPersistentEntity<S> entity,
DBObject dbo)
|
|
void |
setApplicationContext(ApplicationContext applicationContext)
|
|
void |
setMongoDbFactory(MongoDbFactory mongoDbFactory)
|
|
void |
setUseFieldAccessOnly(boolean useFieldAccessOnly)
|
|
protected
|
unwrapList(BasicDBList dbList,
|
|
void |
write(java.lang.Object obj,
DBObject dbo)
Root entry method into write conversion. |
|
protected DBObject |
writeCollectionInternal(MongoPersistentProperty property,
java.lang.Object obj)
|
|
protected void |
writeInternal(java.lang.Object obj,
DBObject dbo)
Internal write conversion method which should be used for nested invocations. |
|
protected void |
writeInternal(java.lang.Object obj,
DBObject dbo,
MongoPersistentEntity<?> entity)
|
|
protected void |
writeMapInternal(java.util.Map<java.lang.Object,java.lang.Object> obj,
DBObject dbo,
|
|
protected void |
writePropertyInternal(MongoPersistentProperty prop,
java.lang.Object obj,
DBObject dbo)
|
|
private void |
writeSimpleInternal(java.lang.String key,
java.lang.Object value,
DBObject dbObject)
Writes the given simple value to the given DBObject . |
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
private static final java.util.List<java.lang.Class<?>> VALID_ID_TYPES
protected static final Log log
protected finalmappingContext
protected final SpelExpressionParser spelExpressionParser
protected ApplicationContext applicationContext
protected boolean useFieldAccessOnly
protected MongoDbFactory mongoDbFactory
Constructor Detail |
---|
public MappingMongoConverter(MongoDbFactory mongoDbFactory,mappingContext)
MappingMongoConverter
given the new MongoDbFactory
and MappingContext
.
mongoDbFactory
- mappingContext
- Method Detail |
---|
publicgetMappingContext()
public void setMongoDbFactory(MongoDbFactory mongoDbFactory)
public boolean isUseFieldAccessOnly()
public void setUseFieldAccessOnly(boolean useFieldAccessOnly)
public <T> T convertObjectId(ObjectId id, java.lang.Class<T> targetType)
MongoConverter
ObjectId
to the given target type.
T
- the actual type to createid
- the source ObjectId
targetType
- the target type to convert the ObjectId
to
public ObjectId convertObjectId(java.lang.Object id)
MongoConverter
ObjectId
instance for the given id.
public <S> S read(java.lang.Class<S> clazz, 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.
clazz
- the type of the return valuedbo
- theDBObject
protected <S> S read(type, 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.
type
- the type of the return valuedbo
- theDBObject
private <S> S read(MongoPersistentEntity<S> entity, DBObject dbo)
public void write(java.lang.Object obj, DBObject dbo)
DBObject
. Shouldn't be called for
nested conversions.
obj
- The object to convert to a DBObjectdbo
- The DBObject to use for writing.org.springframework.data.document.mongodb.MongoWriter#write(java.lang.Object, com.mongodb.DBObject)
protected void writeInternal(java.lang.Object obj, DBObject dbo)
obj
- dbo
- protected void writeInternal(java.lang.Object obj, DBObject dbo, MongoPersistentEntity<?> entity)
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
BeansException
protected void writePropertyInternal(MongoPersistentProperty prop, java.lang.Object obj, DBObject dbo)
protected DBObject writeCollectionInternal(MongoPersistentProperty property, java.lang.Object obj)
protected void writeMapInternal(java.util.Map<java.lang.Object,java.lang.Object> obj, DBObject dbo,propertyType)
public void addCustomTypeKeyIfNecessary(type, java.lang.Object value, 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
- publicgetValueType( type)
type
-
private void writeSimpleInternal(java.lang.String key, java.lang.Object value, DBObject dbObject)
DBObject
. Will store enum names for enum values.
key
- value
- dbObject
- protected DBRef createDBRef(java.lang.Object target, DBRef dbref)
protected java.lang.Object getValueInternal(MongoPersistentProperty prop, DBObject dbo, StandardEvaluationContext ctx, java.lang.String spelExpr)
protected java.lang.Class<?> findTypeToBeUsed(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.private <S>getMoreConcreteTargetType(DBObject dbObject, basicType)
DBObject
and returns that in case it's a
subtype of the given basic one.
dbObject
- basicType
-
protected <T> java.util.List<?> unwrapList(BasicDBList dbList,targetType)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |