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
ABsonWriter
implementation that outputs a JSON representation of BSON.- Since:
- 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
JsonWriter.Context
The 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 useswriter
to write JSON to.JsonWriter(java.io.Writer writer, JsonWriterSettings settings)
Creates a new instance which useswriter
to write JSON to and uses the given settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doWriteBoolean(boolean value)
void
doWriteNull()
void
doWriteObjectId(ObjectId objectId)
void
doWriteRegularExpression(BsonRegularExpression regularExpression)
void
doWriteString(java.lang.String value)
void
doWriteSymbol(java.lang.String value)
void
doWriteTimestamp(BsonTimestamp value)
void
doWriteUndefined()
void
flush()
Flushes any pending data to the output destination.java.io.Writer
getWriter()
Gets theWriter
.boolean
isTruncated()
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 useswriter
to 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 useswriter
to 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:BsonWriter
Flushes 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
-
-