Package com.google.gson.internal.bind
Class JsonTreeWriter
java.lang.Object
com.google.gson.stream.JsonWriter
com.google.gson.internal.bind.JsonTreeWriter
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
This writer creates a JsonElement.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
The name for the next JSON object value.private JsonElement
the JSON element constructed by this writer.private static final JsonPrimitive
Added to the top of the stack when this writer is closed to cause following ops to fail.private final List
<JsonElement> The JsonElements and JsonArrays under modification, outermost to innermost.private static final Writer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBegins encoding a new array.Begins encoding a new object.void
close()
Flushes and closes this writer and the underlyingWriter
.endArray()
Ends encoding the current array.Ends encoding the current object.void
flush()
Ensures all buffered data is written to the underlyingWriter
and flushes that writer.get()
Returns the top level object produced by this writer.Encodes the property name.Encodesnull
.private JsonElement
peek()
private void
put
(JsonElement value) value
(boolean value) Encodesvalue
.value
(double value) Encodesvalue
.value
(long value) Encodesvalue
.Encodesvalue
.Encodesvalue
.Encodesvalue
.Methods inherited from class com.google.gson.stream.JsonWriter
getSerializeNulls, isHtmlSafe, isLenient, jsonValue, setHtmlSafe, setIndent, setLenient, setSerializeNulls
-
Field Details
-
UNWRITABLE_WRITER
-
SENTINEL_CLOSED
Added to the top of the stack when this writer is closed to cause following ops to fail. -
stack
The JsonElements and JsonArrays under modification, outermost to innermost. -
pendingName
The name for the next JSON object value. If non-null, the top of the stack is a JsonObject. -
product
the JSON element constructed by this writer.
-
-
Constructor Details
-
JsonTreeWriter
public JsonTreeWriter()
-
-
Method Details
-
get
Returns the top level object produced by this writer. -
peek
-
put
-
beginArray
Description copied from class:JsonWriter
Begins encoding a new array. Each call to this method must be paired with a call toJsonWriter.endArray()
.- Overrides:
beginArray
in classJsonWriter
- Returns:
- this writer.
- Throws:
IOException
-
endArray
Description copied from class:JsonWriter
Ends encoding the current array.- Overrides:
endArray
in classJsonWriter
- Returns:
- this writer.
- Throws:
IOException
-
beginObject
Description copied from class:JsonWriter
Begins encoding a new object. Each call to this method must be paired with a call toJsonWriter.endObject()
.- Overrides:
beginObject
in classJsonWriter
- Returns:
- this writer.
- Throws:
IOException
-
endObject
Description copied from class:JsonWriter
Ends encoding the current object.- Overrides:
endObject
in classJsonWriter
- Returns:
- this writer.
- Throws:
IOException
-
name
Description copied from class:JsonWriter
Encodes the property name.- Overrides:
name
in classJsonWriter
- Parameters:
name
- the name of the forthcoming value. May not be null.- Returns:
- this writer.
- Throws:
IOException
-
value
Description copied from class:JsonWriter
Encodesvalue
.- Overrides:
value
in classJsonWriter
- Parameters:
value
- the literal string value, or null to encode a null literal.- Returns:
- this writer.
- Throws:
IOException
-
nullValue
Description copied from class:JsonWriter
Encodesnull
.- Overrides:
nullValue
in classJsonWriter
- Returns:
- this writer.
- Throws:
IOException
-
value
Description copied from class:JsonWriter
Encodesvalue
.- Overrides:
value
in classJsonWriter
- Returns:
- this writer.
- Throws:
IOException
-
value
Description copied from class:JsonWriter
Encodesvalue
.- Overrides:
value
in classJsonWriter
- Returns:
- this writer.
- Throws:
IOException
-
value
Description copied from class:JsonWriter
Encodesvalue
.- Overrides:
value
in classJsonWriter
- Parameters:
value
- a finite value. May not beNaNs
orinfinities
.- Returns:
- this writer.
- Throws:
IOException
-
value
Description copied from class:JsonWriter
Encodesvalue
.- Overrides:
value
in classJsonWriter
- Returns:
- this writer.
- Throws:
IOException
-
value
Description copied from class:JsonWriter
Encodesvalue
.- Overrides:
value
in classJsonWriter
- Parameters:
value
- a finite value. May not beNaNs
orinfinities
.- Returns:
- this writer.
- Throws:
IOException
-
flush
Description copied from class:JsonWriter
Ensures all buffered data is written to the underlyingWriter
and flushes that writer.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classJsonWriter
- Throws:
IOException
-
close
Description copied from class:JsonWriter
Flushes and closes this writer and the underlyingWriter
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classJsonWriter
- Throws:
IOException
- if the JSON document is incomplete.
-