/** * Closes the current scope by appending any necessary whitespace and the * given bracket. */ private JsonWriter close(int empty, int nonempty, String closeBracket) throws IOException { int context = peekScope(); if (context != nonempty && context != empty) { throw new IllegalStateException("Nesting problem."); } if (deferredName != null) { throw new IllegalStateException("Dangling name: " + deferredName); } stackSize--; pathNames[stackSize] = null; // Free the last path name so that it can be garbage collected! pathIndices[stackSize - 1]++; if (context == nonempty) { newline(); } sink.writeUtf8(closeBracket); return this; }
/** * Inserts any necessary separators and whitespace before a name. Also * adjusts the stack to expect the name's value. */ private void beforeName() throws IOException { int context = peekScope(); if (context == NONEMPTY_OBJECT) { // first in object sink.writeByte(','); } else if (context != EMPTY_OBJECT) { // not in an object! throw new IllegalStateException("Nesting problem."); } newline(); replaceTop(DANGLING_NAME); }
switch (peekScope()) { case NONEMPTY_DOCUMENT: if (!lenient) {
/** * Closes the current scope by appending any necessary whitespace and the * given bracket. */ private JsonWriter close(int empty, int nonempty, String closeBracket) throws IOException { int context = peekScope(); if (context != nonempty && context != empty) { throw new IllegalStateException("Nesting problem."); } if (deferredName != null) { throw new IllegalStateException("Dangling name: " + deferredName); } stackSize--; pathNames[stackSize] = null; // Free the last path name so that it can be garbage collected! pathIndices[stackSize - 1]++; if (context == nonempty) { newline(); } sink.writeUtf8(closeBracket); return this; }
/** * Closes the current scope by appending any necessary whitespace and the * given bracket. */ private JsonWriter close(int empty, int nonempty, String closeBracket) throws IOException { int context = peekScope(); if (context != nonempty && context != empty) { throw new IllegalStateException("Nesting problem."); } if (deferredName != null) { throw new IllegalStateException("Dangling name: " + deferredName); } stackSize--; pathNames[stackSize] = null; // Free the last path name so that it can be garbage collected! pathIndices[stackSize - 1]++; if (context == nonempty) { newline(); } sink.writeUtf8(closeBracket); return this; }
/** * Inserts any necessary separators and whitespace before a name. Also * adjusts the stack to expect the name's value. */ private void beforeName() throws IOException { int context = peekScope(); if (context == NONEMPTY_OBJECT) { // first in object sink.writeByte(','); } else if (context != EMPTY_OBJECT) { // not in an object! throw new IllegalStateException("Nesting problem."); } newline(); replaceTop(DANGLING_NAME); }
/** * Inserts any necessary separators and whitespace before a name. Also * adjusts the stack to expect the name's value. */ private void beforeName() throws IOException { int context = peekScope(); if (context == NONEMPTY_OBJECT) { // first in object sink.writeByte(','); } else if (context != EMPTY_OBJECT) { // not in an object! throw new IllegalStateException("Nesting problem."); } newline(); replaceTop(DANGLING_NAME); }
switch (peekScope()) { case NONEMPTY_DOCUMENT: if (!lenient) {
switch (peekScope()) { case NONEMPTY_DOCUMENT: if (!lenient) {