APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.badlogic.gdx.utils

public Class UBJsonWriter

extends Object
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.Closeable, .DataOutputStream, .IOException, .OutputStream

Builder style API for emitting UBJSON.
Author
Justin Shapcott

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private UBJsonWriter.JsonObject
private boolean
pack-priv final DataOutputStream
private final Array<UBJsonWriter.JsonObject>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public UBJsonWriter

Returns:

this writer, for chaining.
array
()

Begins a new array container.

public UBJsonWriter

Returns:

this writer, for chaining.
array
(String name)

Begins a new named array container, having the given name.

private void
public void
close()

Implements java.io.Closeable.close.

Closes the underlying output stream and releases any system resources associated with the stream.

public void
flush()

Flushes the underlying stream.

public UBJsonWriter

Returns:

this writer, for chaining
name
(String name)

Appends a name for the next object, array, or value.

public UBJsonWriter

Returns:

This writer, for chaining
object
()

Begins a new object container.

public UBJsonWriter

Returns:

This writer, for chaining
object
(String name)

Begins a new named object container, having the given name.

public UBJsonWriter

Returns:

This writer, for chaining
pop
()

Ends the current object or array and pops it off of the element stack.

protected UBJsonWriter
pop(boolean silent)

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, byte value)

Appends a named byte value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, short value)

Appends a named short value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, int value)

Appends a named int value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, long value)

Appends a named long value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, float value)

Appends a named float value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, double value)

Appends a named double value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, boolean value)

Appends a named boolean value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, char value)

Appends a named char value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, String value)

Appends a named String value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, byte[] value)

Appends a named byte array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, short[] value)

Appends a named short array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, int[] value)

Appends a named int array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, long[] value)

Appends a named long array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, float[] value)

Appends a named float array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, double[] value)

Appends a named double array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, boolean[] value)

Appends a named boolean array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, char[] value)

Appends a named char array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name, String[] value)

Appends a named String array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
set
(String name)

Appends a named null array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(byte value)

Appends a byte value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(short value)

Appends a short value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(int value)

Appends an int value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(long value)

Appends a long value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(float value)

Appends a float value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(double value)

Appends a double value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(boolean value)

Appends a boolean value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(char value)

Appends a char value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(String value)

Appends a String value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(byte[] values)

Appends an optimized byte array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(short[] values)

Appends an optimized short array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(int[] values)

Appends an optimized int array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(long[] values)

Appends an optimized long array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(float[] values)

Appends an optimized float array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(double[] values)

Appends an optimized double array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(boolean[] values)

Appends a boolean array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(char[] values)

Appends an optimized char array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(String[] values)

Appends an optimized String array value to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(JsonValue value)

Appends the given JsonValue, including all its fields recursively, to the stream.

public UBJsonWriter

Returns:

this writer, for chaining
value
(Object object)

Appends the object to the stream, if it is a known value type.

public UBJsonWriter

Returns:

this writer, for chaining
value
()

Appends a null value to the stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
private UBJsonWriter.JsonObject current
namedback to summary
private boolean named
outback to summary
pack-priv final DataOutputStream out
stackback to summary
private final Array<UBJsonWriter.JsonObject> stack

Constructor Detail

UBJsonWriterback to summary
public UBJsonWriter(OutputStream out)

Method Detail

arrayback to summary
public UBJsonWriter array() throws IOException

Begins a new array container. To finish the array call pop().

Returns:UBJsonWriter

this writer, for chaining.

arrayback to summary
public UBJsonWriter array(String name) throws IOException

Begins a new named array container, having the given name. To finish the array call pop().

Returns:UBJsonWriter

this writer, for chaining.

checkNameback to summary
private void checkName()
closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Closes the underlying output stream and releases any system resources associated with the stream.

Exceptions
IOException:

Doc from java.io.Closeable.close.

if an I/O error occurs

flushback to summary
public void flush() throws IOException

Flushes the underlying stream. This forces any buffered output bytes to be written out to the stream.

nameback to summary
public UBJsonWriter name(String name) throws IOException

Appends a name for the next object, array, or value.

Returns:UBJsonWriter

this writer, for chaining

objectback to summary
public UBJsonWriter object() throws IOException

Begins a new object container. To finish the object call pop().

Returns:UBJsonWriter

This writer, for chaining

