Package org.bson.json
Class StrictCharacterStreamJsonWriter
java.lang.Object
org.bson.json.StrictCharacterStreamJsonWriter
- All Implemented Interfaces:
StrictJsonWriter
A class that writes JSON texts as a character stream via a provided
Writer
.- Since:
- 3.5
-
Constructor Summary
ConstructorDescriptionStrictCharacterStreamJsonWriter
(Writer writer, StrictCharacterStreamJsonWriterSettings settings) Construct an instance. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the current length of the JSON text.boolean
Return true if the output has been truncated due to exceeding the length specified inStrictCharacterStreamJsonWriterSettings.getMaxLength()
.void
writeBoolean
(boolean value) Writes a boolean to the writer.void
writeBoolean
(String name, boolean value) Writes a a member with a boolean value to the writer.void
Writes the end of a JSON array to the writer.void
Writes the end of a JSON object to the writer.void
Writes the name of a member to the writer.void
Writes a null value to the writer.void
Writes a member with a null value to the writer.void
writeNumber
(String value) Writes a number to the writer.void
writeNumber
(String name, String value) Writes a member with a numeric value to the writer.void
Writes a raw value without quoting or escaping.void
Writes a member with a raw value without quoting or escaping.void
Writes the start of a array to the writer.void
writeStartArray
(String name) Writes the start of JSON array member to the writer.void
Writes the start of a JSON object to the writer.void
writeStartObject
(String name) Writes the start of a JSON object member to the writer.void
writeString
(String value) Writes a String to the writer.void
writeString
(String name, String value) Writes a member with a string value to the writer.
-
Constructor Details
-
StrictCharacterStreamJsonWriter
public StrictCharacterStreamJsonWriter(Writer writer, StrictCharacterStreamJsonWriterSettings settings) Construct an instance.- Parameters:
writer
- the writer to write JSON to.settings
- the settings to apply to this writer.
-
-
Method Details
-
getCurrentLength
public int getCurrentLength()Gets the current length of the JSON text.- Returns:
- the current length of the JSON text
-
writeStartObject
Description copied from interface:StrictJsonWriter
Writes the start of a JSON object member to the writer.- Specified by:
writeStartObject
in interfaceStrictJsonWriter
- Parameters:
name
- the member name
-
writeStartArray
Description copied from interface:StrictJsonWriter
Writes the start of JSON array member to the writer.- Specified by:
writeStartArray
in interfaceStrictJsonWriter
- Parameters:
name
- the member name
-
writeBoolean
Description copied from interface:StrictJsonWriter
Writes a a member with a boolean value to the writer.- Specified by:
writeBoolean
in interfaceStrictJsonWriter
- Parameters:
name
- the member namevalue
- the boolean value
-
writeNumber
Description copied from interface:StrictJsonWriter
Writes a member with a numeric value to the writer.- Specified by:
writeNumber
in interfaceStrictJsonWriter
- Parameters:
name
- the member namevalue
- the Double value, as a String so that clients can take full control over formatting
-
writeString
Description copied from interface:StrictJsonWriter
Writes a member with a string value to the writer.- Specified by:
writeString
in interfaceStrictJsonWriter
- Parameters:
name
- the member namevalue
- the String value
-
writeRaw
Description copied from interface:StrictJsonWriter
Writes a member with a raw value without quoting or escaping.- Specified by:
writeRaw
in interfaceStrictJsonWriter
- Parameters:
name
- the member namevalue
- the raw value
-
writeNull
Description copied from interface:StrictJsonWriter
Writes a member with a null value to the writer.- Specified by:
writeNull
in interfaceStrictJsonWriter
- Parameters:
name
- the member name
-
writeName
Description copied from interface:StrictJsonWriter
Writes the name of a member to the writer.- Specified by:
writeName
in interfaceStrictJsonWriter
- Parameters:
name
- the member name
-
writeBoolean
public void writeBoolean(boolean value) Description copied from interface:StrictJsonWriter
Writes a boolean to the writer.- Specified by:
writeBoolean
in interfaceStrictJsonWriter
- Parameters:
value
- the boolean value.
-
writeNumber
Description copied from interface:StrictJsonWriter
Writes a number to the writer.- Specified by:
writeNumber
in interfaceStrictJsonWriter
- Parameters:
value
- the Double value, as a String so that clients can take full control over formatting
-
writeString
Description copied from interface:StrictJsonWriter
Writes a String to the writer.- Specified by:
writeString
in interfaceStrictJsonWriter
- Parameters:
value
- the String value
-
writeRaw
Description copied from interface:StrictJsonWriter
Writes a raw value without quoting or escaping.- Specified by:
writeRaw
in interfaceStrictJsonWriter
- Parameters:
value
- the String value
-
writeNull
public void writeNull()Description copied from interface:StrictJsonWriter
Writes a null value to the writer.- Specified by:
writeNull
in interfaceStrictJsonWriter
-
writeStartObject
public void writeStartObject()Description copied from interface:StrictJsonWriter
Writes the start of a JSON object to the writer.- Specified by:
writeStartObject
in interfaceStrictJsonWriter
-
writeStartArray
public void writeStartArray()Description copied from interface:StrictJsonWriter
Writes the start of a array to the writer.- Specified by:
writeStartArray
in interfaceStrictJsonWriter
-
writeEndObject
public void writeEndObject()Description copied from interface:StrictJsonWriter
Writes the end of a JSON object to the writer.- Specified by:
writeEndObject
in interfaceStrictJsonWriter
-
writeEndArray
public void writeEndArray()Description copied from interface:StrictJsonWriter
Writes the end of a JSON array to the writer.- Specified by:
writeEndArray
in interfaceStrictJsonWriter
-
isTruncated
public boolean isTruncated()Return true if the output has been truncated due to exceeding the length specified inStrictCharacterStreamJsonWriterSettings.getMaxLength()
.- Specified by:
isTruncated
in interfaceStrictJsonWriter
- Returns:
- true if the output has been truncated
- Since:
- 3.7
- See Also:
-