Package org.bson
Class BasicBSONCallback
- java.lang.Object
- 
- org.bson.BasicBSONCallback
 
- 
- All Implemented Interfaces:
- BSONCallback
 
 public class BasicBSONCallback extends Object implements BSONCallback An implementation ofBsonCallbackthat creates an instance of BSONObject.
- 
- 
Constructor SummaryConstructors Constructor Description BasicBSONCallback()Creates a new instance.
 - 
Method SummaryAll Methods Instance Methods Concrete 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.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- 
getpublic Object get() Description copied from interface:BSONCallbackReturns the finished top-level Document.- Specified by:
- getin interface- BSONCallback
- Returns:
- the top level document read from the database.
 
 - 
createpublic BSONObject create() Factory method for creating a new BSONObject.- Returns:
- a new BasicBSONObject.
 
 - 
createListprotected BSONObject createList() Factory method for creating a new BSON List.- Returns:
- a new BasicBSONList.
 
 - 
createBSONCallbackpublic BSONCallback createBSONCallback() Description copied from interface:BSONCallbackFactory method for BSONCallbacks.- Specified by:
- createBSONCallbackin interface- BSONCallback
- Returns:
- a new BSONCallback.
 
 - 
createpublic 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 BSONObject
- path- a list of field names to navigate to this field in the document
- Returns:
- the new BSONObject
 
 - 
objectStartpublic void objectStart() Description copied from interface:BSONCallbackSignals the start of a BSON document, which usually maps onto some Java object.- Specified by:
- objectStartin interface- BSONCallback
 
 - 
objectStartpublic 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 interface- BSONCallback
- Parameters:
- name- the field name of the document.
 
 - 
objectDonepublic Object objectDone() Description copied from interface:BSONCallbackCalled at the end of the document/array, and returns this object.- Specified by:
- objectDonein interface- BSONCallback
- Returns:
- the Object that has been read from this section of the document.
 
 - 
arrayStartpublic void arrayStart() Description copied from interface:BSONCallbackSignals the start of a BSON array.- Specified by:
- arrayStartin interface- BSONCallback
 
 - 
arrayStartpublic void arrayStart(String name) Description copied from interface:BSONCallbackSignals the start of a BSON array, with its field name.- Specified by:
- arrayStartin interface- BSONCallback
- Parameters:
- name- the name of this array field
 
 - 
arrayDonepublic Object arrayDone() Description copied from interface:BSONCallbackCalled the end of the array, and returns the completed array.- Specified by:
- arrayDonein interface- BSONCallback
- Returns:
- an Object representing the array that has been read from this section of the document.
 
 - 
gotNullpublic void gotNull(String name) Description copied from interface:BSONCallbackCalled when reading a BSON field that exists but has a null value.- Specified by:
- gotNullin interface- BSONCallback
- Parameters:
- name- the name of the field
- See Also:
- BsonType.NULL
 
 - 
gotUndefinedpublic void gotUndefined(String name) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.UNDEFINEDvalue.- Specified by:
- gotUndefinedin interface- BSONCallback
- Parameters:
- name- the name of the field
- See Also:
- BsonType.UNDEFINED
 
 - 
gotMinKeypublic void gotMinKey(String name) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.MIN_KEYvalue.- Specified by:
- gotMinKeyin interface- BSONCallback
- Parameters:
- name- the name of the field
 
 - 
gotMaxKeypublic void gotMaxKey(String name) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.MAX_KEYvalue.- Specified by:
- gotMaxKeyin interface- BSONCallback
- Parameters:
- name- the name of the field
 
 - 
gotBooleanpublic void gotBoolean(String name, boolean value) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.BOOLEANvalue.- Specified by:
- gotBooleanin interface- BSONCallback
- Parameters:
- name- the name of the field
- value- the field's value
 
 - 
gotDoublepublic void gotDouble(String name, double value) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.DOUBLEvalue.- Specified by:
- gotDoublein interface- BSONCallback
- Parameters:
- name- the name of the field
- value- the field's value
 
 - 