objectback to summary
public UBJsonWriter object(String name) throws IOException

Begins a new named object container, having the given name. To finish the object call pop().

Returns:UBJsonWriter

This writer, for chaining

popback to summary
public UBJsonWriter pop() throws IOException

Ends the current object or array and pops it off of the element stack.

Returns:UBJsonWriter

This writer, for chaining

popback to summary
protected UBJsonWriter pop(boolean silent) throws IOException
setback to summary
public UBJsonWriter set(String name, byte value) throws IOException

Appends a named byte value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, short value) throws IOException

Appends a named short value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, int value) throws IOException

Appends a named int value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, long value) throws IOException

Appends a named long value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, float value) throws IOException

Appends a named float value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, double value) throws IOException

Appends a named double value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, boolean value) throws IOException

Appends a named boolean value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, char value) throws IOException

Appends a named char value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, String value) throws IOException

Appends a named String value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, byte[] value) throws IOException

Appends a named byte array value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, short[] value) throws IOException

Appends a named short array value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, int[] value) throws IOException

Appends a named int array value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, long[] value) throws IOException

Appends a named long array value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, float[] value) throws IOException

Appends a named float array value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, double[] value) throws IOException

Appends a named double array value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, boolean[] value) throws IOException

Appends a named boolean array value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, char[] value) throws IOException

Appends a named char array value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name, String[] value) throws IOException

Appends a named String array value to the stream.

Returns:UBJsonWriter

this writer, for chaining

setback to summary
public UBJsonWriter set(String name) throws IOException

Appends a named null array value to the stream.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(byte value) throws IOException

Appends a byte value to the stream. This corresponds to the int8 value type in the UBJSON specification.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(short value) throws IOException

Appends a short value to the stream. This corresponds to the int16 value type in the UBJSON specification.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(int value) throws IOException

Appends an int value to the stream. This corresponds to the int32 value type in the UBJSON specification.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(long value) throws IOException

Appends a long value to the stream. This corresponds to the int64 value type in the UBJSON specification.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(float value) throws IOException

Appends a float value to the stream. This corresponds to the float32 value type in the UBJSON specification.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(double value) throws IOException

Appends a double value to the stream. This corresponds to the float64 value type in the UBJSON specification.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(boolean value) throws IOException

Appends a boolean value to the stream. This corresponds to the boolean value type in the UBJSON specification.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(char value) throws IOException

Appends a char value to the stream. Because, in Java, a char is 16 bytes, this corresponds to the int16 value type in the UBJSON specification.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(String value) throws IOException

Appends a String value to the stream. This corresponds to the string value type in the UBJSON specification.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(byte[] values) throws IOException

Appends an optimized byte array value to the stream. As an optimized array, the int8 value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(short[] values) throws IOException

Appends an optimized short array value to the stream. As an optimized array, the int16 value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(int[] values) throws IOException

Appends an optimized int array value to the stream. As an optimized array, the int32 value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(long[] values) throws IOException

Appends an optimized long array value to the stream. As an optimized array, the int64 value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(float[] values) throws IOException

Appends an optimized float array value to the stream. As an optimized array, the float32 value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(double[] values) throws IOException

Appends an optimized double array value to the stream. As an optimized array, the float64 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:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(boolean[] values) throws IOException

Appends a boolean array value to the stream.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(char[] values) throws IOException

Appends an optimized char array value to the stream. As an optimized array, the int16 value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(String[] values) throws IOException

Appends an optimized String array value to the stream. As an optimized array, the String value type marker and element count are encoded once at the array marker instead of repeating the type marker for each element.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(JsonValue value) throws IOException

Appends the given JsonValue, including all its fields recursively, to the stream.

Returns:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value(Object object) throws 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:UBJsonWriter

this writer, for chaining

valueback to summary
public UBJsonWriter value() throws IOException

Appends a null value to the stream.

Returns:UBJsonWriter

this writer, for chaining

com.badlogic.gdx.utils back to summary

private Class UBJsonWriter.JsonObject

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final boolean

Constructor Summary

AccessConstructor and Description
pack-priv
JsonObject(boolean array)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrayback to summary
pack-priv final boolean array

Constructor Detail

JsonObjectback to summary
pack-priv JsonObject(boolean array) throws IOException

Method Detail

closeback to summary
pack-priv void close() throws IOException