Package org.bson
Class BasicBSONCallback
- java.lang.Object
-
- org.bson.BasicBSONCallback
-
- All Implemented Interfaces:
BSONCallback
- Direct Known Subclasses:
DefaultDBCallback,JSONCallback
public class BasicBSONCallback extends java.lang.Object implements BSONCallback
An implementation ofBsonCallbackthat creates an instance of BSONObject.
-
-
Constructor Summary
Constructors Constructor Description BasicBSONCallback()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete 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.BSONObjectcreate()Factory method for creating a new BSONObject.BSONObjectcreate(boolean array, java.util.List<java.lang.String> path)Helper method to create either a BSON Object or a BSON List depending upon whether thearrayparameter is true or not.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.voidgotBoolean(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
-
get
public java.lang.Object 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
public BSONObject create()
Factory method for creating a new BSONObject.- Returns:
- a new BasicBSONObject.
-
createBSONCallback
public BSONCallback createBSONCallback()
Description copied from interface:BSONCallbackFactory method for BSONCallbacks.- Specified by:
createBSONCallbackin interfaceBSONCallback- Returns:
- a new BSONCallback.
-
create
public BSONObject create(boolean array, java.util.List<java.lang.String> path)
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
public void objectStart(java.lang.String name)
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
public java.lang.Object 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
public void arrayStart(java.lang.String name)
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
public java.lang.Object 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
public void gotNull(java.lang.String name)
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:
BsonType.NULL
-
gotUndefined
public void gotUndefined(java.lang.String name)
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:
BsonType.UNDEFINED
-
gotMinKey
public void gotMinKey(java.lang.String name)
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
public void gotMaxKey(java.lang.String name)
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
public void gotBoolean(java.lang.String name, boolean value)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
public void gotDouble(java.lang.String name, double value)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
public void gotInt(java.lang.String name, int value)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
public void gotLong(java.lang.String name, long value)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
public void gotDecimal128(java.lang.String name, Decimal128 value)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
public void gotDate(java.lang.String name, long millis)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
public void gotRegex(java.lang.String name, java.lang.String pattern, java.lang.String flags)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
public void gotString(java.lang.String name, java.lang.String value)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
public void gotSymbol(java.lang.String name, java.lang.String value)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
public void gotTimestamp(java.lang.String name, int time, int increment)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
public void gotObjectId(java.lang.String name, ObjectId id)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
public void gotDBRef(java.lang.String name, java.lang.String namespace, ObjectId id)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
-
gotBinaryArray
@Deprecated public void gotBinaryArray(java.lang.String name, byte[] data)Deprecated.Description copied from interface:BSONCallbackThis method is not used.- Specified by:
gotBinaryArrayin interfaceBSONCallback- Parameters:
name- the name of the fielddata- the field's value
-
gotBinary
public void gotBinary(java.lang.String name, byte type, byte[] data)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
public void gotUUID(java.lang.String name, long part1, long part2)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
public void gotCode(java.lang.String name, java.lang.String code)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
public void gotCodeWScope(java.lang.String name, java.lang.String code, java.lang.Object scope)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
-
reset
public void reset()
Description copied from interface:BSONCallbackResets the callback, clearing all state.- Specified by:
resetin interfaceBSONCallback
-
-