@Test public void discardHashToken() throws IOException, JsonFormatException { State type; JsonPullParser parser = JsonPullParser .newParser("[null,{\"key1\":true,{\"key2\":false,\"key3\":{\"key4\":{}}}}]"); type = parser.getEventType(); assertThat(type, is(State.START_ARRAY)); parser.discardValue(); type = parser.getEventType(); assertThat(type, is(State.START_HASH)); parser.discardValue(); type = parser.getEventType(); assertThat(type, is(State.START_HASH)); parser.discardValue(); type = parser.getEventType(); assertThat(type, is(State.KEY)); parser.discardHashToken(); type = parser.getEventType(); assertThat(type, is(State.END_HASH)); type = parser.getEventType(); assertThat(type, is(State.END_HASH)); type = parser.getEventType(); assertThat(type, is(State.END_ARRAY)); }
public void discardHashToken() throws IOException, JsonFormatException, IllegalStateException { State state = lookAhead(); switch (state) { case START_HASH: getEventType(); while ((state = lookAhead()) != State.END_HASH) { switch (state) { case START_ARRAY: discardArrayToken(); break; case START_HASH: discardHashToken(); break; case KEY: case VALUE_NULL: case VALUE_STRING: case VALUE_BOOLEAN: case VALUE_LONG: case VALUE_DOUBLE: getEventType(); break; default: throw new IllegalStateException("unexpected token. token=" + state); } } getEventType(); break; case VALUE_NULL: getEventType(); break; default: throw new IllegalStateException("unexpected token. token=" + state); } }
JsonPullParser { public void discardHashToken() throws IOException, JsonFormatException, IllegalStateException { State state = lookAhead(); switch (state) { case START_HASH: getEventType(); while ((state = lookAhead()) != State.END_HASH) { switch (state) { case START_ARRAY: discardArrayToken(); break; case START_HASH: discardHashToken(); break; case KEY: case VALUE_NULL: case VALUE_STRING: case VALUE_BOOLEAN: case VALUE_LONG: case VALUE_DOUBLE: getEventType(); break; default: throw new IllegalStateException("unexpected token. token=" + state); } } getEventType(); break; case VALUE_NULL: getEventType(); break; default: throw new IllegalStateException("unexpected token. token=" + state); } } }
JsonPullParser { public void discardHashToken() throws IOException, JsonFormatException, IllegalStateException { State state = lookAhead(); switch (state) { case START_HASH: getEventType(); while ((state = lookAhead()) != State.END_HASH) { switch (state) { case START_ARRAY: discardArrayToken(); break; case START_HASH: discardHashToken(); break; case KEY: case VALUE_NULL: case VALUE_STRING: case VALUE_BOOLEAN: case VALUE_LONG: case VALUE_DOUBLE: getEventType(); break; default: throw new IllegalStateException("unexpected token. token=" + state); } } getEventType(); break; case VALUE_NULL: getEventType(); break; default: throw new IllegalStateException("unexpected token. token=" + state); } } JsonPullParser(); }
JsonPullParser { public void discardHashToken() throws IOException, JsonFormatException, IllegalStateException { State state = lookAhead(); switch (state) { case START_HASH: getEventType(); while ((state = lookAhead()) != State.END_HASH) { switch (state) { case START_ARRAY: discardArrayToken(); break; case START_HASH: discardHashToken(); break; case KEY: case VALUE_NULL: case VALUE_STRING: case VALUE_BOOLEAN: case VALUE_LONG: case VALUE_DOUBLE: getEventType(); break; default: throw new IllegalStateException("unexpected token. token=" + state); } } getEventType(); break; case VALUE_NULL: getEventType(); break; default: throw new IllegalStateException("unexpected token. token=" + state); } } JsonPullParser(); static JsonPullParser newParser(InputStream is); static JsonPullParser newParser(InputStream is, String charsetName); static JsonPullParser newParser(InputStream is, Charset charset); static JsonPullParser newParser(String json); static JsonPullParser newParser(Reader reader); JsonPullParser setLogEnable(); State lookAhead(); State getEventType(); int getSliceSize(); void discardValue(); void discardArrayToken(); void discardHashToken(); String getValueString(); long getValueLong(); double getValueDouble(); boolean getValueBoolean(); boolean isLogEnabled(); List<JsonSlice> getSlices(); }
JsonPullParser { public void discardHashToken() throws IOException, JsonFormatException, IllegalStateException { State state = lookAhead(); switch (state) { case START_HASH: getEventType(); while ((state = lookAhead()) != State.END_HASH) { switch (state) { case START_ARRAY: discardArrayToken(); break; case START_HASH: discardHashToken(); break; case KEY: case VALUE_NULL: case VALUE_STRING: case VALUE_BOOLEAN: case VALUE_LONG: case VALUE_DOUBLE: getEventType(); break; default: throw new IllegalStateException("unexpected token. token=" + state); } } getEventType(); break; case VALUE_NULL: getEventType(); break; default: throw new IllegalStateException("unexpected token. token=" + state); } } JsonPullParser(); static JsonPullParser newParser(InputStream is); static JsonPullParser newParser(InputStream is, String charsetName); static JsonPullParser newParser(InputStream is, Charset charset); static JsonPullParser newParser(String json); static JsonPullParser newParser(Reader reader); JsonPullParser setLogEnable(); State lookAhead(); State getEventType(); int getSliceSize(); void discardValue(); void discardArrayToken(); void discardHashToken(); String getValueString(); long getValueLong(); double getValueDouble(); boolean getValueBoolean(); boolean isLogEnabled(); List<JsonSlice> getSlices(); static final String DEFAULT_CHARSET_NAME; static final Charset DEFAULT_CHARSET; }