public class BasicBSONEncoder extends Object implements org.bson.BSONEncoder
Constructor and Description |
---|
BasicBSONEncoder() |
Modifier and Type | Method and Description |
---|---|
protected void |
_putObjectField(String name,
Object initialValue)
Encodes any Object type
|
void |
done() |
byte[] |
encode(org.bson.BSONObject document) |
protected org.bson.BsonBinaryWriter |
getBsonWriter()
Gets the writer responsible for writing the encoded BSON.
|
protected org.bson.io.OutputBuffer |
getOutputBuffer()
Gets the buffer the BSON is being encoded into.
|
protected void |
putArray(String name,
Object object)
Encodes an array field.
|
protected void |
putBinary(String name,
org.bson.types.Binary binary)
Encodes a Binary field
|
protected void |
putBinary(String name,
byte[] bytes)
Encodes a byte array field
|
protected void |
putBoolean(String name,
Boolean value)
Encodes a field with a
Boolean or boolean value |
protected void |
putCode(String name,
org.bson.types.Code code)
Encodes a field to a
BsonType.JAVASCRIPT value. |
protected void |
putCodeWScope(String name,
org.bson.types.CodeWScope codeWScope)
Encodes a field to a
BsonType.JAVASCRIPT_WITH_SCOPE value. |
protected void |
putDate(String name,
Date date)
Encodes a field with data and time value.
|
protected void |
putDecimal128(String name,
org.bson.types.Decimal128 value)
Encodes a Decimal128 field.
|
protected void |
putIterable(String name,
Iterable iterable)
Encodes an Iterable, for example
List values |
protected void |
putMap(String name,
Map map)
Encodes a map, as a BSON document
|
protected void |
putMaxKey(String name)
Encodes a field to a
BsonType.MAX_KEY value. |
protected void |
putMinKey(String name)
Encodes a field to a
BsonType.MIN_KEY value. |
protected void |
putName(String name)
Writes a field name
|
protected void |
putNull(String name)
Encodes a null value
|
protected void |
putNumber(String name,
Number number)
Encodes any number field.
|
int |
putObject(org.bson.BSONObject document)
Encodes a
BSONObject . |
protected int |
putObject(String name,
org.bson.BSONObject document)
Encodes any
BSONObject , as a document |
protected void |
putObjectId(String name,
org.bson.types.ObjectId objectId)
Encodes an ObjectId field to a
BsonType.OBJECT_ID . |
protected void |
putPattern(String name,
Pattern value)
Encodes a Pattern field to a
BsonType.REGULAR_EXPRESSION . |
protected boolean |
putSpecial(String name,
Object special)
Special values are not encoded into documents.
|
protected void |
putString(String name,
String value)
Encodes a String field
|
protected void |
putSymbol(String name,
org.bson.types.Symbol symbol)
Encodes a Symbol field
|
protected void |
putTimestamp(String name,
org.bson.BsonTimestamp timestamp)
Encodes a BSON timestamp
|
protected void |
putUndefined(String name)
Encodes an undefined value
|
protected void |
putUUID(String name,
UUID uuid)
Encodes a field with a
UUID value. |
void |
set(org.bson.io.OutputBuffer buffer) |
public byte[] encode(org.bson.BSONObject document)
encode
in interface org.bson.BSONEncoder
public void done()
done
in interface org.bson.BSONEncoder
public void set(org.bson.io.OutputBuffer buffer)
set
in interface org.bson.BSONEncoder
protected org.bson.io.OutputBuffer getOutputBuffer()
protected org.bson.BsonBinaryWriter getBsonWriter()
public int putObject(org.bson.BSONObject document)
BSONObject
. This is for the higher level api calls.putObject
in interface org.bson.BSONEncoder
document
- the document to encodeprotected void putName(String name)
name
- the field nameprotected void _putObjectField(String name, Object initialValue)
name
- the field nameinitialValue
- the value to writeprotected void putNull(String name)
name
- the field nameBsonType.NULL
protected void putUndefined(String name)
name
- the field nameBsonType.UNDEFINED
protected void putTimestamp(String name, org.bson.BsonTimestamp timestamp)
name
- the field nametimestamp
- the timestamp to encodeBsonType.TIMESTAMP
protected void putCode(String name, org.bson.types.Code code)
BsonType.JAVASCRIPT
value.name
- the field namecode
- the valueprotected void putCodeWScope(String name, org.bson.types.CodeWScope codeWScope)
BsonType.JAVASCRIPT_WITH_SCOPE
value.name
- the field namecodeWScope
- the valueprotected void putBoolean(String name, Boolean value)
Boolean
or boolean
valuename
- the field namevalue
- the valueprotected void putDate(String name, Date date)
name
- the field namedate
- the valueBsonType.DATE_TIME
protected void putNumber(String name, Number number)
name
- the field namenumber
- the valueprotected void putDecimal128(String name, org.bson.types.Decimal128 value)
name
- the field namevalue
- the valueprotected void putBinary(String name, byte[] bytes)
name
- the field namebytes
- the valueBsonType.BINARY
protected void putBinary(String name, org.bson.types.Binary binary)
name
- the field namebinary
- the valueBsonType.BINARY
protected void putUUID(String name, UUID uuid)
UUID
value. This is encoded to a binary value of subtype BsonBinarySubType.UUID_LEGACY
name
- the field nameuuid
- the valueprotected void putSymbol(String name, org.bson.types.Symbol symbol)
name
- the field namesymbol
- the valueBsonType.SYMBOL
protected void putString(String name, String value)
name
- the field namevalue
- the valueBsonType.STRING
protected void putPattern(String name, Pattern value)
BsonType.REGULAR_EXPRESSION
.name
- the field namevalue
- the valueBsonType.BINARY
protected void putObjectId(String name, org.bson.types.ObjectId objectId)
BsonType.OBJECT_ID
.name
- the field nameobjectId
- the valueprotected void putArray(String name, Object object)
name
- the field nameobject
- the array, which can be any sort of primitive or String arrayprotected void putIterable(String name, Iterable iterable)
List
valuesname
- the field nameiterable
- the valueprotected void putMap(String name, Map map)
name
- the field namemap
- the valueprotected int putObject(String name, org.bson.BSONObject document)
BSONObject
, as a documentname
- the field namedocument
- the valueprotected boolean putSpecial(String name, Object special)
name
- the field namespecial
- the valueprotected void putMinKey(String name)
BsonType.MIN_KEY
value.name
- the field nameprotected void putMaxKey(String name)
BsonType.MAX_KEY
value.name
- the field nameCopyright © 2010–2020. All rights reserved.