String (boolean anyPrimitiveAsString) { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } String result; if (p == PEEKED_UNQUOTED) { result = nextUnquotedValue(); } else if (p == PEEKED_SINGLE_QUOTED) { result = nextQuotedValue('\''); } else if (p == PEEKED_DOUBLE_QUOTED) { result = nextQuotedValue('"'); } else if (p == PEEKED_BUFFERED) { result = peekedString; peekedString = null; } else if (p == PEEKED_LONG) { result = Long.toString(peekedLong); } else if (p == PEEKED_NUMBER) { int end = position + peekedNumberLength; result = sourceSequence.subSequence(position, end).toString(); position = end; } else if (anyPrimitiveAsString && p == PEEKED_TRUE) { result = "true"; } else if (anyPrimitiveAsString && p == PEEKED_FALSE) { result = "false"; } else if (anyPrimitiveAsString && p == PEEKED_NULL) { result = "null"; } else { throw createParseError("Expected a string but was " + peek()); } peeked = PEEKED_NONE; return result; }