Changeset 13231 in josm for trunk/src/javax/json/stream
- Timestamp:
- 2017-12-23T02:40:43+01:00 (7 years ago)
- Location:
- trunk/src/javax/json/stream
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/javax/json/stream/JsonGenerationException.java
r6756 r13231 2 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 3 * 4 * Copyright (c) 2012-201 3Oracle and/or its affiliates. All rights reserved.4 * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved. 5 5 * 6 6 * The contents of this file are subject to the terms of either the GNU … … 9 9 * may not use this file except in compliance with the License. You can 10 10 * obtain a copy of the License at 11 * https:// glassfish.dev.java.net/public/CDDL+GPL_1_1.html12 * or packager/legal/LICENSE.txt. See the License for the specific11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1 12 * or LICENSE.txt. See the License for the specific 13 13 * language governing permissions and limitations under the License. 14 14 * 15 15 * When distributing the software, include this License Header Notice in each 16 * file and include the License file at packager/legal/LICENSE.txt.16 * file and include the License file at LICENSE.txt. 17 17 * 18 18 * GPL Classpath Exception: … … 46 46 * {@code JsonGenerationException} indicates an incorrect JSON is 47 47 * being generated. 48 *49 * @author Jitendra Kotamraju50 48 */ 51 49 public class JsonGenerationException extends JsonException { -
trunk/src/javax/json/stream/JsonGenerator.java
r6756 r13231 2 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 3 * 4 * Copyright (c) 2011-201 3Oracle and/or its affiliates. All rights reserved.4 * Copyright (c) 2011-2017 Oracle and/or its affiliates. All rights reserved. 5 5 * 6 6 * The contents of this file are subject to the terms of either the GNU … … 9 9 * may not use this file except in compliance with the License. You can 10 10 * obtain a copy of the License at 11 * https:// glassfish.dev.java.net/public/CDDL+GPL_1_1.html12 * or packager/legal/LICENSE.txt. See the License for the specific11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1 12 * or LICENSE.txt. See the License for the specific 13 13 * language governing permissions and limitations under the License. 14 14 * 15 15 * When distributing the software, include this License Header Notice in each 16 * file and include the License file at packager/legal/LICENSE.txt.16 * file and include the License file at LICENSE.txt. 17 17 * 18 18 * GPL Classpath Exception: … … 98 98 * </pre> 99 99 * 100 * <p> 101 * Other JSON values (that are not JSON objects or arrays) can be created 102 * by calling the appropiate {@code write} methods. 103 * <p> 104 * The following example shows how to generate a JSON string: 105 * <pre><code> 106 * JsonGenerator generator = ...; 107 * generator.write("message").close(); 108 * </code></pre> 109 * 100 110 * {@code JsonGenerator} methods can be chained as in the following example: 101 * <p>102 * <a id="JsonGeneratorExample3"/>103 111 * <pre> 104 112 * <code> … … 130 138 * 131 139 * The example code above generates the following JSON (or equivalent): 132 * <p>133 140 * <pre> 134 141 * <code> … … 150 157 * 151 158 * The generated JSON text must strictly conform to the grammar defined in 152 * <a href="http://www.ietf.org/rfc/rfc 4627.txt">RFC 4627</a>.159 * <a href="http://www.ietf.org/rfc/rfc7159.txt">RFC 7159</a>. 153 160 * 154 161 * @see javax.json.Json 155 162 * @see JsonGeneratorFactory 156 * @author Jitendra Kotamraju157 163 */ 158 164 public interface JsonGenerator extends Flushable, /*Auto*/Closeable { … … 167 173 * Writes the JSON start object character. It starts a new child object 168 174 * context within which JSON name/value pairs can be written to the object. 169 * This method is valid only in an array context or in no context (when a175 * This method is valid only in an array context, field context or in no context (when a 170 176 * context is not yet started). This method can only be called once in 171 177 * no context. … … 174 180 * @throws javax.json.JsonException if an i/o error occurs (IOException 175 181 * would be cause of JsonException) 176 * @throws JsonGenerationException if this method is called within an 182 * @throws JsonGenerationException if this method is called within an 177 183 * object context or if it is called more than once in no context. 178 184 */ … … 188 194 * @throws javax.json.JsonException if an i/o error occurs (IOException 189 195 * would be cause of JsonException) 190 * @throws JsonGenerationException if this method is not called within an 196 * @throws JsonGenerationException if this method is not called within an 191 197 * object context 192 198 */ 193 199 JsonGenerator writeStartObject(String name); 200 201 /** 202 * Writes the JSON name with a colon. It starts a field context, in which valid 203 * options are writing a value, starting an object or an array. 204 * 205 * Writing value closes field context, if object or array is started after field name, 206 * field context will be closed after object/array close. 207 * 208 * @param name name of json field 209 * @return this generator 210 * @throws javax.json.JsonException if an i/o error occurs (IOException 211 * would be cause of JsonException) 212 * @throws JsonGenerationException if this method is not called within an 213 * object context 214 * 215 * @since 1.1 216 */ 217 JsonGenerator writeKey(String name); 194 218 195 219 /** 196 220 * Writes the JSON start array character. It starts a new child array 197 221 * context within which JSON values can be written to the array. This 198 * method is valid only in an array context or in no context (when a222 * method is valid only in an array context, field context or in no context (when a 199 223 * context is not yet started). This method can only be called once in 200 224 * no context. … … 203 227 * @throws javax.json.JsonException if an i/o error occurs (IOException 204 228 * would be cause of JsonException) 205 * @throws JsonGenerationException if this method is called within an 229 * @throws JsonGenerationException if this method is called within an 206 230 * object context or if called more than once in no context 207 231 */ … … 217 241 * @throws javax.json.JsonException if an i/o error occurs (IOException 218 242 * would be cause of JsonException) 219 * @throws JsonGenerationException if this method is not called within 243 * @throws JsonGenerationException if this method is not called within 220 244 * an object context 221 245 */ … … 232 256 * @throws javax.json.JsonException if an i/o error occurs (IOException 233 257 * would be cause of JsonException) 234 * @throws JsonGenerationException if this method is not called within an 258 * @throws JsonGenerationException if this method is not called within an 235 259 * object context 236 260 */ … … 248 272 * @throws javax.json.JsonException if an i/o error occurs (IOException 249 273 * would be cause of JsonException) 250 * @throws JsonGenerationException if this method is not called within an 274 * @throws JsonGenerationException if this method is not called within an 251 275 * object context 252 276 */ … … 266 290 * @throws javax.json.JsonException if an i/o error occurs (IOException 267 291 * would be cause of JsonException) 268 * @throws JsonGenerationException if this method is not called within an 292 * @throws JsonGenerationException if this method is not called within an 269 293 * object context. 270 294 */ … … 283 307 * @throws javax.json.JsonException if an i/o error occurs (IOException 284 308 * would be cause of JsonException) 285 * @throws JsonGenerationException if this method is not called within an 309 * @throws JsonGenerationException if this method is not called within an 286 310 * object context. 287 311 */ … … 301 325 * @throws javax.json.JsonException if an i/o error occurs (IOException 302 326 * would be cause of JsonException) 303 * @throws JsonGenerationException if this method is not called within an 327 * @throws JsonGenerationException if this method is not called within an 304 328 * object context. 305 329 */ … … 319 343 * @throws javax.json.JsonException if an i/o error occurs (IOException 320 344 * would be cause of JsonException) 321 * @throws JsonGenerationException if this method is not called within an 345 * @throws JsonGenerationException if this method is not called within an 322 346 * object context. 323 347 */ … … 337 361 * @throws javax.json.JsonException if an i/o error occurs (IOException 338 362 * would be cause of JsonException) 339 * @throws NumberFormatException if the value is Not-a-Number (NaN) or infinity.363 * @throws NumberFormatException if the value is Not-a-Number (NaN) or infinity. 340 364 * @throws JsonGenerationException if this method is not called within an 341 365 * object context … … 345 369 /** 346 370 * Writes a JSON name/boolean value pair in the current object context. 347 * If value is true, it writes the JSON {@code true} value, otherwise 371 * If value is true, it writes the JSON {@code true} value, otherwise 348 372 * it writes the JSON {@code false} value. 349 373 * … … 369 393 * @throws javax.json.JsonException if an i/o error occurs (IOException 370 394 * would be cause of JsonException) 371 * @throws JsonGenerationException if this method is not called within an 395 * @throws JsonGenerationException if this method is not called within an 372 396 * object context 373 397 */ … … 376 400 /** 377 401 * Writes the end of the current context. If the current context is 378 * an array context, this method writes the end-of-array character (']'). 402 * an array context, this method writes the end-of-array character (']'). 379 403 * If the current context is an object context, this method writes the 380 404 * end-of-object character ('}'). After writing the end of the current 381 405 * context, the parent context becomes the new current context. 406 * If parent context is field context, it is closed. 382 407 * 383 408 * @return this generator … … 390 415 /** 391 416 * Writes the specified value as a JSON value within 392 * the current array context.393 * 394 * @param value a value to be written in current JSON array 395 * @return this generator 396 * @throws javax.json.JsonException if an i/o error occurs (IOException 397 * would be cause of JsonException) 398 * @throws JsonGenerationException if this method is not called within an 399 * array context.417 * the current array, field or root context. 418 * 419 * @param value a value to be written in current JSON array 420 * @return this generator 421 * @throws javax.json.JsonException if an i/o error occurs (IOException 422 * would be cause of JsonException) 423 * @throws JsonGenerationException if this method is not called within an 424 * array or root context. 400 425 */ 401 426 JsonGenerator write(JsonValue value); … … 403 428 /** 404 429 * Writes the specified value as a JSON string value within 405 * the current array context.406 * 407 * @param value a value to be written in current JSON array 408 * @return this generator 409 * @throws javax.json.JsonException if an i/o error occurs (IOException 410 * would be cause of JsonException) 411 * @throws JsonGenerationException if this method is not called within an 412 * array context430 * the current array, field or root context. 431 * 432 * @param value a value to be written in current JSON array 433 * @return this generator 434 * @throws javax.json.JsonException if an i/o error occurs (IOException 435 * would be cause of JsonException) 436 * @throws JsonGenerationException if this method is not called within an 437 * array or root context. 413 438 */ 414 439 JsonGenerator write(String value); … … 416 441 /** 417 442 * Writes the specified value as a JSON number value within 418 * the current array context. The specified value's {@code toString()}443 * the current array, field or root context. The specified value's {@code toString()} 419 444 * is used as the the text value for writing. 420 445 * … … 423 448 * @throws javax.json.JsonException if an i/o error occurs (IOException 424 449 * would be cause of JsonException) 425 * @throws JsonGenerationException if this method is not called within an 426 * array context450 * @throws JsonGenerationException if this method is not called within an 451 * array or root context. 427 452 * 428 453 * @see javax.json.JsonNumber … … 432 457 /** 433 458 * Writes the specified value as a JSON number value within 434 * the current array context. The string {@code new BigDecimal(value).toString()}459 * the current array, field or root context. The string {@code new BigDecimal(value).toString()} 435 460 * is used as the text value for writing. 436 461 * … … 439 464 * @throws javax.json.JsonException if an i/o error occurs (IOException 440 465 * would be cause of JsonException) 441 * @throws JsonGenerationException if this method is not called within an 442 * array context466 * @throws JsonGenerationException if this method is not called within an 467 * array or root context. 443 468 * 444 469 * @see javax.json.JsonNumber … … 448 473 /** 449 474 * Writes the specified value as a JSON number value within 450 * the current array context. The string {@code new BigDecimal(value).toString()}475 * the current array, field or root context. The string {@code new BigDecimal(value).toString()} 451 476 * is used as the text value for writing. 452 477 * … … 455 480 * @throws javax.json.JsonException if an i/o error occurs (IOException 456 481 * would be cause of JsonException) 457 * @throws JsonGenerationException if this method is not called within an 458 * array context482 * @throws JsonGenerationException if this method is not called within an 483 * array or root context. 459 484 */ 460 485 JsonGenerator write(int value); … … 462 487 /** 463 488 * Writes the specified value as a JSON number value within 464 * the current array context. The string {@code new BigDecimal(value).toString()}489 * the current array, field or root context. The string {@code new BigDecimal(value).toString()} 465 490 * is used as the text value for writing. 466 491 * … … 469 494 * @throws javax.json.JsonException if an i/o error occurs (IOException 470 495 * would be cause of JsonException) 471 * @throws JsonGenerationException if this method is not called within an 472 * array context496 * @throws JsonGenerationException if this method is not called within an 497 * array or root context. 473 498 */ 474 499 JsonGenerator write(long value); … … 476 501 /** 477 502 * Writes the specified value as a JSON number value within the current 478 * array context. The string {@code BigDecimal.valueOf(value).toString()}503 * array, field or root context. The string {@code BigDecimal.valueOf(value).toString()} 479 504 * is used as the text value for writing. 480 505 * … … 483 508 * @throws javax.json.JsonException if an i/o error occurs (IOException 484 509 * would be cause of JsonException) 485 * @throws JsonGenerationException if this method is not called within an 486 * array context487 * @throws NumberFormatException if the value is Not-a-Number (NaN) or infinity.510 * @throws JsonGenerationException if this method is not called within an 511 * array or root context. 512 * @throws NumberFormatException if the value is Not-a-Number (NaN) or infinity. 488 513 */ 489 514 JsonGenerator write(double value); 490 515 491 516 /** 492 * Writes a JSON true or false value within the current array context.493 * If value is true, this method writes the JSON {@code true} value, 517 * Writes a JSON true or false value within the current array, field or root context. 518 * If value is true, this method writes the JSON {@code true} value, 494 519 * otherwise it writes the JSON {@code false} value. 495 520 * … … 498 523 * @throws javax.json.JsonException if an i/o error occurs (IOException 499 524 * would be cause of JsonException) 500 * @throws JsonGenerationException if this method is not called within an 501 * array context.525 * @throws JsonGenerationException if this method is not called within an 526 * array or root context. 502 527 */ 503 528 JsonGenerator write(boolean value); 504 529 505 530 /** 506 * Writes a JSON null value within the current array context.507 * 508 * @return this generator 509 * @throws javax.json.JsonException if an i/o error occurs (IOException 510 * would be cause of JsonException) 511 * @throws JsonGenerationException if this method is not called within an 512 * array context531 * Writes a JSON null value within the current array, field or root context. 532 * 533 * @return this generator 534 * @throws javax.json.JsonException if an i/o error occurs (IOException 535 * would be cause of JsonException) 536 * @throws JsonGenerationException if this method is not called within an 537 * array or root context. 513 538 */ 514 539 JsonGenerator writeNull(); 515 540 516 541 /** 517 * Closes this generator and frees any resources associated with it. 542 * Closes this generator and frees any resources associated with it. 518 543 * This method closes the underlying output source. 519 544 * -
trunk/src/javax/json/stream/JsonGeneratorFactory.java
r6756 r13231 2 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 3 * 4 * Copyright (c) 2011-201 3Oracle and/or its affiliates. All rights reserved.4 * Copyright (c) 2011-2017 Oracle and/or its affiliates. All rights reserved. 5 5 * 6 6 * The contents of this file are subject to the terms of either the GNU … … 9 9 * may not use this file except in compliance with the License. You can 10 10 * obtain a copy of the License at 11 * https:// glassfish.dev.java.net/public/CDDL+GPL_1_1.html12 * or packager/legal/LICENSE.txt. See the License for the specific11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1 12 * or LICENSE.txt. See the License for the specific 13 13 * language governing permissions and limitations under the License. 14 14 * 15 15 * When distributing the software, include this License Header Notice in each 16 * file and include the License file at packager/legal/LICENSE.txt.16 * file and include the License file at LICENSE.txt. 17 17 * 18 18 * GPL Classpath Exception: … … 67 67 * <p> All the methods in this class are safe for use by multiple concurrent 68 68 * threads. 69 *70 * @author Jitendra Kotamraju71 69 */ 72 70 public interface JsonGeneratorFactory { … … 77 75 * 78 76 * @param writer i/o writer to which JSON is written 77 * @return the created JSON generator 79 78 */ 80 79 JsonGenerator createGenerator(Writer writer); … … 86 85 * 87 86 * @param out i/o stream to which JSON is written 87 * @return the created JSON generator 88 88 */ 89 89 JsonGenerator createGenerator(OutputStream out); … … 96 96 * @param out i/o stream to which JSON is written 97 97 * @param charset a charset 98 * @return the created JSON generator 98 99 */ 99 100 JsonGenerator createGenerator(OutputStream out, Charset charset); -
trunk/src/javax/json/stream/JsonLocation.java
r6756 r13231 2 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 3 * 4 * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.4 * Copyright (c) 2013-2017 Oracle and/or its affiliates. All rights reserved. 5 5 * 6 6 * The contents of this file are subject to the terms of either the GNU … … 9 9 * may not use this file except in compliance with the License. You can 10 10 * obtain a copy of the License at 11 * https:// glassfish.dev.java.net/public/CDDL+GPL_1_1.html12 * or packager/legal/LICENSE.txt. See the License for the specific11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1 12 * or LICENSE.txt. See the License for the specific 13 13 * language governing permissions and limitations under the License. 14 14 * 15 15 * When distributing the software, include this License Header Notice in each 16 * file and include the License file at packager/legal/LICENSE.txt.16 * file and include the License file at LICENSE.txt. 17 17 * 18 18 * GPL Classpath Exception: … … 52 52 * {@link javax.json.JsonArray JsonArray} input source, all the methods in 53 53 * this class return -1. 54 *55 * @author Jitendra Kotamraju56 54 * @see JsonParser 57 55 * @see JsonParsingException … … 60 58 61 59 /** 62 * Return the line number for the current JSON event in the input source.60 * Return the line number (starts with 1 for the first line) for the current JSON event in the input source. 63 61 * 64 * @return the line number or -1 if none is available62 * @return the line number (starts with 1 for the first line) or -1 if none is available 65 63 */ 66 64 long getLineNumber(); 67 65 68 66 /** 69 * Return the column number for the current JSON event in the input source.67 * Return the column number (starts with 1 for the first column) for the current JSON event in the input source. 70 68 * 71 * @return the column number or -1 if none is available69 * @return the column number (starts with 1 for the first column) or -1 if none is available 72 70 */ 73 71 long getColumnNumber(); -
trunk/src/javax/json/stream/JsonParser.java
r6756 r13231 2 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 3 * 4 * Copyright (c) 2011-201 3Oracle and/or its affiliates. All rights reserved.4 * Copyright (c) 2011-2017 Oracle and/or its affiliates. All rights reserved. 5 5 * 6 6 * The contents of this file are subject to the terms of either the GNU … … 9 9 * may not use this file except in compliance with the License. You can 10 10 * obtain a copy of the License at 11 * https:// glassfish.dev.java.net/public/CDDL+GPL_1_1.html12 * or packager/legal/LICENSE.txt. See the License for the specific11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1 12 * or LICENSE.txt. See the License for the specific 13 13 * language governing permissions and limitations under the License. 14 14 * 15 15 * When distributing the software, include this License Header Notice in each 16 * file and include the License file at packager/legal/LICENSE.txt.16 * file and include the License file at LICENSE.txt. 17 17 * 18 18 * GPL Classpath Exception: … … 44 44 import java.io.Closeable; 45 45 import java.math.BigDecimal; 46 import java.util.stream.Stream; 47 import java.util.Map; 48 49 import javax.json.JsonValue; 50 import javax.json.JsonObject; 51 import javax.json.JsonArray; 46 52 47 53 /** 48 54 * Provides forward, read-only access to JSON data in a streaming way. This 49 * is the most efficient way for reading JSON data. The class 55 * is the most efficient way for reading JSON data. 56 * This is the only way to parse and process JSON data that are too big to be loaded in memory. 57 * <p>The class 50 58 * {@link javax.json.Json} contains methods to create parsers from input 51 59 * sources ({@link java.io.InputStream} and {@link java.io.Reader}). … … 97 105 * 98 106 * <p> 99 * <a id="JsonParserExample2"/>100 * <p>101 107 * <b>For example</b>, for the following JSON: 102 108 * <pre> … … 113 119 * locations below (marked in bold): 114 120 * 115 * <p>116 121 * <pre> 117 122 * {<B>START_OBJECT</B> … … 124 129 * </pre> 125 130 * 126 * <p> 127 * The methods {@code next()} and {@code hasNext()} enable iteration over 131 * The methods {@link #next()} and {@link #hasNext()} enable iteration over 128 132 * parser events to process JSON data. {@code JsonParser} provides get methods 129 133 * to obtain the value at the current state of the parser. For example, the 130 134 * following code shows how to obtain the value "John" from the JSON above: 131 135 * 132 * <p>133 136 * <pre> 134 137 * <code> … … 140 143 * </pre> 141 144 * 145 * Starting in version 1.1, it is possible to build a partial JSON object 146 * model from the stream, at the current parser position. 147 * The methods {@link #getArray} and {@link #getObject} can be used to read in 148 * a {@code JsonArray} or {@code JsonObject}. For example, the following code 149 * shows how to obtain the phoneNumber in a JsonArray, from the JSON above: 150 * 151 * <pre><code> 152 * while (parser.hasNext() { 153 * Event event = parser.next(); 154 * if (event == JsonParser.Event.KEY_NAME ) { 155 * String key = getString(); 156 * event = parser.next(); 157 * if (key.equals("phoneNumber") { 158 * JsonArray phones = parser.getArray(); 159 * } 160 * } 161 * } 162 * </code></pre> 163 * 164 * The methods {@link #getArrayStream} and {@link #getObjectStream} can be used 165 * to get a stream of the elements of a {@code JsonArray} or {@code JsonObject}. 166 * For example, the following code shows another way to obtain John's phoneNumber 167 * in a {@code JsonArray} : 168 * 169 * <pre>{@code 170 * Event event = parser.next(); // START_OBJECT 171 * JsonArray phones = (JsonArray) 172 * parser.getObjectStream().filter(e->e.getKey().equals("phoneNumber")) 173 * .map(e->e.getValue()) 174 * .findFirst() 175 * .get(); 176 * }</pre> 177 * 178 * The methods {@link #skipArray} and {@link #skipObject} can be used to 179 * skip tokens and position the parser to {@code END_ARRAY} or 180 * {@code END_OBJECT}. 181 * <p> 182 * {@code JsonParser} can be used to parse sequence of JSON values that are not 183 * enclosed in a JSON array, e.g. { } { }. The following code demonstrates how 184 * to parse such sequence. 185 * <pre><code> 186 * JsonParser parser = Json.createParser(...); 187 * while (parser.hasNext) { 188 * parser.next(); // advance parser state 189 * JsonValue value = parser.getValue(); 190 * } 191 * </code></pre> 192 * 142 193 * @see javax.json.Json 143 194 * @see JsonParserFactory 144 * @author Jitendra Kotamraju145 195 */ 146 196 public interface JsonParser extends /*Auto*/Closeable { … … 223 273 * @throws java.util.NoSuchElementException if there are no more parsing 224 274 * states. 275 * @return the event for the next parsing state 225 276 */ 226 277 Event next(); … … 319 370 320 371 /** 321 * getJsonValue(JsonObject.class) is valid in the START_OBJECT state and 322 * moves the cursor to END_OBJECT. 323 * 324 * getJsonValue(JsonArray.class) is valid in the START_ARRAY state 325 * and moves the cursor to END_ARRAY. 326 * 327 * getJsonValue(JsonString.class) is valid in the VALUE_STRING state. 328 * 329 * getJsonValue(JsonNumber.class) is valid in the VALUE_NUMBER state. 330 * 331 * @param clazz 332 * @return 333 * 334 public <T extends JsonValue> T getJsonValue(Class<T> clazz); 335 */ 372 * Returns a {@code JsonObject} and advances the parser to the 373 * corresponding {@code END_OBJECT}. 374 * 375 * @return the {@code JsonObject} at the current parser position 376 * 377 * @throws IllegalStateException when the parser state is not 378 * {@code START_OBJECT} 379 * 380 * @since 1.1 381 */ 382 default public JsonObject getObject() { 383 throw new UnsupportedOperationException(); 384 } 385 386 /** 387 * Returns a {@code JsonValue} at the current parser position. 388 * If the parser state is {@code START_ARRAY}, the behavior is 389 * the same as {@link #getArray}. If the parser state is 390 * {@code START_OBJECT}, the behavior is the same as 391 * {@link #getObject}. For all other cases, if applicable, the JSON value is 392 * read and returned. 393 * 394 * @return the {@code JsonValue} at the current parser position. 395 * @throws IllegalStateException when the parser state is 396 * {@code END_OBJECT} or {@code END_ARRAY} 397 * 398 * @since 1.1 399 */ 400 default public JsonValue getValue() { 401 throw new UnsupportedOperationException(); 402 } 403 404 /** 405 * Returns a {@code JsonArray} and advance the parser to the 406 * the corresponding {@code END_ARRAY}. 407 * 408 * @return the {@code JsonArray} at the current parser position 409 * 410 * @throws IllegalStateException when the parser state is not 411 * {@code START_ARRAY} 412 * 413 * @since 1.1 414 */ 415 default public JsonArray getArray() { 416 throw new UnsupportedOperationException(); 417 } 418 419 /** 420 * Returns a stream of the {@code JsonArray} elements. 421 * The parser state must be {@code START_ARRAY}. 422 * The elements are read lazily, on an as-needed basis, as 423 * required by the stream operations. 424 * If the stream operations do not consume 425 * all of the array elements, {@link skipArray} can be used to 426 * skip the unprocessed array elements. 427 * 428 * @return a stream of elements of the {@code JsonArray} 429 * 430 * @throws IllegalStateException when the parser state is not 431 * {@code START_ARRAY} 432 * 433 * @since 1.1 434 */ 435 default public Stream<JsonValue> getArrayStream() { 436 throw new UnsupportedOperationException(); 437 } 438 439 /** 440 * Returns a stream of the {@code JsonObject}'s 441 * name/value pairs. The parser state must be {@code START_OBJECT}. 442 * The name/value pairs are read lazily, on an as-needed basis, as 443 * required by the stream operations. 444 * If the stream operations do not consume 445 * all of the object's name/value pairs, {@link skipObject} can be 446 * used to skip the unprocessed elements. 447 * 448 * @return a stream of name/value pairs of the {@code JsonObject} 449 * 450 * @throws IllegalStateException when the parser state is not 451 * {@code START_OBJECT} 452 * 453 * @since 1.1 454 */ 455 default public Stream<Map.Entry<String,JsonValue>> getObjectStream() { 456 throw new UnsupportedOperationException(); 457 } 458 459 /** 460 * Returns a stream of {@code JsonValue} from a sequence of 461 * JSON values. The values are read lazily, on an as-needed basis, 462 * as needed by the stream operations. 463 * 464 * @return a Stream of {@code JsonValue} 465 * 466 * @throws IllegalStateException if the parser is in an array or object. 467 * 468 * @since 1.1 469 */ 470 default public Stream<JsonValue> getValueStream() { 471 throw new UnsupportedOperationException(); 472 } 473 474 /** 475 * Advance the parser to {@code END_ARRAY}. 476 * If the parser is in array context, i.e. it has previously 477 * encountered a {@code START_ARRAY} without encountering the 478 * corresponding {@code END_ARRAY}, the parser is advanced to 479 * the corresponding {@code END_ARRAY}. 480 * If the parser is not in any array context, nothing happens. 481 * 482 * @since 1.1 483 */ 484 default public void skipArray() { 485 throw new UnsupportedOperationException(); 486 } 487 488 /** 489 * Advance the parser to {@code END_OBJECT}. 490 * If the parser is in object context, i.e. it has previously 491 * encountered a {@code START_OBJECT} without encountering the 492 * corresponding {@code END_OBJECT}, the parser is advanced to 493 * the corresponding {@code END_OBJECT}. 494 * If the parser is not in any object context, nothing happens. 495 * 496 * @since 1.1 497 */ 498 default public void skipObject() { 499 throw new UnsupportedOperationException(); 500 } 336 501 337 502 /** … … 344 509 @Override 345 510 void close(); 346 347 511 } -
trunk/src/javax/json/stream/JsonParserFactory.java
r6756 r13231 2 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 3 * 4 * Copyright (c) 2011-201 3Oracle and/or its affiliates. All rights reserved.4 * Copyright (c) 2011-2017 Oracle and/or its affiliates. All rights reserved. 5 5 * 6 6 * The contents of this file are subject to the terms of either the GNU … … 9 9 * may not use this file except in compliance with the License. You can 10 10 * obtain a copy of the License at 11 * https:// glassfish.dev.java.net/public/CDDL+GPL_1_1.html12 * or packager/legal/LICENSE.txt. See the License for the specific11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1 12 * or LICENSE.txt. See the License for the specific 13 13 * language governing permissions and limitations under the License. 14 14 * 15 15 * When distributing the software, include this License Header Notice in each 16 * file and include the License file at packager/legal/LICENSE.txt.16 * file and include the License file at LICENSE.txt. 17 17 * 18 18 * GPL Classpath Exception: … … 69 69 * <p> All the methods in this class are safe for use by multiple concurrent 70 70 * threads. 71 *72 * @author Jitendra Kotamraju73 71 */ 74 72 public interface JsonParserFactory { … … 78 76 * 79 77 * @param reader a i/o reader from which JSON is to be read 78 * @return the created JSON parser 80 79 */ 81 80 JsonParser createParser(Reader reader); … … 84 83 * Creates a JSON parser from the specified byte stream. 85 84 * The character encoding of the stream is determined 86 * as specified in <a href="http://tools.ietf.org/rfc/rfc 4627.txt">RFC 4627</a>.85 * as specified in <a href="http://tools.ietf.org/rfc/rfc7159.txt">RFC 7159</a>. 87 86 * 88 87 * @param in i/o stream from which JSON is to be read 88 * @return the created JSON parser 89 89 * @throws javax.json.JsonException if encoding cannot be determined 90 90 * or i/o error (IOException would be cause of JsonException) … … 99 99 * @param in i/o stream from which JSON is to be read 100 100 * @param charset a charset 101 * @return the created JSON parser 101 102 */ 102 103 JsonParser createParser(InputStream in, Charset charset); … … 106 107 * 107 108 * @param obj a JSON object 109 * @return the created JSON parser 108 110 */ 109 111 JsonParser createParser(JsonObject obj); … … 113 115 * 114 116 * @param array a JSON array 117 * @return the created JSON parser 115 118 */ 116 119 JsonParser createParser(JsonArray array); -
trunk/src/javax/json/stream/JsonParsingException.java
r6756 r13231 2 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 3 * 4 * Copyright (c) 2012-201 3Oracle and/or its affiliates. All rights reserved.4 * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved. 5 5 * 6 6 * The contents of this file are subject to the terms of either the GNU … … 9 9 * may not use this file except in compliance with the License. You can 10 10 * obtain a copy of the License at 11 * https:// glassfish.dev.java.net/public/CDDL+GPL_1_1.html12 * or packager/legal/LICENSE.txt. See the License for the specific11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1 12 * or LICENSE.txt. See the License for the specific 13 13 * language governing permissions and limitations under the License. 14 14 * 15 15 * When distributing the software, include this License Header Notice in each 16 * file and include the License file at packager/legal/LICENSE.txt.16 * file and include the License file at LICENSE.txt. 17 17 * 18 18 * GPL Classpath Exception: … … 46 46 * {@code JsonParsingException} is used when an incorrect JSON is 47 47 * being parsed. 48 *49 * @author Jitendra Kotamraju50 48 */ 51 49 public class JsonParsingException extends JsonException { -
trunk/src/javax/json/stream/package-info.java
r6756 r13231 2 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 3 * 4 * Copyright (c) 2012-201 3Oracle and/or its affiliates. All rights reserved.4 * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved. 5 5 * 6 6 * The contents of this file are subject to the terms of either the GNU … … 9 9 * may not use this file except in compliance with the License. You can 10 10 * obtain a copy of the License at 11 * https:// glassfish.dev.java.net/public/CDDL+GPL_1_1.html12 * or packager/legal/LICENSE.txt. See the License for the specific11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1 12 * or LICENSE.txt. See the License for the specific 13 13 * language governing permissions and limitations under the License. 14 14 * 15 15 * When distributing the software, include this License Header Notice in each 16 * file and include the License file at packager/legal/LICENSE.txt.16 * file and include the License file at LICENSE.txt. 17 17 * 18 18 * GPL Classpath Exception: … … 68 68 * 69 69 * @since JSON Processing 1.0 70 * @author Jitendra Kotamraju71 70 */ 72 71 package javax.json.stream;
Note:
See TracChangeset
for help on using the changeset viewer.