Package org.bson
Interface BSONCallback
-
- All Known Subinterfaces:
DBCallback
- All Known Implementing Classes:
BasicBSONCallback,DefaultDBCallback,EmptyBSONCallback,JSONCallback,LazyBSONCallback,LazyDBCallback
public interface BSONCallbackA callback interface for describing the structure of a BSON document. Implementations of this define how to turn BSON read from MongoDB into Java objects. See the BSON Spec.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description java.lang.ObjectarrayDone()Called the end of the array, and returns the completed array.voidarrayStart()Signals the start of a BSON array.voidarrayStart(java.lang.String name)Signals the start of a BSON array, with its field name.BSONCallbackcreateBSONCallback()Factory method for BSONCallbacks.java.lang.Objectget()Returns the finished top-level Document.voidgotBinary(java.lang.String name, byte type, byte[] data)Called when reading a field with aBsonType.BINARYvalue.voidgotBinaryArray(java.lang.String name, byte[] data)Deprecated.this method is no longer called by the decodervoidgotBoolean(java.lang.String name, boolean value)Called when reading a field with aBsonType.BOOLEANvalue.voidgotCode(java.lang.String name, java.lang.String code)Called when reading a field with aBsonType.JAVASCRIPTvalue.voidgotCodeWScope(java.lang.String name, java.lang.String code, java.lang.Object scope)Called when reading a field with aBsonType.JAVASCRIPT_WITH_SCOPEvalue.voidgotDate(java.lang.String name, long millis)Called when reading a field with aBsonType.DATE_TIMEvalue.voidgotDBRef(java.lang.String name, java.lang.String namespace, ObjectId id)Invoked whenBSONDecoderencountered aBsonType.DB_POINTERtype field in a byte sequence.voidgotDecimal128(java.lang.String name, Decimal128 value)Called when reading a field with aBsonType.DECIMAL128value.voidgotDouble(java.lang.String name, double value)Called when reading a field with aBsonType.DOUBLEvalue.voidgotInt(java.lang.String name, int value)Called when reading a field with aBsonType.INT32value.voidgotLong(java.lang.String name, long value)Called when reading a field with aBsonType.INT64value.voidgotMaxKey(java.lang.String name)Called when reading a field with aBsonType.MAX_KEYvalue.voidgotMinKey(java.lang.String name)Called when reading a field with aBsonType.MIN_KEYvalue.voidgotNull(java.lang.String name)Called when reading a BSON field that exists but has a null value.voidgotObjectId(java.lang.String name, ObjectId id)Called when reading a field with aBsonType.OBJECT_IDvalue.voidgotRegex(java.lang.String name, java.lang.String pattern, java.lang.String flags)Called when reading a field with aBsonType.REGULAR_EXPRESSIONvalue.voidgotString(java.lang.String name, java.lang.String value)Called when reading a field with aBsonType.STRINGvalue.voidgotSymbol(java.lang.String name, java.lang.String value)Called when reading a field with aBsonType.SYMBOLvalue.voidgotTimestamp(java.lang.String name, int time, int increment)Called when reading a field with aBsonType.TIMESTAMPvalue.voidgotUndefined(java.lang.String name)Called when reading a field with aBsonType.UNDEFINEDvalue.voidgotUUID(java.lang.String name, long part1, long part2)Called when reading a field with aUUIDvalue.java.lang.ObjectobjectDone()Called at the end of the document/array, and returns this object.voidobjectStart()Signals the start of a BSON document, which usually maps onto some Java object.voidobjectStart(java.lang.String name)Signals the start of a BSON document, which usually maps onto some Java object.voidreset()Resets the callback, clearing all state.
-
-
-
Method Detail
-
objectStart
void objectStart()
Signals the start of a BSON document, which usually maps onto some Java object.
-
objectStart
void objectStart(java.lang.String name)
Signals the start of a BSON document, which usually maps onto some Java object.- Parameters:
name- the field name of the document.
-
objectDone
java.lang.Object objectDone()
Called at the end of the document/array, and returns this object.- Returns:
- the Object that has been read from this section of the document.
-
reset
void reset()
Resets the callback, clearing all state.
-
get
java.lang.Object get()
Returns the finished top-level Document.- Returns:
- the top level document read from the database.
-
createBSONCallback
BSONCallback createBSONCallback()
Factory method for BSONCallbacks.- Returns:
- a new BSONCallback.
-
arrayStart
void arrayStart()
Signals the start of a BSON array.
-
arrayStart
void arrayStart(java.lang.String name)
Signals the start of a BSON array, with its field name.- Parameters:
name- the name of this array field
-
arrayDone
java.lang.Object arrayDone()
Called the end of the array, and returns the completed array.- Returns:
- an Object representing the array that has been read from this section of the document.
-
gotNull
void gotNull(java.lang.String name)
Called when reading a BSON field that exists but has a null value.- Parameters:
name- the name of the field- See Also:
BsonType.NULL
-
gotUndefined
void gotUndefined(java.lang.String name)
Called when reading a field with aBsonType.UNDEFINEDvalue.- Parameters:
name- the name of the field- See Also:
BsonType.UNDEFINED
-
gotMinKey
void gotMinKey(java.lang.String name)
Called when reading a field with aBsonType.MIN_KEYvalue.- Parameters:
name- the name of the field
-
gotMaxKey
void gotMaxKey(java.lang.String name)
Called when reading a field with aBsonType.MAX_KEYvalue.- Parameters:
name- the name of the field
-
gotBoolean
void gotBoolean(java.lang.String name, boolean value)Called when reading a field with aBsonType.BOOLEANvalue.- Parameters:
name- the name of the fieldvalue- the field's value
-
gotDouble
void gotDouble(java.lang.String name, double value)Called when reading a field with aBsonType.DOUBLEvalue.- Parameters:
name- the name of the fieldvalue- the field's value
-
gotDecimal128
void gotDecimal128(java.lang.String name, Decimal128 value)Called when reading a field with aBsonType.DECIMAL128value.- Parameters:
name- the field namevalue- the Decimal128 field value- Since:
- 3.4
-
gotInt
void gotInt(java.lang.String name, int value)Called when reading a field with aBsonType.INT32value.- Parameters:
name- the name of the fieldvalue- the field's value
-
gotLong
void gotLong(java.lang.String name, long value)Called when reading a field with aBsonType.INT64value.- Parameters:
name- the name of the fieldvalue- the field's value
-
gotDate
void gotDate(java.lang.String name, long millis)Called when reading a field with aBsonType.DATE_TIMEvalue.- Parameters:
name- the name of the fieldmillis- the date and time in milliseconds
-
gotString
void gotString(java.lang.String name, java.lang.String value)Called when reading a field with aBsonType.STRINGvalue.- Parameters:
name- the name of the fieldvalue- the field's value
-
gotSymbol
void gotSymbol(java.lang.String name, java.lang.String value)Called when reading a field with aBsonType.SYMBOLvalue.- Parameters:
name- the name of the fieldvalue- the field's value
-
gotRegex
void gotRegex(java.lang.String name, java.lang.String pattern, java.lang.String flags)Called when reading a field with aBsonType.REGULAR_EXPRESSIONvalue.- Parameters:
name- the name of the fieldpattern- the regex patternflags- the optional flags for the regular expression
-
gotTimestamp
void gotTimestamp(java.lang.String name, int time, int increment)Called when reading a field with aBsonType.TIMESTAMPvalue.- Parameters:
name- the name of the fieldtime- the time in seconds since epochincrement- an incrementing ordinal for operations within a given second
-
gotObjectId
void gotObjectId(java.lang.String name, ObjectId id)Called when reading a field with aBsonType.OBJECT_IDvalue.- Parameters:
name- the name of the fieldid- the object ID
-
gotDBRef
void gotDBRef(java.lang.String name, java.lang.String namespace, ObjectId id)Invoked whenBSONDecoderencountered aBsonType.DB_POINTERtype field in a byte sequence.- 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
-
gotBinaryArray
@Deprecated void gotBinaryArray(java.lang.String name, byte[] data)Deprecated.this method is no longer called by the decoderThis method is not used.- Parameters:
name- the name of the fielddata- the field's value
-
gotBinary
void gotBinary(java.lang.String name, byte type, byte[] data)Called when reading a field with aBsonType.BINARYvalue. Note that binary values have a subtype, which may determine how the value is processed.- Parameters:
name- the name of the fieldtype- one of the binary subtypes:BsonBinarySubTypedata- the field's value
-
gotUUID
void gotUUID(java.lang.String name, long part1, long part2)Called when reading a field with aUUIDvalue. This is a binary value of subtypeBsonBinarySubType.UUID_LEGACY- Parameters:
name- the name of the fieldpart1- the first part of the UUIDpart2- the second part of the UUID
-
gotCode
void gotCode(java.lang.String name, java.lang.String code)Called when reading a field with aBsonType.JAVASCRIPTvalue.- Parameters:
name- the name of the fieldcode- the JavaScript code
-
gotCodeWScope
void gotCodeWScope(java.lang.String name, java.lang.String code, java.lang.Object scope)Called when reading a field with aBsonType.JAVASCRIPT_WITH_SCOPEvalue.- Parameters:
name- the name of the fieldcode- the JavaScript codescope- a document representing the scope for the code
-
-