Changeset 13231 in josm for trunk/src/javax/json/stream/JsonGenerator.java
- Timestamp:
- 2017-12-23T02:40:43+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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">RFC4627</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 a 175 * 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 a 222 * 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 *
Note:
See TracChangeset
for help on using the changeset viewer.