/** * Throws a helpful exception based on the current alphanumeric token. */ private JsonParserException createHelpfulException(char first, char[] expected, int failurePosition) throws JsonParserException { // Build the first part of the token StringBuilder errorToken = new StringBuilder(first + (expected == null ? "" : new String(expected, 0, failurePosition))); // Consume the whole pseudo-token to make a better error message while (isAsciiLetter(peekChar()) && errorToken.length() < 15) errorToken.append((char)advanceChar()); return createParseException(null, "Unexpected token '" + errorToken + "'" + (expected == null ? "" : ". Did you mean '" + first + new String(expected) + "'?"), true); }
/** * Throws a helpful exception based on the current alphanumeric token. */ private JsonParserException createHelpfulException(char first, char[] expected, int failurePosition) throws JsonParserException { // Build the first part of the token StringBuilder errorToken = new StringBuilder(first + (expected == null ? "" : new String(expected, 0, failurePosition))); // Consume the whole pseudo-token to make a better error message while (isAsciiLetter(peekChar()) && errorToken.length() < 15) errorToken.append((char)advanceChar()); return createParseException(null, "Unexpected token '" + errorToken + "'" + (expected == null ? "" : ". Did you mean '" + first + new String(expected) + "'?"), true); }
/** * Throws a helpful exception based on the current alphanumeric token. */ private JsonParserException createHelpfulException(char first, char[] expected, int failurePosition) throws JsonParserException { // Build the first part of the token StringBuilder errorToken = new StringBuilder(first + (expected == null ? "" : new String(expected, 0, failurePosition))); // Consume the whole pseudo-token to make a better error message while (isAsciiLetter(peekChar()) && errorToken.length() < 15) errorToken.append((char)advanceChar()); return createParseException(null, "Unexpected token '" + errorToken + "'" + (expected == null ? "" : ". Did you mean '" + first + new String(expected) + "'?"), true); }
while (isDigitCharacter(peekChar())) { char next = (char)advanceChar(); isDouble = next == '.' || next == 'e' || next == 'E' || isDouble;
while (isDigitCharacter(peekChar())) { char next = (char)advanceChar(); isDouble = next == '.' || next == 'e' || next == 'E' || isDouble;
while (isDigitCharacter(peekChar())) { char next = (char)advanceChar(); isDouble = next == '.' || next == 'e' || next == 'E' || isDouble;
/** * Expects a given string at the current position. */ private void consumeKeyword(char first, char[] expected) throws JsonParserException { for (int i = 0; i < expected.length; i++) if (advanceChar() != expected[i]) throw createHelpfulException(first, expected, i); // The token should end with something other than an ASCII letter if (isAsciiLetter(peekChar())) throw createHelpfulException(first, expected, expected.length); }
/** * Expects a given string at the current position. */ private void consumeKeyword(char first, char[] expected) throws JsonParserException { for (int i = 0; i < expected.length; i++) if (advanceChar() != expected[i]) throw createHelpfulException(first, expected, i); // The token should end with something other than an ASCII letter if (isAsciiLetter(peekChar())) throw createHelpfulException(first, expected, expected.length); }
/** * Expects a given string at the current position. */ private void consumeKeyword(char first, char[] expected) throws JsonParserException { for (int i = 0; i < expected.length; i++) if (advanceChar() != expected[i]) throw createHelpfulException(first, expected, i); // The token should end with something other than an ASCII letter if (isAsciiLetter(peekChar())) throw createHelpfulException(first, expected, expected.length); }