Package org.bson.json
Class JsonWriter
- java.lang.Object
-
- org.bson.AbstractBsonWriter
-
- org.bson.json.JsonWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,BsonWriter
public class JsonWriter extends AbstractBsonWriter
ABsonWriterimplementation that outputs a JSON representation of BSON.- Since:
- 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classJsonWriter.ContextThe context for the writer, inheriting all the values fromAbstractBsonWriter.Context, and additionally providing settings for the indentation level and whether there are any child elements at this level.-
Nested classes/interfaces inherited from class org.bson.AbstractBsonWriter
AbstractBsonWriter.State
-
-
Constructor Summary
Constructors Constructor Description JsonWriter(java.io.Writer writer)Creates a new instance which useswriterto write JSON to.JsonWriter(java.io.Writer writer, JsonWriterSettings settings)Creates a new instance which useswriterto write JSON to and uses the given settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddoWriteBoolean(boolean value)voiddoWriteNull()voiddoWriteObjectId(ObjectId objectId)voiddoWriteRegularExpression(BsonRegularExpression regularExpression)voiddoWriteString(java.lang.String value)voiddoWriteSymbol(java.lang.String value)voiddoWriteTimestamp(BsonTimestamp value)voiddoWriteUndefined()voidflush()Flushes any pending data to the output destination.java.io.WritergetWriter()Gets theWriter.booleanisTruncated()Return true if the output has been truncated due to exceeding the length specified inJsonWriterSettings.maxLength.-
Methods inherited from class org.bson.AbstractBsonWriter
close, pipe, pipe, writeBinaryData, writeBinaryData, writeBoolean, writeBoolean, writeDateTime, writeDateTime, writeDBPointer, writeDBPointer, writeDecimal128, writeDecimal128, writeDouble, writeDouble, writeEndArray, writeEndDocument, writeInt32, writeInt32, writeInt64, writeInt64, writeJavaScript, writeJavaScript, writeJavaScriptWithScope, writeJavaScriptWithScope, writeMaxKey, writeMaxKey, writeMinKey, writeMinKey, writeName, writeNull, writeNull, writeObjectId, writeObjectId, writeRegularExpression, writeRegularExpression, writeStartArray, writeStartArray, writeStartDocument, writeStartDocument, writeString, writeString, writeSymbol, writeSymbol, writeTimestamp, writeTimestamp, writeUndefined, writeUndefined
-
-
-
-
Constructor Detail
-
JsonWriter
public JsonWriter(java.io.Writer writer)
Creates a new instance which useswriterto write JSON to.- Parameters:
writer- the writer to write JSON to.
-
JsonWriter
public JsonWriter(java.io.Writer writer, JsonWriterSettings settings)Creates a new instance which useswriterto write JSON to and uses the given settings.- Parameters:
writer- the writer to write JSON to.settings- the settings to apply to this writer.
-
-
Method Detail
-
getWriter
public java.io.Writer getWriter()
Gets theWriter.- Returns:
- the writer
-
doWriteBoolean
public void doWriteBoolean(boolean value)
-
doWriteNull
public void doWriteNull()
-
doWriteObjectId
public void doWriteObjectId(ObjectId objectId)
-
doWriteRegularExpression
public void doWriteRegularExpression(BsonRegularExpression regularExpression)
-
doWriteString
public void doWriteString(java.lang.String value)
-
doWriteSymbol
public void doWriteSymbol(java.lang.String value)
-
doWriteTimestamp
public void doWriteTimestamp(BsonTimestamp value)
-
doWriteUndefined
public void doWriteUndefined()
-
flush
public void flush()
Description copied from interface:BsonWriterFlushes any pending data to the output destination.
-
isTruncated
public boolean isTruncated()
Return true if the output has been truncated due to exceeding the length specified inJsonWriterSettings.maxLength.- Returns:
- true if the output has been truncated
- Since:
- 3.7
- See Also:
JsonWriterSettings.maxLength
-
-