com.arcao.geocaching.api.impl.live_geocaching_api.parser
Class JsonReader

java.lang.Object
  extended by com.arcao.geocaching.api.impl.live_geocaching_api.parser.JsonReader

public class JsonReader
extends Object


Constructor Summary
JsonReader(Reader in)
           
 
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 isLenient()
          Returns true if this parser is liberal in what it accepts.
 boolean nextBoolean()
          Returns the boolean value of the next token, consuming it.
 boolean nextBoolean(boolean defaultValue)
           
 double nextDouble()
          Returns the double value of the next token, consuming it.
 double nextDouble(double defaultValue)
           
 int nextInt()
          Returns the int value of the next token, consuming it.
 int nextInt(int defaultValue)
           
 long nextLong()
          Returns the long value of the next token, consuming it.
 long nextLong(long defaultValue)
           
 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.
 String nextString()
          Returns the string value of the next token, consuming it.
 String nextString(String defaultValue)
           
 com.google.gson.stream.JsonToken peek()
          Returns the type of the next token without consuming it.
 void setLenient(boolean lenient)
          Configure this parser to be be liberal in what it accepts.
 void skipValue()
          Skips the next value recursively.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JsonReader

public JsonReader(Reader in)
Method Detail

setLenient

public void setLenient(boolean lenient)
Configure this parser to be be liberal in what it accepts. By default, this parser is strict and only accepts JSON as specified by RFC 4627. Setting the parser to lenient causes it to ignore the following syntax errors:


isLenient

public boolean isLenient()
Returns true if this parser is liberal in what it accepts.


beginArray

public void beginArray()
                throws IOException
Consumes the next token from the JSON stream and asserts that it is the beginning of a new array.

Throws:
IOException

endArray

public void endArray()
              throws IOException
Consumes the next token from the JSON stream and asserts that it is the end of the current array.

Throws:
IOException

beginObject

public void beginObject()
                 throws IOException
Consumes the next token from the JSON stream and asserts that it is the beginning of a new object.

Throws:
IOException

endObject

public void endObject()
               throws IOException
Consumes the next token from the JSON stream and asserts that it is the end of the current array.

Throws:
IOException

hasNext

public boolean hasNext()
                throws IOException
Returns true if the current array or object has another element.

Throws:
IOException

peek

public com.google.gson.stream.JsonToken peek()
                                      throws IOException
Returns the type of the next token without consuming it.

Throws:
IOException

nextName

public String nextName()
                throws IOException
Returns the next token, a property name, and consumes it.

Throws:
IOException - if the next token in the stream is not a property name.

nextString

public String nextString()
                  throws IOException
Returns the string value of the next token, consuming it. If the next token is a number, this method will return its string form.

Throws:
IllegalStateException - if the next token is not a string or if this reader is closed.
IOException

nextString

public String nextString(String defaultValue)
                  throws IOException
Throws:
IOException

nextBoolean

public boolean nextBoolean()
                    throws IOException
Returns the boolean value of the next token, consuming it.

Throws:
IllegalStateException - if the next token is not a boolean or if this reader is closed.
IOException

nextBoolean

public boolean nextBoolean(boolean defaultValue)
                    throws IOException
Throws:
IOException

nextNull

public void nextNull()
              throws IOException
Consumes the next token from the JSON stream and asserts that it is a literal null.

Throws:
IllegalStateException - if the next token is not null or if this reader is closed.
IOException

nextDouble

public double nextDouble()
                  throws IOException
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.

Throws:
IllegalStateException - if the next token is not a literal value.
NumberFormatException - if the next literal value cannot be parsed as a double, or is non-finite.
IOException

nextDouble

public double nextDouble(double defaultValue)
                  throws IOException
Throws:
IOException

nextLong

public long nextLong()
              throws IOException
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.

Throws:
IllegalStateException - if the next token is not a literal value.
NumberFormatException - if the next literal value cannot be parsed as a number, or exactly represented as a long.
IOException

nextLong

public long nextLong(long defaultValue)
              throws IOException
Throws:
IOException

nextInt

public int nextInt()
            throws IOException
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.

Throws:
IllegalStateException - if the next token is not a literal value.
NumberFormatException - if the next literal value cannot be parsed as a number, or exactly represented as an int.
IOException

nextInt

public int nextInt(int defaultValue)
            throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Closes this JSON reader and the underlying Reader.

Throws:
IOException

skipValue

public void skipValue()
               throws IOException
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.

Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.