Package org.bson
Interface BSONCallback
-
- All Known Subinterfaces:
DBCallback
- All Known Implementing Classes:
BasicBSONCallback
,DefaultDBCallback
,EmptyBSONCallback
,JSONCallback
,LazyBSONCallback
,LazyDBCallback
public interface BSONCallback
A 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 .
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description arrayDone()
Called the end of the array, and returns the completed array.void
arrayStart()
Signals the start of a BSON array.void
name)
Signals the start of a BSON array, with its field name.BSONCallback
createBSONCallback()
Factory method for BSONCallbacks.get()
Returns the finished top-level Document.void
name, byte type, byte[] data)
Called when reading a field with aBsonType.BINARY
value.void
name, byte[] data)
Deprecated.this method is no longer called by the decodervoid
name, boolean value)
Called when reading a field with aBsonType.BOOLEAN
value.void
name, code)
Called when reading a field with aBsonType.JAVASCRIPT
value.void
name, code, scope)
Called when reading a field with aBsonType.JAVASCRIPT_WITH_SCOPE
value.void
name, long millis)
Called when reading a field with aBsonType.DATE_TIME
value.void
name, namespace, ObjectId id)
Invoked whenBSONDecoder
encountered aBsonType.DB_POINTER
type field in a byte sequence.void
name, Decimal128 value)
Called when reading a field with aBsonType.DECIMAL128
value.void
name, double value)
Called when reading a field with aBsonType.DOUBLE
value.void
name, int value)
Called when reading a field with aBsonType.INT32
value.void
name, long value)
Called when reading a field with aBsonType.INT64
value.void
name)
Called when reading a field with aBsonType.MAX_KEY
value.void
name)
Called when reading a field with aBsonType.MIN_KEY
value.void
name)
Called when reading a BSON field that exists but has a null value.void
name, ObjectId id)
Called when reading a field with aBsonType.OBJECT_ID
value.void
name, pattern, flags)
Called when reading a field with aBsonType.REGULAR_EXPRESSION
value.void
name, value)
Called when reading a field with aBsonType.STRING
value.void
name, value)
Called when reading a field with aBsonType.SYMBOL
value.void
name, int time, int increment)
Called when reading a field with aBsonType.TIMESTAMP
value.void
name)
Called when reading a field with aBsonType.UNDEFINED
value.void
name, long part1, long part2)
Called when reading a field with a value.objectDone()
Called at the end of the document/array, and returns this object.void
objectStart()
Signals the start of a BSON document, which usually maps onto some Java object.void
name)
Signals the start of a BSON document, which usually maps onto some Java object.void
reset()
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.- MongoDB documentation
-
objectStart
void objectStart( name)
Signals the start of a BSON document, which usually maps onto some Java object.- Parameters:
name
- the field name of the document.- MongoDB documentation
-
objectDone
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
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.- MongoDB documentation
-
arrayStart
void arrayStart( name)
Signals the start of a BSON array, with its field name.- Parameters:
name
- the name of this array field- MongoDB documentation
-
arrayDone
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( 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( name)
Called when reading a field with aBsonType.UNDEFINED
value.- Parameters:
name
- the name of the field- See Also:
BsonType.UNDEFINED
-
gotMinKey
void gotMinKey( name)
Called when reading a field with aBsonType.MIN_KEY
value.- Parameters:
name
- the name of the field
-
gotMaxKey
void gotMaxKey( name)
Called when reading a field with aBsonType.MAX_KEY
value.- Parameters:
name
- the name of the field
-
gotBoolean
void gotBoolean( name, boolean value)
Called when reading a field with aBsonType.BOOLEAN
value.- Parameters:
name
- the name of the fieldvalue
- the field's value
-
gotDouble
void gotDouble( name, double value)
Called when reading a field with aBsonType.DOUBLE
value.- Parameters:
name
- the name of the fieldvalue
- the field's value
-
gotDecimal128
void gotDecimal128( name, Decimal128 value)
Called when reading a field with aBsonType.DECIMAL128
value.- Parameters:
name
- the field namevalue
- the Decimal128 field value- Since:
- 3.4
- Since server release
-
gotInt
void gotInt( name, int value)
Called when reading a field with aBsonType.INT32
value.- Parameters:
name
- the name of the fieldvalue
- the field's value
-
gotLong
void gotLong( name, long value)
Called when reading a field with aBsonType.INT64
value.- Parameters:
name
- the name of the fieldvalue
- the field's value
-
gotDate
void gotDate( name, long millis)
Called when reading a field with aBsonType.DATE_TIME
value.- Parameters:
name
- the name of the fieldmillis
- the date and time in milliseconds
-
gotString
void gotString( name, value)
Called when reading a field with aBsonType.STRING
value.- Parameters:
name
- the name of the fieldvalue
- the field's value
-
gotSymbol
void gotSymbol( name, value)
Called when reading a field with aBsonType.SYMBOL
value.- Parameters:
name
- the name of the fieldvalue
- the field's value
-
gotRegex
void gotRegex( name, pattern, flags)
Called when reading a field with aBsonType.REGULAR_EXPRESSION
value.- Parameters:
name
- the name of the fieldpattern
- the regex patternflags
- the optional flags for the regular expression- MongoDB documentation
-
gotTimestamp
void gotTimestamp( name, int time, int increment)
Called when reading a field with aBsonType.TIMESTAMP
value.- Parameters:
name
- the name of the fieldtime
- the time in seconds since epochincrement
- an incrementing ordinal for operations within a given second- MongoDB documentation
-
gotObjectId
void gotObjectId( name, ObjectId id)
Called when reading a field with aBsonType.OBJECT_ID
value.- Parameters:
name
- the name of the fieldid
- the object ID
-
gotDBRef
void gotDBRef( name, namespace, ObjectId id)
Invoked whenBSONDecoder
encountered aBsonType.DB_POINTER
type 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
void gotBinaryArray( 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( name, byte type, byte[] data)
Called when reading a field with aBsonType.BINARY
value. 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:BsonBinarySubType
data
- the field's value
-
gotUUID
void gotUUID( name, long part1, long part2)
Called when reading a field with a value. 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( name, code)
Called when reading a field with aBsonType.JAVASCRIPT
value.- Parameters:
name
- the name of the fieldcode
- the JavaScript code
-
gotCodeWScope
void gotCodeWScope( name, code, scope)
Called when reading a field with aBsonType.JAVASCRIPT_WITH_SCOPE
value.- Parameters:
name
- the name of the fieldcode
- the JavaScript codescope
- a document representing the scope for the code
-
-