Package com.massivecraft.mcore.xlib.gson.stream

Examples of com.massivecraft.mcore.xlib.gson.stream.JsonToken


        new TypeAdapterRuntimeTypeWrapper<V>(context, valueTypeAdapter, valueType);
      this.constructor = constructor;
    }

    public Map<K, V> read(JsonReader in) throws IOException {
      JsonToken peek = in.peek();
      if (peek == JsonToken.NULL) {
        in.nextNull();
        return null;
      }
View Full Code Here


    popStack(); // empty iterator
    popStack(); // object
  }

  @Override public boolean hasNext() throws IOException {
    JsonToken token = peek();
    return token != JsonToken.END_OBJECT && token != JsonToken.END_ARRAY;
  }
View Full Code Here

    stack.add(entry.getValue());
    return (String) entry.getKey();
  }

  @Override public String nextString() throws IOException {
    JsonToken token = peek();
    if (token != JsonToken.STRING && token != JsonToken.NUMBER) {
      throw new IllegalStateException("Expected " + JsonToken.STRING + " but was " + token);
    }
    return ((JsonPrimitive) popStack()).getAsString();
  }
View Full Code Here

    expect(JsonToken.NULL);
    popStack();
  }

  @Override public double nextDouble() throws IOException {
    JsonToken token = peek();
    if (token != JsonToken.NUMBER && token != JsonToken.STRING) {
      throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + token);
    }
    double result = ((JsonPrimitive) peekStack()).getAsDouble();
    if (!isLenient() && (Double.isNaN(result) || Double.isInfinite(result))) {
View Full Code Here

    popStack();
    return result;
  }

  @Override public long nextLong() throws IOException {
    JsonToken token = peek();
    if (token != JsonToken.NUMBER && token != JsonToken.STRING) {
      throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + token);
    }
    long result = ((JsonPrimitive) peekStack()).getAsLong();
    popStack();
View Full Code Here

    popStack();
    return result;
  }

  @Override public int nextInt() throws IOException {
    JsonToken token = peek();
    if (token != JsonToken.NUMBER && token != JsonToken.STRING) {
      throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + token);
    }
    int result = ((JsonPrimitive) peekStack()).getAsInt();
    popStack();
View Full Code Here

    this.gson = gson;
  }

  @SuppressWarnings("incomplete-switch")
  @Override public Object read(JsonReader in) throws IOException {
    JsonToken token = in.peek();
    switch (token) {
    case BEGIN_ARRAY:
      List<Object> list = new ArrayList<Object>();
      in.beginArray();
      while (in.hasNext()) {
View Full Code Here

    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;
View Full Code Here

   * Advances the cursor in the JSON stream to the next token.
   */
  private JsonToken advance() throws IOException {
    peek();

    JsonToken result = token;
    token = null;
    value = null;
    name = null;
    return result;
  }
View Full Code Here

  public void skipValue() throws IOException {
    skipping = true;
    try {
      int count = 0;
      do {
        JsonToken token = advance();
        if (token == JsonToken.BEGIN_ARRAY || token == JsonToken.BEGIN_OBJECT) {
          count++;
        } else if (token == JsonToken.END_ARRAY || token == JsonToken.END_OBJECT) {
          count--;
        }
View Full Code Here

TOP

Related Classes of com.massivecraft.mcore.xlib.gson.stream.JsonToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.