gotIntpublic void gotInt(String name, int value) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.INT32value.- Specified by:
- gotIntin interface- BSONCallback
- Parameters:
- name- the name of the field
- value- the field's value
 
 - 
gotLongpublic void gotLong(String name, long value) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.INT64value.- Specified by:
- gotLongin interface- BSONCallback
- Parameters:
- name- the name of the field
- value- the field's value
 
 - 
gotDecimal128public void gotDecimal128(String name, Decimal128 value) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.DECIMAL128value.- Specified by:
- gotDecimal128in interface- BSONCallback
- Parameters:
- name- the field name
- value- the Decimal128 field value
 
 - 
gotDatepublic void gotDate(String name, long millis) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.DATE_TIMEvalue.- Specified by:
- gotDatein interface- BSONCallback
- Parameters:
- name- the name of the field
- millis- the date and time in milliseconds
 
 - 
gotRegexpublic void gotRegex(String name, String pattern, String flags) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.REGULAR_EXPRESSIONvalue.- Specified by:
- gotRegexin interface- BSONCallback
- Parameters:
- name- the name of the field
- pattern- the regex pattern
- flags- the optional flags for the regular expression
 
 - 
gotStringpublic void gotString(String name, String value) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.STRINGvalue.- Specified by:
- gotStringin interface- BSONCallback
- Parameters:
- name- the name of the field
- value- the field's value
 
 - 
gotSymbolpublic void gotSymbol(String name, String value) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.SYMBOLvalue.- Specified by:
- gotSymbolin interface- BSONCallback
- Parameters:
- name- the name of the field
- value- the field's value
 
 - 
gotTimestamppublic void gotTimestamp(String name, int time, int increment) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.TIMESTAMPvalue.- Specified by:
- gotTimestampin interface- BSONCallback
- Parameters:
- name- the name of the field
- time- the time in seconds since epoch
- increment- an incrementing ordinal for operations within a given second
 
 - 
gotObjectIdpublic void gotObjectId(String name, ObjectId id) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.OBJECT_IDvalue.- Specified by:
- gotObjectIdin interface- BSONCallback
- Parameters:
- name- the name of the field
- id- the object ID
 
 - 
gotDBRefpublic 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 interface- BSONCallback
- Parameters:
- name- the name of the field
- namespace- the namespace to which reference is pointing to
- id- the if of the object to which reference is pointing to
 
 - 
gotBinarypublic 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 interface- BSONCallback
- Parameters:
- name- the name of the field
- type- one of the binary subtypes:- BsonBinarySubType
- data- the field's value
 
 - 
gotUUIDpublic 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 interface- BSONCallback
- Parameters:
- name- the name of the field
- part1- the first part of the UUID
- part2- the second part of the UUID
 
 - 
gotCodepublic void gotCode(String name, String code) Description copied from interface:BSONCallbackCalled when reading a field with aBsonType.JAVASCRIPTvalue.- Specified by:
- gotCodein interface- BSONCallback
- Parameters:
- name- the name of the field
- code- the JavaScript code
 
 - 
gotCodeWScopepublic 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 interface- BSONCallback
- Parameters:
- name- the name of the field
- code- the JavaScript code
- scope- a document representing the scope for the code
 
 - 
_putprotected void _put(String name, Object value) Puts a new value into the document.- Parameters:
- name- the name of the field
- value- the value
 
 - 
curprotected BSONObject cur() Gets the current value- Returns:
- the current value
 
 - 
curNameprotected String curName() Gets the name of the current field- Returns:
- the name of the current field.
 
 - 
setRootprotected void setRoot(Object root) Sets the root document for this position- Parameters:
- root- the new root document
 
 - 
isStackEmptyprotected 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.
 
 - 
resetpublic void reset() Description copied from interface:BSONCallbackResets the callback, clearing all state.- Specified by:
- resetin interface- BSONCallback
 
 
- 
 
-