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:
java.io.Closeable

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(java.lang.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(java.lang.Number value)
          Encodes value.
 JsonWriter value(java.lang.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
equals, 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 java.io.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:
java.io.IOException

endArray

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

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

beginObject

public JsonWriter beginObject()
                       throws java.io.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:
java.io.IOException

endObject

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

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

name

public JsonWriter name(java.lang.String name)
                throws java.io.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:
java.io.IOException

value

public JsonWriter value(java.lang.String value)
                 throws java.io.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:
java.io.IOException

nullValue

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

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

value

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

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

value

public JsonWriter value(double value)
                 throws java.io.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:
java.io.IOException

value

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

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

value

public JsonWriter value(java.lang.Number value)
                 throws java.io.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:
java.io.IOException

flush

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

Overrides:
flush in class JsonWriter
Throws:
java.io.IOException

close

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

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