sdk/src/com/socialize/google/gson/stream/JsonReader.java
public JsonToken peek() throws IOException {
    if (token != null) {
      return token;
    }

    switch (stack[stackSize - 1]) {
    case EMPTY_DOCUMENT:
      if (lenient) {
        consumeNonExecutePrefix();
      }
      stack[stackSize - 1] = JsonScope.NONEMPTY_DOCUMENT;
      JsonToken firstToken = nextValue();
      if (!lenient && token != JsonToken.BEGIN_ARRAY && token != JsonToken.BEGIN_OBJECT) {
        throw new IOException("Expected JSON document to start with '[' or '{' but was " + token
            + " at line " + getLineNumber() + " column " + getColumnNumber());
      }
      return firstToken;
    case EMPTY_ARRAY:
      return nextInArray(true);
    case NONEMPTY_ARRAY:
      return nextInArray(false);
    case EMPTY_OBJECT:
      return nextInObject(true);
    case DANGLING_NAME:
      return objectValue();
    case NONEMPTY_OBJECT:
      return nextInObject(false);
    case NONEMPTY_DOCUMENT:
      int c = nextNonWhitespace(false);
      if (c == -1) {
        return JsonToken.END_DOCUMENT;
      }
      pos--;
      if (!lenient) {
        throw syntaxError("Expected EOF");
      }
      return nextValue();
    case CLOSED:
      throw new IllegalStateException("JsonReader is closed");
    default:
      throw new AssertionError();
    }
  }
public JsonToken peek() throws IOException {
    if (token != null) {
      return token;
    }

    switch (stack[stackSize - 1]) {
    case EMPTY_DOCUMENT:
      if (lenient) {
        consumeNonExecutePrefix();
      }
      stack[stackSize - 1] = JsonScope.NONEMPTY_DOCUMENT;
      JsonToken firstToken = nextValue();
      if (!lenient && token != JsonToken.BEGIN_ARRAY && token != JsonToken.BEGIN_OBJECT) {
        throw new IOException("Expected JSON document to start with '[' or '{' but was " + token
            + " at line " + getLineNumber() + " column " + getColumnNumber());
      }
      return firstToken;
    case EMPTY_ARRAY:
      return nextInArray(true);
    case NONEMPTY_ARRAY:
      return nextInArray(false);
    case EMPTY_OBJECT:
      return nextInObject(true);
    case DANGLING_NAME:
      return objectValue();
    case NONEMPTY_OBJECT:
      return nextInObject(false);
    case NONEMPTY_DOCUMENT:
      int c = nextNonWhitespace(false);
      if (c == -1) {
        return JsonToken.END_DOCUMENT;
      }
      pos--;
      if (!lenient) {
        throw syntaxError("Expected EOF");
      }
      return nextValue();
    case CLOSED:
      throw new IllegalStateException("JsonReader is closed");
    default:
      throw new AssertionError();
    }
  }
public JsonToken peek ( ) throws IOException { if ( token != null ) { return token ; } switch ( stack [ stackSize - 1 ] ) { case EMPTY_DOCUMENT : if ( lenient ) { consumeNonExecutePrefix ( ) ; } stack [ stackSize - 1 ] = JsonScope . NONEMPTY_DOCUMENT ; JsonToken firstToken = nextValue ( ) ; if ( ! lenient && token != JsonToken . BEGIN_ARRAY && token != JsonToken . BEGIN_OBJECT ) { throw new IOException ( "Expected JSON document to start with '[' or '{' but was " + token + " at line " + getLineNumber ( ) + " column " + getColumnNumber ( ) ) ; } return firstToken ; case EMPTY_ARRAY : return nextInArray ( true ) ; case NONEMPTY_ARRAY : return nextInArray ( false ) ; case EMPTY_OBJECT : return nextInObject ( true ) ; case DANGLING_NAME : return objectValue ( ) ; case NONEMPTY_OBJECT : return nextInObject ( false ) ; case NONEMPTY_DOCUMENT : int c = nextNonWhitespace ( false ) ; if ( c == - 1 ) { return JsonToken . END_DOCUMENT ; } pos -- ; if ( ! lenient ) { throw syntaxError ( "Expected EOF" ) ; } return nextValue ( ) ; case CLOSED : throw new IllegalStateException ( "JsonReader is closed" ) ; default : throw new AssertionError ( ) ; } }
Returns the type of the next token without consuming it.
Returns the type of the next token without consuming it .