Package org.bson
Class BasicBSONCallback
java.lang.Object
org.bson.BasicBSONCallback
- All Implemented Interfaces:
BSONCallback
An implementation of
BsonCallback that creates an instance of BSONObject.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidPuts a new value into the document.Called the end of the array, and returns the completed array.voidSignals the start of a BSON array.voidarrayStart(String name) Signals the start of a BSON array, with its field name.create()Factory method for creating a new BSONObject.Helper method to create either a BSON Object or a BSON List depending upon whether thearrayparameter is true or not.Factory method for BSONCallbacks.protected BSONObjectFactory method for creating a new BSON List.protected BSONObjectcur()Gets the current valueprotected StringcurName()Gets the name of the current fieldget()Returns the finished top-level Document.voidCalled when reading a field with aBsonType.BINARYvalue.voidgotBoolean(String name, boolean value) Called when reading a field with aBsonType.BOOLEANvalue.voidCalled when reading a field with aBsonType.JAVASCRIPTvalue.voidgotCodeWScope(String name, String code, Object scope) Called when reading a field with aBsonType.JAVASCRIPT_WITH_SCOPEvalue.voidCalled when reading a field with aBsonType.DATE_TIMEvalue.voidInvoked whenBSONDecoderencountered aBsonType.DB_POINTERtype field in a byte sequence.voidgotDecimal128(String name, Decimal128 value) Called when reading a field with aBsonType.DECIMAL128value.voidCalled when reading a field with aBsonType.DOUBLEvalue.voidCalled when reading a field with aBsonType.INT32value.voidCalled when reading a field with aBsonType.INT64value.voidCalled when reading a field with aBsonType.MAX_KEYvalue.voidCalled when reading a field with aBsonType.MIN_KEYvalue.voidCalled when reading a BSON field that exists but has a null value.voidgotObjectId(String name, ObjectId id) Called when reading a field with aBsonType.OBJECT_IDvalue.voidCalled when reading a field with aBsonType.REGULAR_EXPRESSIONvalue.voidCalled when reading a field with aBsonType.STRINGvalue.voidCalled when reading a field with aBsonType.SYMBOLvalue.voidgotTimestamp(String name, int time, int increment) Called when reading a field with aBsonType.TIMESTAMPvalue.voidgotUndefined(String name) Called when reading a field with aBsonType.UNDEFINEDvalue.voidCalled when reading a field with aUUIDvalue.protected booleanReturns whether this is the top level or notCalled at the end of the document/array, and returns this object.voidSignals the start of a BSON document, which usually maps onto some Java object.voidobjectStart(String name) Signals the start of a BSON document, which usually maps onto some Java object.voidreset()Resets the callback, clearing all state.protected voidSets the root document for this position
-
Constructor Details
-
BasicBSONCallback
public BasicBSONCallback()Creates a new instance.
-
-
Method Details
-
get
Description copied from interface:BSONCallbackReturns the finished top-level Document.- Specified by:
getin interfaceBSONCallback- Returns:
- the top level document read from the database.
-
create
Factory method for creating a new BSONObject.- Returns:
- a new BasicBSONObject.
-
createList
Factory method for creating a new BSON List.- Returns:
- a new BasicBSONList.
-
createBSONCallback
Description copied from interface:BSONCallbackFactory method for BSONCallbacks.- Specified by:
createBSONCallbackin interfaceBSONCallback- Returns:
- a new BSONCallback.
-
create
Helper method to create either a BSON Object or a BSON List depending upon whether thearrayparameter is true or not.- 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
-
objectStart
public void objectStart()Description copied from interface:BSONCallbackSignals the start of a BSON document, which usually maps onto some Java object.- Specified by:
objectStartin interfaceBSONCallback
-
objectStart
Description copied from interface:BSONCallbackSignals the start of a BSON document, which usually maps onto some Java object.- Specified by:
objectStartin interfaceBSONCallback- Parameters:
name- the field name of the document.
-
objectDone
Description copied from interface:BSONCallbackCalled at the end of the document/array, and returns this object.- Specified by:
objectDonein interfaceBSONCallback- Returns:
- the Object that has been read from this section of the document.
-
arrayStart
public void arrayStart()Description copied from interface:BSONCallbackSignals the start of a BSON array.- Specified by:
arrayStartin interfaceBSONCallback
-
arrayStart
Description copied from interface:BSONCallbackSignals the start of a BSON array, with its field name.- Specified by:
arrayStartin interfaceBSONCallback- Parameters:
name- the name of this array field
-
arrayDone
Description copied from interface:BSONCallbackCalled the end of the array, and returns the completed array.- Specified by:
arrayDonein interfaceBSONCallback- Returns:
- an Object representing the array that has been read from this section of the document.
-
gotNull
Description copied from interface:BSONCallbackCalled when reading a BSON field that exists but has a null value.- Specified by:
gotNullin interfaceBSONCallback- Parameters:
name- the name of the field- See Also:
-
gotUndefined
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.UNDEFINEDvalue.- Specified by:
gotUndefinedin interfaceBSONCallback- Parameters:
name- the name of the field- See Also:
-
gotMinKey
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.MIN_KEYvalue.- Specified by:
gotMinKeyin interfaceBSONCallback- Parameters:
name- the name of the field
-
gotMaxKey
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.MAX_KEYvalue.- Specified by:
gotMaxKeyin interfaceBSONCallback- Parameters:
name- the name of the field
-
gotBoolean
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.BOOLEANvalue.- Specified by:
gotBooleanin interfaceBSONCallback- Parameters:
name- the name of the fieldvalue- the field's value
-
gotDouble
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.DOUBLEvalue.- Specified by:
gotDoublein interfaceBSONCallback- Parameters:
name- the name of the fieldvalue- the field's value
-
gotInt
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.INT32value.- Specified by:
gotIntin interfaceBSONCallback- Parameters:
name- the name of the fieldvalue- the field's value
-
gotLong
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.INT64value.- Specified by:
gotLongin interfaceBSONCallback- Parameters:
name- the name of the fieldvalue- the field's value
-
gotDecimal128
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.DECIMAL128value.- Specified by:
gotDecimal128in interfaceBSONCallback- Parameters:
name- the field namevalue- the Decimal128 field value
-
gotDate
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.DATE_TIMEvalue.- Specified by:
gotDatein interfaceBSONCallback- Parameters:
name- the name of the fieldmillis- the date and time in milliseconds
-
gotRegex
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.REGULAR_EXPRESSIONvalue.- Specified by:
gotRegexin interfaceBSONCallback- Parameters:
name- the name of the fieldpattern- the regex patternflags- the optional flags for the regular expression
-
gotString
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.STRINGvalue.- Specified by:
gotStringin interfaceBSONCallback- Parameters:
name- the name of the fieldvalue- the field's value
-
gotSymbol
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.SYMBOLvalue.- Specified by:
gotSymbolin interfaceBSONCallback- Parameters:
name- the name of the fieldvalue- the field's value
-
gotTimestamp
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.TIMESTAMPvalue.- Specified by:
gotTimestampin interfaceBSONCallback- Parameters:
name- the name of the fieldtime- the time in seconds since epochincrement- an incrementing ordinal for operations within a given second
-
gotObjectId
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.OBJECT_IDvalue.- Specified by:
gotObjectIdin interfaceBSONCallback- Parameters:
name- the name of the fieldid- the object ID
-
gotDBRef
Description copied from interface:BSONCallbackInvoked whenBSONDecoderencountered aBsonType.DB_POINTERtype field in a byte sequence.- Specified by:
gotDBRefin interfaceBSONCallback- 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
-
gotBinary
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.BINARYvalue. Note that binary values have a subtype, which may determine how the value is processed.- Specified by:
gotBinaryin interfaceBSONCallback- Parameters:
name- the name of the fieldtype- one of the binary subtypes:BsonBinarySubTypedata- the field's value
-
gotUUID
Description copied from interface:BSONCallbackCalled when reading a field with aUUIDvalue. This is a binary value of subtypeBsonBinarySubType.UUID_LEGACY- Specified by:
gotUUIDin interfaceBSONCallback- Parameters:
name- the name of the fieldpart1- the first part of the UUIDpart2- the second part of the UUID
-
gotCode
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.JAVASCRIPTvalue.- Specified by:
gotCodein interfaceBSONCallback- Parameters:
name- the name of the fieldcode- the JavaScript code
-
gotCodeWScope
Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.JAVASCRIPT_WITH_SCOPEvalue.- Specified by:
gotCodeWScopein interfaceBSONCallback- Parameters:
name- the name of the fieldcode- the JavaScript codescope- a document representing the scope for the code
-
_put
Puts a new value into the document.- Parameters:
name- the name of the fieldvalue- the value
-
cur
Gets the current value- Returns:
- the current value
-
curName
Gets the name of the current field- Returns:
- the name of the current field.
-
setRoot
Sets the root document for this position- Parameters:
root- the new root document
-
isStackEmpty
protected boolean isStackEmpty()Returns whether this is the top level or not- Returns:
- true if there's nothing on the stack, and this is the top level of the document.
-
reset
public void reset()Description copied from interface:BSONCallbackResets the callback, clearing all state.- Specified by:
resetin interfaceBSONCallback
-