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 o)
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 binary value.
|
void |
gotBinaryArray(String name,
byte[] data)
Deprecated.
|
void |
gotBoolean(String name,
boolean value)
Called when reading a field with a Boolean value.
|
void |
gotCode(String name,
String code)
Called when reading a field with a JavaScript value.
|
void |
gotCodeWScope(String name,
String code,
Object scope)
Called when reading a field with a JavaScript with Scope value.
|
void |
gotDate(String name,
long millis)
Called when reading a field with a DateTime value.
|
void |
gotDBRef(String name,
String ns,
ObjectId id)
Invoked when
BSONDecoder encountered a DBPointer(0x0c) type field in a byte sequence. |
void |
gotDouble(String name,
double value)
Called when reading a field with a Double value.
|
void |
gotInt(String name,
int value)
Called when reading a field with an Int32 value.
|
void |
gotLong(String name,
long value)
Called when reading a field with an Int64 value.
|
void |
gotMaxKey(String name)
Called when reading a field with a MaxKey value.
|
void |
gotMinKey(String name)
Called when reading a field with a MinKey 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 an ObjectID value.
|
void |
gotRegex(String name,
String pattern,
String flags)
Called when reading a field with a Regex value.
|
void |
gotString(String name,
String value)
Called when reading a field with a String value.
|
void |
gotSymbol(String name,
String value)
Called when reading a field with a Symbol value.
|
void |
gotTimestamp(String name,
int time,
int inc)
Called when reading a field with a Timestamp value.
|
void |
gotUndefined(String name)
Called when reading a field with an 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(boolean array)
Deprecated.
instead, use
arrayStart() if array is true, and objectStart() if if array is false |
void |
objectStart(boolean array,
String name)
Deprecated.
instead, use
arrayStart(String) if array is true, and objectStart(String) if array
is false |
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 o)
Sets the root document for this position
|
public BSONObject create()
protected BSONObject createList()
public BSONCallback createBSONCallback()
BSONCallback
createBSONCallback
in interface BSONCallback
public 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()
BSONCallback
objectStart
in interface BSONCallback
@Deprecated public void objectStart(boolean array)
arrayStart()
if array
is true, and objectStart()
if if array
is falseobjectStart
in interface BSONCallback
array
- true if this object is an arraypublic void objectStart(String name)
BSONCallback
objectStart
in interface BSONCallback
name
- the field name of the document.@Deprecated public void objectStart(boolean array, String name)
arrayStart(String)
if array
is true, and objectStart(String)
if array
is falsepublic Object objectDone()
BSONCallback
objectDone
in interface BSONCallback
public void arrayStart()
BSONCallback
arrayStart
in interface BSONCallback
public void arrayStart(String name)
BSONCallback
arrayStart
in interface BSONCallback
name
- the name of this array fieldpublic Object arrayDone()
BSONCallback
arrayDone
in interface BSONCallback
public void gotNull(String name)
BSONCallback
gotNull
in interface BSONCallback
name
- the name of the fieldpublic void gotUndefined(String name)
BSONCallback
gotUndefined
in interface BSONCallback
name
- the name of the fieldpublic void gotMinKey(String name)
BSONCallback
gotMinKey
in interface BSONCallback
name
- the name of the fieldpublic void gotMaxKey(String name)
BSONCallback
gotMaxKey
in interface BSONCallback
name
- the name of the fieldpublic void gotBoolean(String name, boolean value)
BSONCallback
gotBoolean
in interface BSONCallback
name
- the name of the fieldvalue
- the field's valuepublic void gotDouble(String name, double value)
BSONCallback
gotDouble
in interface BSONCallback
name
- the name of the fieldvalue
- the field's valuepublic void gotInt(String name, int value)
BSONCallback
gotInt
in interface BSONCallback
name
- the name of the fieldvalue
- the field's valuepublic void gotLong(String name, long value)
BSONCallback
gotLong
in interface BSONCallback
name
- the name of the fieldvalue
- the field's valuepublic void gotDate(String name, long millis)
BSONCallback
gotDate
in interface BSONCallback
name
- the name of the fieldmillis
- the date and time in millisecondspublic void gotRegex(String name, String pattern, String flags)
BSONCallback
gotRegex
in interface BSONCallback
name
- the name of the fieldpattern
- the regex patternflags
- the optional flags for the regular expressionpublic void gotString(String name, String value)
BSONCallback
gotString
in interface BSONCallback
name
- the name of the fieldvalue
- the field's valuepublic void gotSymbol(String name, String value)
BSONCallback
gotSymbol
in interface BSONCallback
name
- the name of the fieldvalue
- the field's valuepublic void gotTimestamp(String name, int time, int inc)
BSONCallback
gotTimestamp
in interface BSONCallback
name
- the name of the fieldtime
- the time in seconds since epochinc
- an incrementing ordinal for operations within a given secondpublic void gotObjectId(String name, ObjectId id)
BSONCallback
gotObjectId
in interface BSONCallback
name
- the name of the fieldid
- the object IDpublic void gotDBRef(String name, String ns, ObjectId id)
BSONCallback
BSONDecoder
encountered a DBPointer(0x0c) type field in a byte sequence.gotDBRef
in interface BSONCallback
name
- the name of the fieldns
- 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)
BSONCallback
gotBinaryArray
in interface BSONCallback
name
- the name of the fielddata
- the field's valuepublic void gotBinary(String name, byte type, byte[] data)
BSONCallback
gotBinary
in interface BSONCallback
name
- the name of the fieldtype
- one of the binary subtypesdata
- the field's valuepublic void gotUUID(String name, long part1, long part2)
BSONCallback
UUID
value. This is a binary value of subtype UuidLegacy.gotUUID
in interface BSONCallback
name
- the name of the fieldpart1
- the first part of the UUIDpart2
- the second part of the UUIDpublic void gotCode(String name, String code)
BSONCallback
gotCode
in interface BSONCallback
name
- the name of the fieldcode
- the JavaScript codepublic void gotCodeWScope(String name, String code, Object scope)
BSONCallback
gotCodeWScope
in interface BSONCallback
name
- the name of the fieldcode
- the JavaScript codescope
- a document representing the scope for the codeprotected void _put(String name, Object o)
name
- the name of the fieldo
- the valueprotected BSONObject cur()
protected String curName()
public Object get()
BSONCallback
get
in interface BSONCallback
protected void setRoot(Object o)
o
- the new root documentprotected boolean isStackEmpty()
public void reset()
BSONCallback
reset
in interface BSONCallback