public class BsonGenerator extends Object implements CookJsonGenerator
Because BSON does not support BigDecimal and BigInteger
types, they are stored as string literals. It is possible to store
them as double (for certain range of values). To do so, use the
function setUseDouble(boolean).
It should be noted that the generated BSON file is in a stream format
that has 0's for Document / Array type lengths. While BsonParser
has no problems reading the file, some utilities such as bsondump do
require them to be correctly specified. Use BsonFixLength.fix(java.io.File)
to update the length information.
PRETTY_PRINTING| Constructor and Description |
|---|
BsonGenerator(OutputStream os)
Constructor for BsonGenerator.
|
public BsonGenerator(OutputStream os)
os - the output stream.public void setUseDouble(boolean b)
BigDecimal / BigInteger
values are stored as double instead of string.b - boolean flag.public JsonGenerator writeStartObject()
writeStartObject in interface JsonGeneratorpublic JsonGenerator writeStartObject(String name)
writeStartObject in interface JsonGeneratorpublic JsonGenerator writeStartArray()
writeStartArray in interface JsonGeneratorpublic JsonGenerator writeStartArray(String name)
writeStartArray in interface JsonGeneratorpublic JsonGenerator write(String name, JsonValue value)
write in interface JsonGeneratorpublic JsonGenerator write(String name, byte[] value)
CookJsonGeneratorwrite in interface CookJsonGeneratorname - the key name.value - a binary data to be writtenCookJsonBinarypublic JsonGenerator write(String name, String value)
write in interface JsonGeneratorpublic JsonGenerator write(String name, BigInteger value)
write in interface JsonGeneratorpublic JsonGenerator write(String name, BigDecimal value)
write in interface JsonGeneratorpublic JsonGenerator write(String name, int value)
write in interface JsonGeneratorpublic JsonGenerator write(String name, long value)
write in interface JsonGeneratorpublic JsonGenerator write(String name, double value)
write in interface JsonGeneratorpublic JsonGenerator write(String name, boolean value)
write in interface JsonGeneratorpublic JsonGenerator writeNull(String name)
writeNull in interface JsonGeneratorpublic JsonGenerator writeEnd()
writeEnd in interface JsonGeneratorpublic JsonGenerator write(JsonValue value)
write in interface JsonGeneratorpublic JsonGenerator write(byte[] value)
CookJsonGeneratorwrite in interface CookJsonGeneratorvalue - a binary data to be writtenCookJsonBinarypublic JsonGenerator write(String value)
write in interface JsonGeneratorpublic JsonGenerator write(BigDecimal value)
write in interface JsonGeneratorpublic JsonGenerator write(BigInteger value)
write in interface JsonGeneratorpublic JsonGenerator write(int value)
write in interface JsonGeneratorpublic JsonGenerator write(long value)
write in interface JsonGeneratorpublic JsonGenerator write(double value)
write in interface JsonGeneratorpublic JsonGenerator write(boolean value)
write in interface JsonGeneratorpublic JsonGenerator writeNull()
writeNull in interface JsonGeneratorpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in interface JsonGeneratorpublic void flush()
flush in interface Flushableflush in interface JsonGeneratorCopyright © 2016. All rights reserved.