Package org.bson
Class BasicBSONCallback
- java.lang.Object
 - 
- org.bson.BasicBSONCallback
 
 
- 
- All Implemented Interfaces:
 BSONCallback
- Direct Known Subclasses:
 DefaultDBCallback,JSONCallback
public class BasicBSONCallback extends 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 protected void_put(String name, Object value)Puts a new value into the document.ObjectarrayDone()Called the end of the array, and returns the completed array.voidarrayStart()Signals the start of a BSON array.voidarrayStart(String name)Signals the start of a BSON array, with its field name.BSONObjectcreate()Factory method for creating a new BSONObject.BSONObjectcreate(boolean array, List<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.protected BSONObjectcreateList()Factory method for creating a new BSON List.protected BSONObjectcur()Gets the current valueprotected StringcurName()Gets the name of the current fieldObjectget()Returns the finished top-level Document.voidgotBinary(String name, byte type, byte[] data)Called when reading a field with aBsonType.BINARYvalue.voidgotBinaryArray(String name, byte[] data)Deprecated.voidgotBoolean(String name, boolean value)Called when reading a field with aBsonType.BOOLEANvalue.voidgotCode(String name, String code)Called when reading a field with aBsonType.JAVASCRIPTvalue.voidgotCodeWScope(String name, String code, Object scope)Called when reading a field with aBsonType.JAVASCRIPT_WITH_SCOPEvalue.voidgotDate(String name, long millis)Called when reading a field with aBsonType.DATE_TIMEvalue.voidgotDBRef(String name, String namespace, ObjectId id)Invoked whenBSONDecoderencountered aBsonType.DB_POINTERtype field in a byte sequence.voidgotDecimal128(String name, Decimal128 value)Called when reading a field with aBsonType.DECIMAL128value.voidgotDouble(String name, double value)Called when reading a field with aBsonType.DOUBLEvalue.voidgotInt(String name, int value)Called when reading a field with aBsonType.INT32value.voidgotLong(String name, long value)Called when reading a field with aBsonType.INT64value.voidgotMaxKey(String name)Called when reading a field with aBsonType.MAX_KEYvalue.voidgotMinKey(String name)Called when reading a field with aBsonType.MIN_KEYvalue.voidgotNull(String name)Called 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.voidgotRegex(String name, String pattern, String flags)Called when reading a field with aBsonType.REGULAR_EXPRESSIONvalue.voidgotString(String name, String value)Called when reading a field with aBsonType.STRINGvalue.voidgotSymbol(String name, String value)Called 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.voidgotUUID(String name, long part1, long part2)Called when reading a field with aUUIDvalue.protected booleanisStackEmpty()Returns whether this is the top level or notObjectobjectDone()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(String name)Signals the start of a BSON document, which usually maps onto some Java object.voidreset()Resets the callback, clearing all state.protected voidsetRoot(Object root)Sets the root document for this position 
 - 
 
- 
- 
Method Detail
- 
get
public 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.
 
 
- 
createList
protected BSONObject createList()
Factory method for creating a new BSON List.- Returns:
 - a new BasicBSONList.
 
 
- 
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, List<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(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 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(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 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(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(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(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(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(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(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(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(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(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(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(String name, String pattern, 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(String name, 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(String name, 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(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(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(String name, 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(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(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(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(String name, 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(String name, String code, 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
 
- 
_put
protected void _put(String name, Object value)
Puts a new value into the document.- Parameters:
 name- the name of the fieldvalue- the value
 
- 
cur
protected BSONObject cur()
Gets the current value- Returns:
 - the current value
 
 
- 
curName
protected String curName()
Gets the name of the current field- Returns:
 - the name of the current field.
 
 
- 
setRoot
protected void setRoot(Object root)
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
 
 - 
 
 -