Package ar.com.restba.json

Examples of ar.com.restba.json.JsonException


   *           number.
   */
  public JsonArray put(int index, Object value) {
    JsonObject.testValidity(value);
    if (index < 0) {
      throw new JsonException("JsonArray[" + index + "] not found.");
    }
    if (index < length()) {
      this.myArrayList.set(index, value);
    } else {
      while (index != length()) {
View Full Code Here


        b = true;
      }
      writer.write(']');
      return writer;
    } catch (IOException e) {
      throw new JsonException(e);
    }
  }
View Full Code Here

   * @throws JsonException
   *           If the value is out of sequence.
   */
  private JsonWriter append(String s) {
    if (s == null) {
      throw new JsonException("Null pointer");
    }
    if (this.mode == 'o' || this.mode == 'a') {
      try {
        if (this.comma && this.mode == 'a') {
          this.writer.write(',');
        }
        this.writer.write(s);
      } catch (IOException e) {
        throw new JsonException(e);
      }
      if (this.mode == 'o') {
        this.mode = 'k';
      }
      this.comma = true;
      return this;
    }
    throw new JsonException("Value out of sequence.");
  }
View Full Code Here

      this.push(null);
      this.append("[");
      this.comma = false;
      return this;
    }
    throw new JsonException("Misplaced array.");
  }
View Full Code Here

   * @throws JsonException
   *           If unbalanced.
   */
  private JsonWriter end(char m, char c) {
    if (this.mode != m) {
      throw new JsonException(m == 'o' ? "Misplaced endObject." : "Misplaced endArray.");
    }
    this.pop(m);
    try {
      this.writer.write(c);
    } catch (IOException e) {
      throw new JsonException(e);
    }
    this.comma = true;
    return this;
  }
View Full Code Here

   *           If the key is out of place. For example, keys do not belong in
   *           arrays or if the key is null.
   */
  public JsonWriter key(String s) {
    if (s == null) {
      throw new JsonException("Null key.");
    }
    if (this.mode == 'k') {
      try {
        stack[top - 1].putOnce(s, Boolean.TRUE);
        if (this.comma) {
          this.writer.write(',');
        }
        this.writer.write(JsonObject.quote(s));
        this.writer.write(':');
        this.comma = false;
        this.mode = 'o';
        return this;
      } catch (IOException e) {
        throw new JsonException(e);
      }
    }
    throw new JsonException("Misplaced key.");
  }
View Full Code Here

      this.append("{");
      this.push(new JsonObject());
      this.comma = false;
      return this;
    }
    throw new JsonException("Misplaced object.");

  }
View Full Code Here

   * @throws JsonException
   *           If nesting is wrong.
   */
  private void pop(char c) {
    if (this.top <= 0) {
      throw new JsonException("Nesting error.");
    }
    char m = this.stack[this.top - 1] == null ? 'a' : 'k';
    if (m != c) {
      throw new JsonException("Nesting error.");
    }
    this.top -= 1;
    this.mode = this.top == 0 ? 'd' : this.stack[this.top - 1] == null ? 'a' : 'k';
  }
View Full Code Here

   * @throws JsonException
   *           If nesting is too deep.
   */
  private void push(JsonObject jo) {
    if (this.top >= maxdepth) {
      throw new JsonException("Nesting too deep.");
    }
    this.stack[this.top] = jo;
    this.mode = jo == null ? 'a' : 'k';
    this.top += 1;
  }
View Full Code Here

   * that you can test for a digit or letter before attempting to parse the next
   * number or identifier.
   */
  public void back() {
    if (useLastChar || index <= 0) {
      throw new JsonException("Stepping back two steps is not supported");
    }
    index -= 1;
    useLastChar = true;
  }
View Full Code Here

TOP

Related Classes of ar.com.restba.json.JsonException

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.