Package moe.kyokobot.koe.internal.json
Class JsonAppendableWriter
java.lang.Object
moe.kyokobot.koe.internal.json.JsonAppendableWriter
- All Implemented Interfaces:
JsonSink<JsonAppendableWriter>
JSON writer that emits JSON to a
Appendable.
Create this class with JsonWriter.on(Appendable) or
JsonWriter.on(OutputStream).
OutputStream out = ...;
JsonWriter
.indent(" ")
.on(out)
.object()
.array("a")
.value(1)
.value(2)
.end()
.value("b", false)
.value("c", true)
.end()
.done();
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Appendableprotected final OutputStreamprotected final boolean -
Method Summary
Modifier and TypeMethodDescriptionarray()Starts an array.Starts an array within an object, prefixed with a key.array(String key, Collection<?> c) Emits the start of an array with a key.array(Collection<?> c) Emits the start of an array.voiddone()Closes this JSON writer and flushes the underlyingAppendableif it is alsoFlushable.protected voidEnsures that the object is in the finished state.end()Ends the current array or object.nul()Emits a 'null' token.Emits a 'null' token with a key.object()Starts an object.Starts an object within an object, prefixed with a key.Emits the start of an object with a key.Emits the start of an object.value(boolean b) Emits a boolean value.value(double d) Emits a double value.value(float d) Emits a float value.value(int i) Emits an integer value.value(long l) Emits a long value.Emits aNumbervalue.Emits an object if it is a JSON-compatible type, otherwise throws an exception.Emits a string value (or null).Emits a boolean value with a key.Emits a double value with a key.Emits a float value with a key.Emits an integer value with a key.Emits a long value with a key.Emits aNumbervalue with a key.Emits an object with a key if it is a JSON-compatible type, otherwise throws an exception.Emits a string value (or null) with a key.
-
Field Details
-
appendable
-
out
-
utf8
protected final boolean utf8
-
-
Method Details
-
done
Closes this JSON writer and flushes the underlyingAppendableif it is alsoFlushable.- Throws:
JsonWriterException- if the underlyingFlushableAppendablefailed to flush.
-
array
Description copied from interface:JsonSinkEmits the start of an array. -
array
Description copied from interface:JsonSinkEmits the start of an array with a key. -
object
Description copied from interface:JsonSinkEmits the start of an object. -
object
Description copied from interface:JsonSinkEmits the start of an object with a key. -
nul
Description copied from interface:JsonSinkEmits a 'null' token. -
nul
Description copied from interface:JsonSinkEmits a 'null' token with a key. -
value
Description copied from interface:JsonSinkEmits an object if it is a JSON-compatible type, otherwise throws an exception. -
value
Description copied from interface:JsonSinkEmits an object with a key if it is a JSON-compatible type, otherwise throws an exception. -
value
Description copied from interface:JsonSinkEmits a string value (or null). -
value
Description copied from interface:JsonSinkEmits an integer value. -
value
Description copied from interface:JsonSinkEmits a long value. -
value
Description copied from interface:JsonSinkEmits a boolean value. -
value
Description copied from interface:JsonSinkEmits a double value. -
value
Description copied from interface:JsonSinkEmits a float value. -
value
Description copied from interface:JsonSinkEmits aNumbervalue. -
value
Description copied from interface:JsonSinkEmits a string value (or null) with a key. -
value
Description copied from interface:JsonSinkEmits an integer value with a key. -
value
Description copied from interface:JsonSinkEmits a long value with a key. -
value
Description copied from interface:JsonSinkEmits a boolean value with a key. -
value
Description copied from interface:JsonSinkEmits a double value with a key. -
value
Description copied from interface:JsonSinkEmits a float value with a key. -
value
Description copied from interface:JsonSinkEmits aNumbervalue with a key. -
array
Description copied from interface:JsonSinkStarts an array. -
object
Description copied from interface:JsonSinkStarts an object. -
array
Description copied from interface:JsonSinkStarts an array within an object, prefixed with a key. -
object
Description copied from interface:JsonSinkStarts an object within an object, prefixed with a key. -
end
Description copied from interface:JsonSinkEnds the current array or object. -
doneInternal
protected void doneInternal()Ensures that the object is in the finished state.- Throws:
JsonWriterException- if the written JSON is not properly balanced, ie: all arrays and objects that were started have been properly ended.
-