Package arc.util.serialization
Class UBJsonWriter
java.lang.Object
arc.util.serialization.UBJsonWriter
- All Implemented Interfaces:
BaseJsonWriter,Closeable,AutoCloseable
Builder style API for emitting UBJSON.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarray()Begins a new array container.Begins a new named array container, having the given name.voidclose()Closes the underlying output stream and releases any system resources associated with the stream.voidflush()Flushes the underlying stream.Appends a name for the next object, array, or value.object()Begins a new object container.Begins a new named object container, having the given name.pop()Ends the current object or array and pops it off of the element stack.protected UBJsonWriterpop(boolean silent) voidreset()Appends a namednullarray value to the stream.Appends a namedbooleanvalue to the stream.Appends a namedbooleanarray value to the stream.Appends a namedbytevalue to the stream.Appends a namedbytearray value to the stream.Appends a namedcharvalue to the stream.Appends a namedchararray value to the stream.Appends a nameddoublevalue to the stream.Appends a nameddoublearray value to the stream.Appends a namedfloatvalue to the stream.Appends a namedfloatarray value to the stream.Appends a namedintvalue to the stream.Appends a namedintarray value to the stream.Appends a namedlongvalue to the stream.Appends a namedlongarray value to the stream.Appends a namedshortvalue to the stream.Appends a namedshortarray value to the stream.Appends a named value to the stream.Appends a namedStringvalue to the stream.Appends a namedStringarray value to the stream.voidsetOutputType(JsonWriter.OutputType outputType) voidsetQuoteLongValues(boolean quoteLongValues) value()Appends anullvalue to the stream.value(boolean value) Appends abooleanvalue to the stream.value(boolean[] values) Appends aboolean arrayvalue to the stream.value(byte value) Appends abytevalue to the stream.value(byte[] values) Appends an optimizedbyte arrayvalue to the stream.value(char value) Appends acharvalue to the stream.value(char[] values) Appends an optimizedchar arrayvalue to the stream.value(double value) Appends adoublevalue to the stream.value(double[] values) Appends an optimizeddouble arrayvalue to the stream.value(float value) Appends afloatvalue to the stream.value(float[] values) Appends an optimizedfloat arrayvalue to the stream.value(int value) Appends anintvalue to the stream.value(int[] values) Appends an optimizedint arrayvalue to the stream.value(long value) Appends alongvalue to the stream.value(long[] values) Appends an optimizedlong arrayvalue to the stream.value(short value) Appends ashortvalue to the stream.value(short[] values) Appends an optimizedshort arrayvalue to the stream.Appends the given JsonValue, including all its fields recursively, to the stream.Appends the object to the stream, if it is a known value type.Appends aStringvalue to the stream.Appends an optimizedString arrayvalue to the stream.
-
Constructor Details
-
UBJsonWriter
-
-
Method Details
-
reset
public void reset() -
object
Begins a new object container. To finish the object callpop().- Specified by:
objectin interfaceBaseJsonWriter- Returns:
- This writer, for chaining
- Throws:
IOException
-
object
Begins a new named object container, having the given name. To finish the object callpop().- Specified by:
objectin interfaceBaseJsonWriter- Returns:
- This writer, for chaining
- Throws:
IOException
-
array
Begins a new array container. To finish the array callpop().- Specified by:
arrayin interfaceBaseJsonWriter- Returns:
- this writer, for chaining.
- Throws:
IOException
-
array
Begins a new named array container, having the given name. To finish the array callpop().- Specified by:
arrayin interfaceBaseJsonWriter- Returns:
- this writer, for chaining.
- Throws:
IOException
-
name
Appends a name for the next object, array, or value.- Specified by:
namein interfaceBaseJsonWriter- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends abytevalue to the stream. This corresponds to theint8value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends ashortvalue to the stream. This corresponds to theint16value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends anintvalue to the stream. This corresponds to theint32value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends alongvalue to the stream. This corresponds to theint64value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends afloatvalue to the stream. This corresponds to thefloat32value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends adoublevalue to the stream. This corresponds to thefloat64value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends abooleanvalue to the stream. This corresponds to thebooleanvalue type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends acharvalue to the stream. Because, in Java, acharis 16 bytes, this corresponds to theint16value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends aStringvalue to the stream. This corresponds to thestringvalue type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends an optimizedbyte arrayvalue to the stream. As an optimized array, theint8value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends an optimizedshort arrayvalue to the stream. As an optimized array, theint16value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends an optimizedint arrayvalue to the stream. As an optimized array, theint32value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends an optimizedlong arrayvalue to the stream. As an optimized array, theint64value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends an optimizedfloat arrayvalue to the stream. As an optimized array, thefloat32value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends an optimizeddouble arrayvalue to the stream. As an optimized array, thefloat64value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element. element count are encoded once at the array marker instead of for each element.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends aboolean arrayvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends an optimizedchar arrayvalue to the stream. As an optimized array, theint16value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends an optimizedString arrayvalue to the stream. As an optimized array, theStringvalue type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends the given JsonValue, including all its fields recursively, to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends the object to the stream, if it is a known value type. This is a convenience method that calls through to the appropriate value method.- Specified by:
valuein interfaceBaseJsonWriter- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends anullvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
setOutputType
- Specified by:
setOutputTypein interfaceBaseJsonWriter
-
setQuoteLongValues
public void setQuoteLongValues(boolean quoteLongValues) - Specified by:
setQuoteLongValuesin interfaceBaseJsonWriter
-
set
Appends a named value to the stream.- Specified by:
setin interfaceBaseJsonWriter- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedbytevalue to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedshortvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedintvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedlongvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedfloatvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a nameddoublevalue to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedbooleanvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedcharvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedStringvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedbytearray value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedshortarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedintarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedlongarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedfloatarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a nameddoublearray value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedbooleanarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedchararray value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedStringarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namednullarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
pop
Ends the current object or array and pops it off of the element stack.- Specified by:
popin interfaceBaseJsonWriter- Returns:
- This writer, for chaining
- Throws:
IOException
-
pop
- Throws:
IOException
-
flush
Flushes the underlying stream. This forces any buffered output bytes to be written out to the stream.- Throws:
IOException
-
close
Closes the underlying output stream and releases any system resources associated with the stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-