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
-
Method Summary
Modifier and TypeMethodDescriptionarray()
Begins a new array container.Begins a new named array container, having the given name.void
close()
Closes the underlying output stream and releases any system resources associated with the stream.void
flush()
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 UBJsonWriter
pop
(boolean silent) void
reset()
Appends a namednull
array value to the stream.Appends a namedboolean
value to the stream.Appends a namedboolean
array value to the stream.Appends a namedbyte
value to the stream.Appends a namedbyte
array value to the stream.Appends a namedchar
value to the stream.Appends a namedchar
array value to the stream.Appends a nameddouble
value to the stream.Appends a nameddouble
array value to the stream.Appends a namedfloat
value to the stream.Appends a namedfloat
array value to the stream.Appends a namedint
value to the stream.Appends a namedint
array value to the stream.Appends a namedlong
value to the stream.Appends a namedlong
array value to the stream.Appends a namedshort
value to the stream.Appends a namedshort
array value to the stream.Appends a named value to the stream.Appends a namedString
value to the stream.Appends a namedString
array value to the stream.void
setOutputType
(JsonWriter.OutputType outputType) void
setQuoteLongValues
(boolean quoteLongValues) value()
Appends anull
value to the stream.value
(boolean value) Appends aboolean
value to the stream.value
(boolean[] values) Appends aboolean array
value to the stream.value
(byte value) Appends abyte
value to the stream.value
(byte[] values) Appends an optimizedbyte array
value to the stream.value
(char value) Appends achar
value to the stream.value
(char[] values) Appends an optimizedchar array
value to the stream.value
(double value) Appends adouble
value to the stream.value
(double[] values) Appends an optimizeddouble array
value to the stream.value
(float value) Appends afloat
value to the stream.value
(float[] values) Appends an optimizedfloat array
value to the stream.value
(int value) Appends anint
value to the stream.value
(int[] values) Appends an optimizedint array
value to the stream.value
(long value) Appends along
value to the stream.value
(long[] values) Appends an optimizedlong array
value to the stream.value
(short value) Appends ashort
value to the stream.value
(short[] values) Appends an optimizedshort array
value 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 aString
value to the stream.Appends an optimizedString array
value 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:
object
in 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:
object
in interfaceBaseJsonWriter
- Returns:
- This writer, for chaining
- Throws:
IOException
-
array
Begins a new array container. To finish the array callpop()
.- Specified by:
array
in 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:
array
in interfaceBaseJsonWriter
- Returns:
- this writer, for chaining.
- Throws:
IOException
-
name
Appends a name for the next object, array, or value.- Specified by:
name
in interfaceBaseJsonWriter
- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends abyte
value to the stream. This corresponds to theint8
value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends ashort
value to the stream. This corresponds to theint16
value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends anint
value to the stream. This corresponds to theint32
value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends along
value to the stream. This corresponds to theint64
value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends afloat
value to the stream. This corresponds to thefloat32
value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends adouble
value to the stream. This corresponds to thefloat64
value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends aboolean
value to the stream. This corresponds to theboolean
value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends achar
value to the stream. Because, in Java, achar
is 16 bytes, this corresponds to theint16
value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends aString
value to the stream. This corresponds to thestring
value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends an optimizedbyte array
value to the stream. As an optimized array, theint8
value 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 array
value to the stream. As an optimized array, theint16
value 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 array
value to the stream. As an optimized array, theint32
value 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 array
value to the stream. As an optimized array, theint64
value 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 array
value to the stream. As an optimized array, thefloat32
value 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 array
value to the stream. As an optimized array, thefloat64
value 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 array
value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends an optimizedchar array
value to the stream. As an optimized array, theint16
value 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 array
value to the stream. As an optimized array, theString
value 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:
value
in interfaceBaseJsonWriter
- Returns:
- this writer, for chaining
- Throws:
IOException
-
value
Appends anull
value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
setOutputType
- Specified by:
setOutputType
in interfaceBaseJsonWriter
-
setQuoteLongValues
public void setQuoteLongValues(boolean quoteLongValues) - Specified by:
setQuoteLongValues
in interfaceBaseJsonWriter
-
set
Appends a named value to the stream.- Specified by:
set
in interfaceBaseJsonWriter
- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedbyte
value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedshort
value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedint
value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedlong
value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedfloat
value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a nameddouble
value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedboolean
value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedchar
value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedString
value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedbyte
array value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedshort
array value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedint
array value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedlong
array value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedfloat
array value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a nameddouble
array value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedboolean
array value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedchar
array value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namedString
array value to the stream.- Returns:
- this writer, for chaining
- Throws:
IOException
-
set
Appends a namednull
array 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:
pop
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-