com.google.gson.internal.bind
Class JsonTreeWriter

java.lang.Object
  extended by com.google.gson.stream.JsonWriter
      extended by com.google.gson.internal.bind.JsonTreeWriter
All Implemented Interfaces:
Closeable, Flushable

public final class JsonTreeWriter
extends JsonWriter

This writer creates a JsonElement.


Constructor Summary
JsonTreeWriter()
           
 
Method Summary
 JsonWriter beginArray()
          Begins encoding a new array.
 JsonWriter beginObject()
          Begins encoding a new object.
 void close()
          Flushes and closes this writer and the underlying Writer.
 JsonWriter endArray()
          Ends encoding the current array.
 JsonWriter endObject()
          Ends encoding the current object.
 void flush()
          Ensures all buffered data is written to the underlying Writer and flushes that writer.
 JsonElement get()
          Returns the top level object produced by this writer.
 JsonWriter name(String name)
          Encodes the property name.
 JsonWriter nullValue()
          Encodes null.
 JsonWriter value(boolean value)
          Encodes value.
 JsonWriter value(double value)
          Encodes value.
 JsonWriter value(long value)
          Encodes value.
 JsonWriter value(Number value)
          Encodes value.
 JsonWriter value(String value)
          Encodes value.
 
Methods inherited from class com.google.gson.stream.JsonWriter
getSerializeNulls, isHtmlSafe, isLenient, setHtmlSafe, setIndent, setLenient, setSerializeNulls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonTreeWriter

public JsonTreeWriter()
Method Detail

get

public JsonElement get()
Returns the top level object produced by this writer.


beginArray

public JsonWriter beginArray()
                      throws IOException
Description copied from class: JsonWriter
Begins encoding a new array. Each call to this method must be paired with a call to JsonWriter.endArray().

Overrides:
beginArray in class JsonWriter
Returns:
this writer.
Throws:
IOException

endArray

public JsonWriter endArray()
                    throws IOException
Description copied from class: JsonWriter
Ends encoding the current array.

Overrides:
endArray in class JsonWriter
Returns:
this writer.
Throws:
IOException

beginObject

public JsonWriter beginObject()
                       throws IOException
Description copied from class: JsonWriter
Begins encoding a new object. Each call to this method must be paired with a call to JsonWriter.endObject().

Overrides:
beginObject in class JsonWriter
Returns:
this writer.
Throws:
IOException

endObject

public JsonWriter endObject()
                     throws IOException
Description copied from class: JsonWriter
Ends encoding the current object.

Overrides:
endObject in class JsonWriter
Returns:
this writer.
Throws:
IOException

name

public JsonWriter name(String name)
                throws IOException
Description copied from class: JsonWriter
Encodes the property name.

Overrides:
name in class JsonWriter
Parameters:
name - the name of the forthcoming value. May not be null.
Returns:
this writer.
Throws:
IOException

value

public JsonWriter value(String value)
                 throws IOException
Description copied from class: JsonWriter
Encodes value.

Overrides:
value in class JsonWriter
Parameters:
value - the literal string value, or null to encode a null literal.
Returns:
this writer.
Throws:
IOException

nullValue

public JsonWriter nullValue()
                     throws IOException
Description copied from class: JsonWriter
Encodes null.

Overrides:
nullValue in class JsonWriter
Returns:
this writer.
Throws:
IOException

value

public JsonWriter value(boolean value)
                 throws IOException
Description copied from class: JsonWriter
Encodes value.

Overrides:
value in class JsonWriter
Returns:
this writer.
Throws:
IOException

value

public JsonWriter value(double value)
                 throws IOException
Description copied from class: JsonWriter
Encodes value.

Overrides:
value in class JsonWriter
Parameters:
value - a finite value. May not be NaNs or infinities.
Returns:
this writer.
Throws:
IOException

value

public JsonWriter value(long value)
                 throws IOException
Description copied from class: JsonWriter
Encodes value.

Overrides:
value in class JsonWriter
Returns:
this writer.
Throws:
IOException

value

public JsonWriter value(Number value)
                 throws IOException
Description copied from class: JsonWriter
Encodes value.

Overrides:
value in class JsonWriter
Parameters:
value - a finite value. May not be NaNs or infinities.
Returns:
this writer.
Throws:
IOException

flush

public void flush()
           throws IOException
Description copied from class: JsonWriter
Ensures all buffered data is written to the underlying Writer and flushes that writer.

Specified by:
flush in interface Flushable
Overrides:
flush in class JsonWriter
Throws:
IOException

close

public void close()
           throws IOException
Description copied from class: JsonWriter
Flushes and closes this writer and the underlying Writer.

Specified by:
close in interface Closeable
Overrides:
close in class JsonWriter
Throws:
IOException - if the JSON document is incomplete.


Copyright © 2012. All Rights Reserved.