Package com.badlogic.gdx.utils
Class UBJsonWriter
- java.lang.Object
-
- com.badlogic.gdx.utils.UBJsonWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class UBJsonWriter extends java.lang.Object implements java.io.CloseableBuilder style API for emitting UBJSON.
-
-
Constructor Summary
Constructors Constructor Description UBJsonWriter(java.io.OutputStream out)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UBJsonWriterarray()Begins a new array container.UBJsonWriterarray(java.lang.String name)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.UBJsonWritername(java.lang.String name)Appends a name for the next object, array, or value.UBJsonWriterobject()Begins a new object container.UBJsonWriterobject(java.lang.String name)Begins a new named object container, having the given name.UBJsonWriterpop()Ends the current object or array and pops it off of the element stack.protected UBJsonWriterpop(boolean silent)UBJsonWriterset(java.lang.String name)Appends a namednullarray value to the stream.UBJsonWriterset(java.lang.String name, boolean value)Appends a namedbooleanvalue to the stream.UBJsonWriterset(java.lang.String name, boolean[] value)Appends a namedbooleanarray value to the stream.UBJsonWriterset(java.lang.String name, byte value)Appends a namedbytevalue to the stream.UBJsonWriterset(java.lang.String name, byte[] value)Appends a namedbytearray value to the stream.UBJsonWriterset(java.lang.String name, char value)Appends a namedcharvalue to the stream.UBJsonWriterset(java.lang.String name, char[] value)Appends a namedchararray value to the stream.UBJsonWriterset(java.lang.String name, double value)Appends a nameddoublevalue to the stream.UBJsonWriterset(java.lang.String name, double[] value)Appends a nameddoublearray value to the stream.UBJsonWriterset(java.lang.String name, float value)Appends a namedfloatvalue to the stream.UBJsonWriterset(java.lang.String name, float[] value)Appends a namedfloatarray value to the stream.UBJsonWriterset(java.lang.String name, int value)Appends a namedintvalue to the stream.UBJsonWriterset(java.lang.String name, int[] value)Appends a namedintarray value to the stream.UBJsonWriterset(java.lang.String name, long value)Appends a namedlongvalue to the stream.UBJsonWriterset(java.lang.String name, long[] value)Appends a namedlongarray value to the stream.UBJsonWriterset(java.lang.String name, short value)Appends a namedshortvalue to the stream.UBJsonWriterset(java.lang.String name, short[] value)Appends a namedshortarray value to the stream.UBJsonWriterset(java.lang.String name, java.lang.String value)Appends a namedStringvalue to the stream.UBJsonWriterset(java.lang.String name, java.lang.String[] value)Appends a namedStringarray value to the stream.UBJsonWritervalue()Appends anullvalue to the stream.UBJsonWritervalue(boolean value)Appends abooleanvalue to the stream.UBJsonWritervalue(boolean[] values)Appends aboolean arrayvalue to the stream.UBJsonWritervalue(byte value)Appends abytevalue to the stream.UBJsonWritervalue(byte[] values)Appends an optimizedbyte arrayvalue to the stream.UBJsonWritervalue(char value)Appends acharvalue to the stream.UBJsonWritervalue(char[] values)Appends an optimizedchar arrayvalue to the stream.UBJsonWritervalue(double value)Appends adoublevalue to the stream.UBJsonWritervalue(double[] values)Appends an optimizeddouble arrayvalue to the stream.UBJsonWritervalue(float value)Appends afloatvalue to the stream.UBJsonWritervalue(float[] values)Appends an optimizedfloat arrayvalue to the stream.UBJsonWritervalue(int value)Appends anintvalue to the stream.UBJsonWritervalue(int[] values)Appends an optimizedint arrayvalue to the stream.UBJsonWritervalue(long value)Appends alongvalue to the stream.UBJsonWritervalue(long[] values)Appends an optimizedlong arrayvalue to the stream.UBJsonWritervalue(short value)Appends ashortvalue to the stream.UBJsonWritervalue(short[] values)Appends an optimizedshort arrayvalue to the stream.UBJsonWritervalue(JsonValue value)Appends the given JsonValue, including all its fields recursively, to the stream.UBJsonWritervalue(java.lang.Object object)Appends the object to the stream, if it is a known value type.UBJsonWritervalue(java.lang.String value)Appends aStringvalue to the stream.UBJsonWritervalue(java.lang.String[] values)Appends an optimizedString arrayvalue to the stream.
-
-
-
Method Detail
-
object
public UBJsonWriter object() throws java.io.IOException
Begins a new object container. To finish the object callpop().- Returns:
- This writer, for chaining
- Throws:
java.io.IOException
-
object
public UBJsonWriter object(java.lang.String name) throws java.io.IOException
Begins a new named object container, having the given name. To finish the object callpop().- Returns:
- This writer, for chaining
- Throws:
java.io.IOException
-
array
public UBJsonWriter array() throws java.io.IOException
Begins a new array container. To finish the array callpop().- Returns:
- this writer, for chaining.
- Throws:
java.io.IOException
-
array
public UBJsonWriter array(java.lang.String name) throws java.io.IOException
Begins a new named array container, having the given name. To finish the array callpop().- Returns:
- this writer, for chaining.
- Throws:
java.io.IOException
-
name
public UBJsonWriter name(java.lang.String name) throws java.io.IOException
Appends a name for the next object, array, or value.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
value
public UBJsonWriter value(byte value) throws java.io.IOException
Appends abytevalue to the stream. This corresponds to theint8value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
value
public UBJsonWriter value(short value) throws java.io.IOException
Appends ashortvalue to the stream. This corresponds to theint16value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
value
public UBJsonWriter value(int value) throws java.io.IOException
Appends anintvalue to the stream. This corresponds to theint32value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
value
public UBJsonWriter value(long value) throws java.io.IOException
Appends alongvalue to the stream. This corresponds to theint64value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
value
public UBJsonWriter value(float value) throws java.io.IOException
Appends afloatvalue to the stream. This corresponds to thefloat32value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
value
public UBJsonWriter value(double value) throws java.io.IOException
Appends adoublevalue to the stream. This corresponds to thefloat64value type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
value
public UBJsonWriter value(boolean value) throws java.io.IOException
Appends abooleanvalue to the stream. This corresponds to thebooleanvalue type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
value
public UBJsonWriter value(char value) throws java.io.IOException
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:
java.io.IOException
-
value
public UBJsonWriter value(java.lang.String value) throws java.io.IOException
Appends aStringvalue to the stream. This corresponds to thestringvalue type in the UBJSON specification.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
value
public UBJsonWriter value(byte[] values) throws java.io.IOException
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:
java.io.IOException
-
value
public UBJsonWriter value(short[] values) throws java.io.IOException
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:
java.io.IOException
-
value
public UBJsonWriter value(int[] values) throws java.io.IOException
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:
java.io.IOException
-
value
public UBJsonWriter value(long[] values) throws java.io.IOException
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:
java.io.IOException
-
value
public UBJsonWriter value(float[] values) throws java.io.IOException
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:
java.io.IOException
-
value
public UBJsonWriter value(double[] values) throws java.io.IOException
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:
java.io.IOException
-
value
public UBJsonWriter value(boolean[] values) throws java.io.IOException
Appends aboolean arrayvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
value
public UBJsonWriter value(char[] values) throws java.io.IOException
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:
java.io.IOException
-
value
public UBJsonWriter value(java.lang.String[] values) throws java.io.IOException
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:
java.io.IOException
-
value
public UBJsonWriter value(JsonValue value) throws java.io.IOException
Appends the given JsonValue, including all its fields recursively, to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
value
public UBJsonWriter value(java.lang.Object object) throws java.io.IOException
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.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
value
public UBJsonWriter value() throws java.io.IOException
Appends anullvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, byte value) throws java.io.IOException
Appends a namedbytevalue to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, short value) throws java.io.IOException
Appends a namedshortvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, int value) throws java.io.IOException
Appends a namedintvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, long value) throws java.io.IOException
Appends a namedlongvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, float value) throws java.io.IOException
Appends a namedfloatvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, double value) throws java.io.IOException
Appends a nameddoublevalue to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, boolean value) throws java.io.IOException
Appends a namedbooleanvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, char value) throws java.io.IOException
Appends a namedcharvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, java.lang.String value) throws java.io.IOException
Appends a namedStringvalue to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, byte[] value) throws java.io.IOException
Appends a namedbytearray value to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, short[] value) throws java.io.IOException
Appends a namedshortarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, int[] value) throws java.io.IOException
Appends a namedintarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, long[] value) throws java.io.IOException
Appends a namedlongarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, float[] value) throws java.io.IOException
Appends a namedfloatarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, double[] value) throws java.io.IOException
Appends a nameddoublearray value to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, boolean[] value) throws java.io.IOException
Appends a namedbooleanarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, char[] value) throws java.io.IOException
Appends a namedchararray value to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name, java.lang.String[] value) throws java.io.IOException
Appends a namedStringarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
set
public UBJsonWriter set(java.lang.String name) throws java.io.IOException
Appends a namednullarray value to the stream.- Returns:
- this writer, for chaining
- Throws:
java.io.IOException
-
pop
public UBJsonWriter pop() throws java.io.IOException
Ends the current object or array and pops it off of the element stack.- Returns:
- This writer, for chaining
- Throws:
java.io.IOException
-
pop
protected UBJsonWriter pop(boolean silent) throws java.io.IOException
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOExceptionFlushes the underlying stream. This forces any buffered output bytes to be written out to the stream.- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionCloses the underlying output stream and releases any system resources associated with the stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-