Peek at the next input string character to determine the pending JSON element type. @return JsonType indicating the pending JSON element type @throws JsonException if unable to determine the type of the pending element @throws UncheckedIOException if an I/O exception is encountered
()
| 122 | * @throws UncheckedIOException if an I/O exception is encountered |
| 123 | */ |
| 124 | public JsonType peek() { |
| 125 | skipWhitespace(input); |
| 126 | |
| 127 | switch (input.peek()) { |
| 128 | case 'f': |
| 129 | case 't': |
| 130 | return JsonType.BOOLEAN; |
| 131 | |
| 132 | case 'n': |
| 133 | return JsonType.NULL; |
| 134 | |
| 135 | case '-': |
| 136 | case '+': |
| 137 | case '0': |
| 138 | case '1': |
| 139 | case '2': |
| 140 | case '3': |
| 141 | case '4': |
| 142 | case '5': |
| 143 | case '6': |
| 144 | case '7': |
| 145 | case '8': |
| 146 | case '9': |
| 147 | return JsonType.NUMBER; |
| 148 | |
| 149 | case '"': |
| 150 | return isReadingName() ? JsonType.NAME : JsonType.STRING; |
| 151 | |
| 152 | case '{': |
| 153 | return JsonType.START_MAP; |
| 154 | |
| 155 | case '}': |
| 156 | return JsonType.END_MAP; |
| 157 | |
| 158 | case '[': |
| 159 | return JsonType.START_COLLECTION; |
| 160 | |
| 161 | case ']': |
| 162 | return JsonType.END_COLLECTION; |
| 163 | |
| 164 | case Input.EOF: |
| 165 | return JsonType.END; |
| 166 | |
| 167 | default: |
| 168 | char c = input.read(); |
| 169 | throw new JsonException("Unable to determine type from: " + c + ". " + input); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Read the next element of the JSON input stream as a boolean value. |
no test coverage detected