public abstract class ReflectionDBObject extends java.lang.Object implements DBObject
Modifier and Type | Class and Description |
---|---|
static class |
ReflectionDBObject.JavaWrapper
Represents a wrapper around the DBObject to interface with the Class fields
|
Constructor and Description |
---|
ReflectionDBObject() |
Modifier and Type | Method and Description |
---|---|
boolean |
containsField(java.lang.String fieldName)
Checks if this object contains a field with the given name.
|
boolean |
containsKey(java.lang.String key)
Deprecated.
|
java.lang.Object |
get_id()
Gets the _id
|
java.lang.Object |
get(java.lang.String key)
Gets a field from this object by a given name.
|
static ReflectionDBObject.JavaWrapper |
getWrapper(java.lang.Class c)
Returns an existing Wrapper instance associated with a class, or creates a new one.
|
static ReflectionDBObject.JavaWrapper |
getWrapperIfReflectionObject(java.lang.Class c)
Returns the wrapper if this object can be assigned from this class.
|
boolean |
isPartialObject()
Whether
DBObject.markAsPartialObject() was ever called only matters if you are going to upsert and do not want to risk losing fields. |
java.util.Set<java.lang.String> |
keySet()
Returns this object's fields' names
|
void |
markAsPartialObject()
ReflectionDBObjects can't be partial.
|
java.lang.Object |
put(java.lang.String key,
java.lang.Object v)
Sets a name/value pair in this object.
|
void |
putAll(BSONObject o)
Sets all key/value pairs from an object into this object
|
void |
putAll(java.util.Map m)
Sets all key/value pairs from a map into this object
|
java.lang.Object |
removeField(java.lang.String key)
This operation is not supported.
|
void |
set_id(java.lang.Object id)
Sets the _id
|
java.util.Map |
toMap()
Returns a map representing this BSONObject.
|
public java.lang.Object get(java.lang.String key)
BSONObject
get
in interface BSONObject
key
- The name of the field fetchpublic java.util.Set<java.lang.String> keySet()
BSONObject
keySet
in interface BSONObject
@Deprecated public boolean containsKey(java.lang.String key)
BSONObject
containsKey
in interface BSONObject
key
- the key to checkpublic boolean containsField(java.lang.String fieldName)
BSONObject
containsField
in interface BSONObject
fieldName
- Field name for which to checkpublic java.lang.Object put(java.lang.String key, java.lang.Object v)
BSONObject
put
in interface BSONObject
key
- Name to setv
- Corresponding valuepublic void putAll(java.util.Map m)
BSONObject
putAll
in interface BSONObject
m
- the mappublic void putAll(BSONObject o)
BSONObject
putAll
in interface BSONObject
o
- the objectpublic java.lang.Object get_id()
public void set_id(java.lang.Object id)
id
- the unique identifier for this DBObjectpublic boolean isPartialObject()
DBObject
DBObject.markAsPartialObject()
was ever called only matters if you are going to upsert and do not want to risk losing fields.isPartialObject
in interface DBObject
public java.util.Map toMap()
BSONObject
toMap
in interface BSONObject
public void markAsPartialObject()
markAsPartialObject
in interface DBObject
java.lang.RuntimeException
- ReflectionDBObjects can't be partialpublic java.lang.Object removeField(java.lang.String key)
removeField
in interface BSONObject
key
- The name of the field to removejava.lang.UnsupportedOperationException
- can't remove from a ReflectionDBObjectpublic static ReflectionDBObject.JavaWrapper getWrapperIfReflectionObject(java.lang.Class c)
c
- the class to be wrappedpublic static ReflectionDBObject.JavaWrapper getWrapper(java.lang.Class c)
c
- the class to be wrapped