Package com.mongodb
Class DefaultDBCallback
- java.lang.Object
-
- org.bson.BasicBSONCallback
-
- com.mongodb.DefaultDBCallback
-
- All Implemented Interfaces:
DBCallback
,BSONCallback
public class DefaultDBCallback extends BasicBSONCallback implements DBCallback
An implementation of DBCallback that decodes into a DBObject.
-
-
Field Summary
Fields Modifier and Type Field Description static DBCallbackFactory
FACTORY
-
Constructor Summary
Constructors Constructor Description DefaultDBCallback(DBCollection collection)
Creates a new DefaultDBCallback.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BSONObject
create()
Factory method for creating a new BSONObject.BSONObject
create(boolean array, List<String> path)
Helper method to create either a BSON Object or a BSON List depending upon whether thearray
parameter is true or not.void
gotDBRef(String name, String namespace, ObjectId id)
Invoked whenBSONDecoder
encountered aBsonType.DB_POINTER
type field in a byte sequence.Object
objectDone()
Called at the end of the document/array, and returns this object.-
Methods inherited from class org.bson.BasicBSONCallback
_put, arrayDone, arrayStart, arrayStart, createBSONCallback, createList, cur, curName, get, gotBinary, gotBinaryArray, gotBoolean, gotCode, gotCodeWScope, gotDate, gotDecimal128, gotDouble, gotInt, gotLong, gotMaxKey, gotMinKey, gotNull, gotObjectId, gotRegex, gotString, gotSymbol, gotTimestamp, gotUndefined, gotUUID, isStackEmpty, objectStart, objectStart, reset, setRoot
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bson.BSONCallback
arrayDone, arrayStart, arrayStart, createBSONCallback, get, gotBinary, gotBinaryArray, gotBoolean, gotCode, gotCodeWScope, gotDate, gotDecimal128, gotDouble, gotInt, gotLong, gotMaxKey, gotMinKey, gotNull, gotObjectId, gotRegex, gotString, gotSymbol, gotTimestamp, gotUndefined, gotUUID, objectStart, objectStart, reset
-
-
-
-
Field Detail
-
FACTORY
public static final DBCallbackFactory FACTORY
-
-
Constructor Detail
-
DefaultDBCallback
public DefaultDBCallback(DBCollection collection)
Creates a new DefaultDBCallback. If the Collection is null, it usesDBCollectionObjectFactory
to create documents, otherwise it uses the collection's object factory.- Parameters:
collection
- an optionally null Collection that the documents created by this callback belong to.
-
-
Method Detail
-
create
public BSONObject create()
Description copied from class:BasicBSONCallback
Factory method for creating a new BSONObject.- Overrides:
create
in classBasicBSONCallback
- Returns:
- a new BasicBSONObject.
-
create
public BSONObject create(boolean array, List<String> path)
Description copied from class:BasicBSONCallback
Helper method to create either a BSON Object or a BSON List depending upon whether thearray
parameter is true or not.- Overrides:
create
in classBasicBSONCallback
- Parameters:
array
- set to true to create a new BSON List, otherwise will create a new BSONObjectpath
- a list of field names to navigate to this field in the document- Returns:
- the new BSONObject
-
gotDBRef
public void gotDBRef(String name, String namespace, ObjectId id)
Description copied from interface:BSONCallback
Invoked whenBSONDecoder
encountered aBsonType.DB_POINTER
type field in a byte sequence.- Specified by:
gotDBRef
in interfaceBSONCallback
- Overrides:
gotDBRef
in classBasicBSONCallback
- Parameters:
name
- the name of the fieldnamespace
- the namespace to which reference is pointing toid
- the if of the object to which reference is pointing to
-
objectDone
public Object objectDone()
Description copied from interface:BSONCallback
Called at the end of the document/array, and returns this object.- Specified by:
objectDone
in interfaceBSONCallback
- Overrides:
objectDone
in classBasicBSONCallback
- Returns:
- the Object that has been read from this section of the document.
-
-