public class BasicBSONCallback extends Object implements BSONCallback
BsonCallback that creates an instance of BSONObject.| Constructor and Description |
|---|
BasicBSONCallback()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
_put(String name,
Object value)
Puts a new value into the document.
|
Object |
arrayDone()
Called the end of the array, and returns the completed array.
|
void |
arrayStart()
Signals the start of a BSON array.
|
void |
arrayStart(String name)
Signals the start of a BSON array, with its field name.
|
BSONObject |
create()
Factory method for creating a new BSONObject.
|
BSONObject |
create(boolean array,
List<String> path)
Helper method to create either a BSON Object or a BSON List depending upon whether the
array parameter is true or not. |
BSONCallback |
createBSONCallback()
Factory method for BSONCallbacks.
|
protected BSONObject |
createList()
Factory method for creating a new BSON List.
|
protected BSONObject |
cur()
Gets the current value
|
protected String |
curName()
Gets the name of the current field
|
Object |
get()
Returns the finished top-level Document.
|
void |
gotBinary(String name,
byte type,
byte[] data)
Called when reading a field with a
BsonType.BINARY value. |
void |
gotBinaryArray(String name,
byte[] data)
Deprecated.
|
void |
gotBoolean(String name,
boolean value)
Called when reading a field with a
BsonType.BOOLEAN value. |
void |
gotCode(String name,
String code)
Called when reading a field with a
BsonType.JAVASCRIPT value. |
void |
gotCodeWScope(String name,
String code,
Object scope)
Called when reading a field with a
BsonType.JAVASCRIPT_WITH_SCOPE value. |
void |
gotDate(String name,
long millis)
Called when reading a field with a
BsonType.DATE_TIME value. |
void |
gotDBRef(String name,
String namespace,
ObjectId id)
Invoked when
BSONDecoder encountered a BsonType.DB_POINTER type field in a byte sequence. |
void |
gotDecimal128(String name,
Decimal128 value)
Called when reading a field with a
BsonType.DECIMAL128 value. |
void |
gotDouble(String name,
double value)
Called when reading a field with a
BsonType.DOUBLE value. |
void |
gotInt(String name,
int value)
Called when reading a field with a
BsonType.INT32 value. |
void |
gotLong(String name,
long value)
Called when reading a field with a
BsonType.INT64 value. |
void |
gotMaxKey(String name)
Called when reading a field with a
BsonType.MAX_KEY value. |
void |
gotMinKey(String name)
Called when reading a field with a
BsonType.MIN_KEY value. |
void |
gotNull(String name)
Called when reading a BSON field that exists but has a null value.
|
void |
gotObjectId(String name,
ObjectId id)
Called when reading a field with a
BsonType.OBJECT_ID value. |
void |
gotRegex(String name,
String pattern,
String flags)
Called when reading a field with a
BsonType.REGULAR_EXPRESSION value. |
void |
gotString(String name,
String value)
Called when reading a field with a
BsonType.STRING value. |
void |
gotSymbol(String name,
String value)
Called when reading a field with a
BsonType.SYMBOL value. |
void |
gotTimestamp(String name,
int time,
int increment)
Called when reading a field with a
BsonType.TIMESTAMP value. |
void |
gotUndefined(String name)
Called when reading a field with a
BsonType.UNDEFINED value. |
void |
gotUUID(String name,
long part1,
long part2)
Called when reading a field with a
UUID value. |
protected boolean |
isStackEmpty()
Returns whether this is the top level or not
|
Object |
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 |
objectStart(String name)
Signals the start of a BSON document, which usually maps onto some Java object.
|
void |
reset()
Resets the callback, clearing all state.
|
protected void |
setRoot(Object root)
Sets the root document for this position
|
public Object get()
BSONCallbackget in interface BSONCallbackpublic BSONObject create()
protected BSONObject createList()
public BSONCallback createBSONCallback()
BSONCallbackcreateBSONCallback in interface BSONCallbackpublic BSONObject create(boolean array, List<String> path)
array parameter is true or not.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 documentpublic void objectStart()
BSONCallbackobjectStart in interface BSONCallbackpublic void objectStart(String name)
BSONCallbackobjectStart in interface BSONCallbackname - the field name of the document.public Object objectDone()
BSONCallbackobjectDone in interface BSONCallbackpublic void arrayStart()
BSONCallbackarrayStart in interface BSONCallbackpublic void arrayStart(String name)
BSONCallbackarrayStart in interface BSONCallbackname - the name of this array fieldpublic Object arrayDone()
BSONCallbackarrayDone in interface BSONCallbackpublic void gotNull(String name)
BSONCallbackgotNull in interface BSONCallbackname - the name of the fieldBsonType.NULLpublic void gotUndefined(String name)
BSONCallbackBsonType.UNDEFINED value.gotUndefined in interface BSONCallbackname - the name of the fieldBsonType.UNDEFINEDpublic void gotMinKey(String name)
BSONCallbackBsonType.MIN_KEY value.gotMinKey in interface BSONCallbackname - the name of the fieldpublic void gotMaxKey(String name)
BSONCallbackBsonType.MAX_KEY value.gotMaxKey in interface BSONCallbackname - the name of the fieldpublic void gotBoolean(String name, boolean value)
BSONCallbackBsonType.BOOLEAN value.gotBoolean in interface BSONCallbackname - the name of the fieldvalue - the field's valuepublic void gotDouble(String name, double value)
BSONCallbackBsonType.DOUBLE value.gotDouble in interface BSONCallbackname - the name of the fieldvalue - the field's valuepublic void gotInt(String name, int value)
BSONCallbackBsonType.INT32 value.gotInt in interface BSONCallbackname - the name of the fieldvalue - the field's valuepublic void gotLong(String name, long value)
BSONCallbackBsonType.INT64 value.gotLong in interface BSONCallbackname - the name of the fieldvalue - the field's valuepublic void gotDecimal128(String name, Decimal128 value)
BSONCallbackBsonType.DECIMAL128 value.gotDecimal128 in interface BSONCallbackname - the field namevalue - the Decimal128 field valuepublic void gotDate(String name, long millis)
BSONCallbackBsonType.DATE_TIME value.gotDate in interface BSONCallbackname - the name of the fieldmillis - the date and time in millisecondspublic void gotRegex(String name, String pattern, String flags)
BSONCallbackBsonType.REGULAR_EXPRESSION value.gotRegex in interface BSONCallbackname - the name of the fieldpattern - the regex patternflags - the optional flags for the regular expressionpublic void gotString(String name, String value)
BSONCallbackBsonType.STRING value.gotString in interface BSONCallbackname - the name of the fieldvalue - the field's valuepublic void gotSymbol(String name, String value)
BSONCallbackBsonType.SYMBOL value.gotSymbol in interface BSONCallbackname - the name of the fieldvalue - the field's valuepublic void gotTimestamp(String name, int time, int increment)
BSONCallbackBsonType.TIMESTAMP value.gotTimestamp in interface BSONCallbackname - the name of the fieldtime - the time in seconds since epochincrement - an incrementing ordinal for operations within a given secondpublic void gotObjectId(String name, ObjectId id)
BSONCallbackBsonType.OBJECT_ID value.gotObjectId in interface BSONCallbackname - the name of the fieldid - the object IDpublic void gotDBRef(String name, String namespace, ObjectId id)
BSONCallbackBSONDecoder encountered a BsonType.DB_POINTER type field in a byte sequence.gotDBRef in interface BSONCallbackname - the name of the fieldnamespace - the namespace to which reference is pointing toid - the if of the object to which reference is pointing to@Deprecated public void gotBinaryArray(String name, byte[] data)
BSONCallbackgotBinaryArray in interface BSONCallbackname - the name of the fielddata - the field's valuepublic void gotBinary(String name, byte type, byte[] data)
BSONCallbackBsonType.BINARY value. Note that binary values have a subtype, which may
determine how the value is processed.gotBinary in interface BSONCallbackname - the name of the fieldtype - one of the binary subtypes: BsonBinarySubTypedata - the field's valuepublic void gotUUID(String name, long part1, long part2)
BSONCallbackUUID value. This is a binary value of subtype
BsonBinarySubType.UUID_LEGACYgotUUID in interface BSONCallbackname - the name of the fieldpart1 - the first part of the UUIDpart2 - the second part of the UUIDpublic void gotCode(String name, String code)
BSONCallbackBsonType.JAVASCRIPT value.gotCode in interface BSONCallbackname - the name of the fieldcode - the JavaScript codepublic void gotCodeWScope(String name, String code, Object scope)
BSONCallbackBsonType.JAVASCRIPT_WITH_SCOPE value.gotCodeWScope in interface BSONCallbackname - the name of the fieldcode - the JavaScript codescope - a document representing the scope for the codeprotected void _put(String name, Object value)
name - the name of the fieldvalue - the valueprotected BSONObject cur()
protected String curName()
protected void setRoot(Object root)
root - the new root documentprotected boolean isStackEmpty()
public void reset()
BSONCallbackreset in interface BSONCallback