@Override public boolean hasNext() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } return p != PEEKED_END_OBJECT && p != PEEKED_END_ARRAY; }
@Override public Token peek() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek();
@SuppressWarnings("TypeParameterUnusedInFormals") @Override public <T> T nextNull() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p == PEEKED_NULL) { peeked = PEEKED_NONE; pathIndices[stackSize - 1]++; return null; } else { throw new JsonDataException("Expected null but was " + peek() + " at path " + getPath()); } }
@Override public void endObject() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p == PEEKED_END_OBJECT) { stackSize--; pathNames[stackSize] = null; // Free the last path name so that it can be garbage collected! pathIndices[stackSize - 1]++; peeked = PEEKED_NONE; } else { throw new JsonDataException("Expected END_OBJECT but was " + peek() + " at path " + getPath()); } }
@Override public void endArray() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p == PEEKED_END_ARRAY) { stackSize--; pathIndices[stackSize - 1]++; peeked = PEEKED_NONE; } else { throw new JsonDataException("Expected END_ARRAY but was " + peek() + " at path " + getPath()); } }
@Override public boolean nextBoolean() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p == PEEKED_TRUE) { peeked = PEEKED_NONE; pathIndices[stackSize - 1]++; return true; } else if (p == PEEKED_FALSE) { peeked = PEEKED_NONE; pathIndices[stackSize - 1]++; return false; } throw new JsonDataException("Expected a boolean but was " + peek() + " at path " + getPath()); }
@Override public void beginObject() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p == PEEKED_BEGIN_OBJECT) { push(JsonScope.EMPTY_OBJECT); peeked = PEEKED_NONE; } else { throw new JsonDataException("Expected BEGIN_OBJECT but was " + peek() + " at path " + getPath()); } }
@Override public void beginArray() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p == PEEKED_BEGIN_ARRAY) { push(JsonScope.EMPTY_ARRAY); pathIndices[stackSize - 1] = 0; peeked = PEEKED_NONE; } else { throw new JsonDataException("Expected BEGIN_ARRAY but was " + peek() + " at path " + getPath()); } }
@Override public String nextString() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } String result; if (p == PEEKED_UNQUOTED) { result = nextUnquotedValue(); } else if (p == PEEKED_DOUBLE_QUOTED) { result = nextQuotedValue(DOUBLE_QUOTE_OR_SLASH); } else if (p == PEEKED_SINGLE_QUOTED) { result = nextQuotedValue(SINGLE_QUOTE_OR_SLASH); } else if (p == PEEKED_BUFFERED) { result = peekedString; peekedString = null; } else if (p == PEEKED_LONG) { result = Long.toString(peekedLong); } else if (p == PEEKED_NUMBER) { result = buffer.readUtf8(peekedNumberLength); } else { throw new JsonDataException("Expected a string but was " + peek() + " at path " + getPath()); } peeked = PEEKED_NONE; pathIndices[stackSize - 1]++; return result; }
@Override public String nextName() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } String result; if (p == PEEKED_UNQUOTED_NAME) { result = nextUnquotedValue(); } else if (p == PEEKED_DOUBLE_QUOTED_NAME) { result = nextQuotedValue(DOUBLE_QUOTE_OR_SLASH); } else if (p == PEEKED_SINGLE_QUOTED_NAME) { result = nextQuotedValue(SINGLE_QUOTE_OR_SLASH); } else { throw new JsonDataException("Expected a name but was " + peek() + " at path " + getPath()); } peeked = PEEKED_NONE; pathNames[stackSize - 1] = result; return result; }
@Override public double nextDouble() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek();
@Override public long nextLong() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek();
@Override public int nextInt() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek();
int p = peeked; if (p == PEEKED_NONE) { p = doPeek();
@Override public boolean hasNext() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } return p != PEEKED_END_OBJECT && p != PEEKED_END_ARRAY; }
@Override public boolean hasNext() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } return p != PEEKED_END_OBJECT && p != PEEKED_END_ARRAY; }
@Override public <T> T nextNull() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p == PEEKED_NULL) { peeked = PEEKED_NONE; pathIndices[stackSize - 1]++; return null; } else { throw new JsonDataException("Expected null but was " + peek() + " at path " + getPath()); } }
@Override public void beginObject() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p == PEEKED_BEGIN_OBJECT) { push(JsonScope.EMPTY_OBJECT); peeked = PEEKED_NONE; } else { throw new JsonDataException("Expected BEGIN_OBJECT but was " + peek() + " at path " + getPath()); } }
@Override public void beginObject() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p == PEEKED_BEGIN_OBJECT) { push(JsonScope.EMPTY_OBJECT); peeked = PEEKED_NONE; } else { throw new JsonDataException("Expected BEGIN_OBJECT but was " + peek() + " at path " + getPath()); } }
@Override public void beginArray() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p == PEEKED_BEGIN_ARRAY) { push(JsonScope.EMPTY_ARRAY); pathIndices[stackSize - 1] = 0; peeked = PEEKED_NONE; } else { throw new JsonDataException("Expected BEGIN_ARRAY but was " + peek() + " at path " + getPath()); } }