com.google.gson.internal.bind
Class JsonTreeReader

java.lang.Object
  extended by com.google.gson.stream.JsonReader
      extended by com.google.gson.internal.bind.JsonTreeReader
All Implemented Interfaces:
java.io.Closeable

public final class JsonTreeReader
extends JsonReader

This reader walks the elements of a JsonElement as if it was coming from a character stream.

Author:
Jesse Wilson

Constructor Summary
JsonTreeReader(JsonElement element)
           
 
Method Summary
 void beginArray()
          Consumes the next token from the JSON stream and asserts that it is the beginning of a new array.
 void beginObject()
          Consumes the next token from the JSON stream and asserts that it is the beginning of a new object.
 void close()
          Closes this JSON reader and the underlying Reader.
 void endArray()
          Consumes the next token from the JSON stream and asserts that it is the end of the current array.
 void endObject()
          Consumes the next token from the JSON stream and asserts that it is the end of the current array.
 boolean hasNext()
          Returns true if the current array or object has another element.
 boolean nextBoolean()
          Returns the boolean value of the next token, consuming it.
 double nextDouble()
          Returns the double value of the next token, consuming it.
 int nextInt()
          Returns the int value of the next token, consuming it.
 long nextLong()
          Returns the long value of the next token, consuming it.
 java.lang.String nextName()
          Returns the next token, a property name, and consumes it.
 void nextNull()
          Consumes the next token from the JSON stream and asserts that it is a literal null.
 java.lang.String nextString()
          Returns the string value of the next token, consuming it.
 JsonToken peek()
          Returns the type of the next token without consuming it.
 void promoteNameToValue()
           
 void skipValue()
          Skips the next value recursively.
 java.lang.String toString()
           
 
Methods inherited from class com.google.gson.stream.JsonReader
isLenient, setLenient
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JsonTreeReader

public JsonTreeReader(JsonElement element)
Method Detail

beginArray

public void beginArray()
                throws java.io.IOException
Description copied from class: JsonReader
Consumes the next token from the JSON stream and asserts that it is the beginning of a new array.

Overrides:
beginArray in class JsonReader
Throws:
java.io.IOException

endArray

public void endArray()
              throws java.io.IOException
Description copied from class: JsonReader
Consumes the next token from the JSON stream and asserts that it is the end of the current array.

Overrides:
endArray in class JsonReader
Throws:
java.io.IOException

beginObject

public void beginObject()
                 throws java.io.IOException
Description copied from class: JsonReader
Consumes the next token from the JSON stream and asserts that it is the beginning of a new object.

Overrides:
beginObject in class JsonReader
Throws:
java.io.IOException

endObject

public void endObject()
               throws java.io.IOException
Description copied from class: JsonReader
Consumes the next token from the JSON stream and asserts that it is the end of the current array.

Overrides:
endObject in class JsonReader
Throws:
java.io.IOException

hasNext

public boolean hasNext()
                throws java.io.IOException
Description copied from class: JsonReader
Returns true if the current array or object has another element.

Overrides:
hasNext in class JsonReader
Throws:
java.io.IOException

peek

public JsonToken peek()
               throws java.io.IOException
Description copied from class: JsonReader
Returns the type of the next token without consuming it.

Overrides:
peek in class JsonReader
Throws:
java.io.IOException

nextName

public java.lang.String nextName()
                          throws java.io.IOException
Description copied from class: JsonReader
Returns the next token, a property name, and consumes it.

Overrides:
nextName in class JsonReader
Throws:
java.io.IOException - if the next token in the stream is not a property name.

nextString

public java.lang.String nextString()
                            throws java.io.IOException
Description copied from class: JsonReader
Returns the string value of the next token, consuming it. If the next token is a number, this method will return its string form.

Overrides:
nextString in class JsonReader
Throws:
java.io.IOException

nextBoolean

public boolean nextBoolean()
                    throws java.io.IOException
Description copied from class: JsonReader
Returns the boolean value of the next token, consuming it.

Overrides:
nextBoolean in class JsonReader
Throws:
java.io.IOException

nextNull

public void nextNull()
              throws java.io.IOException
Description copied from class: JsonReader
Consumes the next token from the JSON stream and asserts that it is a literal null.

Overrides:
nextNull in class JsonReader
Throws:
java.io.IOException

nextDouble

public double nextDouble()
                  throws java.io.IOException
Description copied from class: JsonReader
Returns the double value of the next token, consuming it. If the next token is a string, this method will attempt to parse it as a double using Double.parseDouble(String).

Overrides:
nextDouble in class JsonReader
Throws:
java.io.IOException

nextLong

public long nextLong()
              throws java.io.IOException
Description copied from class: JsonReader
Returns the long value of the next token, consuming it. If the next token is a string, this method will attempt to parse it as a long. If the next token's numeric value cannot be exactly represented by a Java long, this method throws.

Overrides:
nextLong in class JsonReader
Throws:
java.io.IOException

nextInt

public int nextInt()
            throws java.io.IOException
Description copied from class: JsonReader
Returns the int value of the next token, consuming it. If the next token is a string, this method will attempt to parse it as an int. If the next token's numeric value cannot be exactly represented by a Java int, this method throws.

Overrides:
nextInt in class JsonReader
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Description copied from class: JsonReader
Closes this JSON reader and the underlying Reader.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class JsonReader
Throws:
java.io.IOException

skipValue

public void skipValue()
               throws java.io.IOException
Description copied from class: JsonReader
Skips the next value recursively. If it is an object or array, all nested elements are skipped. This method is intended for use when the JSON token stream contains unrecognized or unhandled values.

Overrides:
skipValue in class JsonReader
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class JsonReader

promoteNameToValue

public void promoteNameToValue()
                        throws java.io.IOException
Throws:
java.io.IOException