Changeset 13231 in josm for trunk/src/javax/json/stream


Ignore:
Timestamp:
2017-12-23T02:40:43+01:00 (7 years ago)
Author:
Don-vip
Message:

see #15682 - upgrade to JSR 374 (JSON Processing) API 1.1.2

Location:
trunk/src/javax/json/stream
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/javax/json/stream/JsonGenerationException.java

    r6756 r13231  
    22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    33 *
    4  * Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved.
     4 * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
    55 *
    66 * The contents of this file are subject to the terms of either the GNU
     
    99 * may not use this file except in compliance with the License.  You can
    1010 * obtain a copy of the License at
    11  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
    12  * or packager/legal/LICENSE.txt.  See the License for the specific
     11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1
     12 * or LICENSE.txt.  See the License for the specific
    1313 * language governing permissions and limitations under the License.
    1414 *
    1515 * 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.
    1717 *
    1818 * GPL Classpath Exception:
     
    4646 * {@code JsonGenerationException} indicates an incorrect JSON is
    4747 * being generated.
    48  *
    49  * @author Jitendra Kotamraju
    5048 */
    5149public class JsonGenerationException extends JsonException {
  • trunk/src/javax/json/stream/JsonGenerator.java

    r6756 r13231  
    22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    33 *
    4  * Copyright (c) 2011-2013 Oracle and/or its affiliates. All rights reserved.
     4 * Copyright (c) 2011-2017 Oracle and/or its affiliates. All rights reserved.
    55 *
    66 * The contents of this file are subject to the terms of either the GNU
     
    99 * may not use this file except in compliance with the License.  You can
    1010 * obtain a copy of the License at
    11  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
    12  * or packager/legal/LICENSE.txt.  See the License for the specific
     11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1
     12 * or LICENSE.txt.  See the License for the specific
    1313 * language governing permissions and limitations under the License.
    1414 *
    1515 * 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.
    1717 *
    1818 * GPL Classpath Exception:
     
    9898 * </pre>
    9999 *
     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 *
    100110 * {@code JsonGenerator} methods can be chained as in the following example:
    101  * <p>
    102  * <a id="JsonGeneratorExample3"/>
    103111 * <pre>
    104112 * <code>
     
    130138 *
    131139 * The example code above generates the following JSON (or equivalent):
    132  * <p>
    133140 * <pre>
    134141 * <code>
     
    150157 *
    151158 * The generated JSON text must strictly conform to the grammar defined in
    152  * <a href="http://www.ietf.org/rfc/rfc4627.txt">RFC 4627</a>.
     159 * <a href="http://www.ietf.org/rfc/rfc7159.txt">RFC 7159</a>.
    153160 *
    154161 * @see javax.json.Json
    155162 * @see JsonGeneratorFactory
    156  * @author Jitendra Kotamraju
    157163 */
    158164public interface JsonGenerator extends Flushable, /*Auto*/Closeable {
     
    167173     * Writes the JSON start object character. It starts a new child object
    168174     * 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
    170176     * context is not yet started). This method can only be called once in
    171177     * no context.
     
    174180     * @throws javax.json.JsonException if an i/o error occurs (IOException
    175181     * 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
    177183     *      object context or if it is called more than once in no context.
    178184     */
     
    188194     * @throws javax.json.JsonException if an i/o error occurs (IOException
    189195     * 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
    191197     *     object context
    192198     */
    193199    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);
    194218
    195219    /**
    196220     * Writes the JSON start array character. It starts a new child array
    197221     * 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
    199223     * context is not yet started). This method can only be called once in
    200224     * no context.
     
    203227     * @throws javax.json.JsonException if an i/o error occurs (IOException
    204228     * 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
    206230     *      object context or if called more than once in no context
    207231     */
     
    217241     * @throws javax.json.JsonException if an i/o error occurs (IOException
    218242     * 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
    220244     *      an object context
    221245     */
     
    232256     * @throws javax.json.JsonException if an i/o error occurs (IOException
    233257     * 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
    235259     *      object context
    236260     */
     
    248272     * @throws javax.json.JsonException if an i/o error occurs (IOException
    249273     * 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
    251275     *      object context
    252276     */
     
    266290     * @throws javax.json.JsonException if an i/o error occurs (IOException
    267291     * 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
    269293     *      object context.
    270294     */
     
    283307     * @throws javax.json.JsonException if an i/o error occurs (IOException
    284308     * 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
    286310     *      object context.
    287311     */
     
    301325     * @throws javax.json.JsonException if an i/o error occurs (IOException
    302326     * 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
    304328     *      object context.
    305329     */
     
    319343     * @throws javax.json.JsonException if an i/o error occurs (IOException
    320344     * 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
    322346     *      object context.
    323347     */
     
    337361     * @throws javax.json.JsonException if an i/o error occurs (IOException
    338362     * 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.
    340364     * @throws JsonGenerationException if this method is not called within an
    341365     *      object context
     
    345369    /**
    346370     * 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
    348372     * it writes the JSON {@code false} value.
    349373     *
     
    369393     * @throws javax.json.JsonException if an i/o error occurs (IOException
    370394     * 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
    372396     *      object context
    373397     */
     
    376400    /**
    377401     * 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 (']').
    379403     * If the current context is an object context, this method writes the
    380404     * end-of-object character ('}'). After writing the end of the current
    381405     * context, the parent context becomes the new current context.
     406     * If parent context is field context, it is closed.
    382407     *
    383408     * @return this generator
     
    390415    /**
    391416     * 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.
    400425     */
    401426    JsonGenerator write(JsonValue value);
     
    403428    /**
    404429     * 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 context
     430     * 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.
    413438     */
    414439    JsonGenerator write(String value);
     
    416441    /**
    417442     * 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()}
    419444     * is used as the the text value for writing.
    420445     *
     
    423448     * @throws javax.json.JsonException if an i/o error occurs (IOException
    424449     * would be cause of JsonException)
    425      * @throws JsonGenerationException if this method is not called within an 
    426      *      array context
     450     * @throws JsonGenerationException if this method is not called within an
     451     *      array or root context.
    427452     *
    428453     * @see javax.json.JsonNumber
     
    432457    /**
    433458     * 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()}
    435460     * is used as the text value for writing.
    436461     *
     
    439464     * @throws javax.json.JsonException if an i/o error occurs (IOException
    440465     * would be cause of JsonException)
    441      * @throws JsonGenerationException if this method is not called within an 
    442      *      array context
     466     * @throws JsonGenerationException if this method is not called within an
     467     *      array or root context.
    443468     *
    444469     * @see javax.json.JsonNumber
     
    448473    /**
    449474     * 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()}
    451476     * is used as the text value for writing.
    452477     *
     
    455480     * @throws javax.json.JsonException if an i/o error occurs (IOException
    456481     * would be cause of JsonException)
    457      * @throws JsonGenerationException if this method is not called within an 
    458      *      array context
     482     * @throws JsonGenerationException if this method is not called within an
     483     *      array or root context.
    459484     */
    460485    JsonGenerator write(int value);
     
    462487    /**
    463488     * 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()}
    465490     * is used as the text value for writing.
    466491     *
     
    469494     * @throws javax.json.JsonException if an i/o error occurs (IOException
    470495     * would be cause of JsonException)
    471      * @throws JsonGenerationException if this method is not called within an 
    472      *      array context
     496     * @throws JsonGenerationException if this method is not called within an
     497     *      array or root context.
    473498     */
    474499    JsonGenerator write(long value);
     
    476501    /**
    477502     * 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()}
    479504     * is used as the text value for writing.
    480505     *
     
    483508     * @throws javax.json.JsonException if an i/o error occurs (IOException
    484509     * would be cause of JsonException)
    485      * @throws JsonGenerationException if this method is not called within an 
    486      *      array context
    487      * @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.
    488513     */
    489514    JsonGenerator write(double value);
    490515
    491516    /**
    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,
    494519     * otherwise it writes the JSON {@code false} value.
    495520     *
     
    498523     * @throws javax.json.JsonException if an i/o error occurs (IOException
    499524     * 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.
    502527     */
    503528    JsonGenerator write(boolean value);
    504529
    505530    /**
    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 context
     531     * 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.
    513538     */
    514539    JsonGenerator writeNull();
    515540
    516541    /**
    517      * Closes this generator and frees any resources associated with it. 
     542     * Closes this generator and frees any resources associated with it.
    518543     * This method closes the underlying output source.
    519544     *
  • trunk/src/javax/json/stream/JsonGeneratorFactory.java

    r6756 r13231  
    22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    33 *
    4  * Copyright (c) 2011-2013 Oracle and/or its affiliates. All rights reserved.
     4 * Copyright (c) 2011-2017 Oracle and/or its affiliates. All rights reserved.
    55 *
    66 * The contents of this file are subject to the terms of either the GNU
     
    99 * may not use this file except in compliance with the License.  You can
    1010 * obtain a copy of the License at
    11  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
    12  * or packager/legal/LICENSE.txt.  See the License for the specific
     11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1
     12 * or LICENSE.txt.  See the License for the specific
    1313 * language governing permissions and limitations under the License.
    1414 *
    1515 * 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.
    1717 *
    1818 * GPL Classpath Exception:
     
    6767 * <p> All the methods in this class are safe for use by multiple concurrent
    6868 * threads.
    69  *
    70  * @author Jitendra Kotamraju
    7169 */
    7270public interface JsonGeneratorFactory {
     
    7775     *
    7876     * @param writer i/o writer to which JSON is written
     77     * @return the created JSON generator
    7978     */
    8079    JsonGenerator createGenerator(Writer writer);
     
    8685     *
    8786     * @param out i/o stream to which JSON is written
     87     * @return the created JSON generator
    8888     */
    8989    JsonGenerator createGenerator(OutputStream out);
     
    9696     * @param out i/o stream to which JSON is written
    9797     * @param charset a charset
     98     * @return the created JSON generator
    9899     */
    99100    JsonGenerator createGenerator(OutputStream out, Charset charset);
  • trunk/src/javax/json/stream/JsonLocation.java

    r6756 r13231  
    22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    33 *
    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.
    55 *
    66 * The contents of this file are subject to the terms of either the GNU
     
    99 * may not use this file except in compliance with the License.  You can
    1010 * obtain a copy of the License at
    11  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
    12  * or packager/legal/LICENSE.txt.  See the License for the specific
     11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1
     12 * or LICENSE.txt.  See the License for the specific
    1313 * language governing permissions and limitations under the License.
    1414 *
    1515 * 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.
    1717 *
    1818 * GPL Classpath Exception:
     
    5252 * {@link javax.json.JsonArray JsonArray} input source, all the methods in
    5353 * this class return -1.
    54  *
    55  * @author Jitendra Kotamraju
    5654 * @see JsonParser
    5755 * @see JsonParsingException
     
    6058
    6159    /**
    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.
    6361     *
    64      * @return the line number or -1 if none is available
     62     * @return the line number (starts with 1 for the first line) or -1 if none is available
    6563     */
    6664    long getLineNumber();
    6765
    6866    /**
    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.
    7068     *
    71      * @return the column number or -1 if none is available
     69     * @return the column number (starts with 1 for the first column) or -1 if none is available
    7270     */
    7371    long getColumnNumber();
  • trunk/src/javax/json/stream/JsonParser.java

    r6756 r13231  
    22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    33 *
    4  * Copyright (c) 2011-2013 Oracle and/or its affiliates. All rights reserved.
     4 * Copyright (c) 2011-2017 Oracle and/or its affiliates. All rights reserved.
    55 *
    66 * The contents of this file are subject to the terms of either the GNU
     
    99 * may not use this file except in compliance with the License.  You can
    1010 * obtain a copy of the License at
    11  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
    12  * or packager/legal/LICENSE.txt.  See the License for the specific
     11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1
     12 * or LICENSE.txt.  See the License for the specific
    1313 * language governing permissions and limitations under the License.
    1414 *
    1515 * 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.
    1717 *
    1818 * GPL Classpath Exception:
     
    4444import java.io.Closeable;
    4545import java.math.BigDecimal;
     46import java.util.stream.Stream;
     47import java.util.Map;
     48
     49import javax.json.JsonValue;
     50import javax.json.JsonObject;
     51import javax.json.JsonArray;
    4652
    4753/**
    4854 * 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
    5058 * {@link javax.json.Json} contains methods to create parsers from input
    5159 * sources ({@link java.io.InputStream} and {@link java.io.Reader}).
     
    97105 *
    98106 * <p>
    99  * <a id="JsonParserExample2"/>
    100  * <p>
    101107 * <b>For example</b>, for the following JSON:
    102108 * <pre>
     
    113119 * locations below (marked in bold):
    114120 *
    115  * <p>
    116121 * <pre>
    117122 * {<B>START_OBJECT</B>
     
    124129 * </pre>
    125130 *
    126  * <p>
    127  * The methods {@code next()} and {@code hasNext()} enable iteration over
     131 * The methods {@link #next()} and {@link #hasNext()} enable iteration over
    128132 * parser events to process JSON data. {@code JsonParser} provides get methods
    129133 * to obtain the value at the current state of the parser. For example, the
    130134 * following code shows how to obtain the value "John" from the JSON above:
    131135 *
    132  * <p>
    133136 * <pre>
    134137 * <code>
     
    140143 * </pre>
    141144 *
     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 *
    142193 * @see javax.json.Json
    143194 * @see JsonParserFactory
    144  * @author Jitendra Kotamraju
    145195 */
    146196public interface JsonParser extends /*Auto*/Closeable {
     
    223273     * @throws java.util.NoSuchElementException if there are no more parsing
    224274     * states.
     275     * @return the event for the next parsing state
    225276     */
    226277    Event next();
     
    319370
    320371    /**
    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    }
    336501
    337502    /**
     
    344509    @Override
    345510    void close();
    346 
    347511}
  • trunk/src/javax/json/stream/JsonParserFactory.java

    r6756 r13231  
    22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    33 *
    4  * Copyright (c) 2011-2013 Oracle and/or its affiliates. All rights reserved.
     4 * Copyright (c) 2011-2017 Oracle and/or its affiliates. All rights reserved.
    55 *
    66 * The contents of this file are subject to the terms of either the GNU
     
    99 * may not use this file except in compliance with the License.  You can
    1010 * obtain a copy of the License at
    11  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
    12  * or packager/legal/LICENSE.txt.  See the License for the specific
     11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1
     12 * or LICENSE.txt.  See the License for the specific
    1313 * language governing permissions and limitations under the License.
    1414 *
    1515 * 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.
    1717 *
    1818 * GPL Classpath Exception:
     
    6969 * <p> All the methods in this class are safe for use by multiple concurrent
    7070 * threads.
    71  *
    72  * @author Jitendra Kotamraju
    7371 */
    7472public interface JsonParserFactory {
     
    7876     *
    7977     * @param reader a i/o reader from which JSON is to be read
     78     * @return the created JSON parser
    8079     */
    8180    JsonParser createParser(Reader reader);
     
    8483     * Creates a JSON parser from the specified byte stream.
    8584     * The character encoding of the stream is determined
    86      * as specified in <a href="http://tools.ietf.org/rfc/rfc4627.txt">RFC 4627</a>.
     85     * as specified in <a href="http://tools.ietf.org/rfc/rfc7159.txt">RFC 7159</a>.
    8786     *
    8887     * @param in i/o stream from which JSON is to be read
     88     * @return the created JSON parser
    8989     * @throws javax.json.JsonException if encoding cannot be determined
    9090     *         or i/o error (IOException would be cause of JsonException)
     
    9999     * @param in i/o stream from which JSON is to be read
    100100     * @param charset a charset
     101     * @return the created JSON parser
    101102     */
    102103    JsonParser createParser(InputStream in, Charset charset);
     
    106107     *
    107108     * @param obj a JSON object
     109     * @return the created JSON parser
    108110     */
    109111    JsonParser createParser(JsonObject obj);
     
    113115     *
    114116     * @param array a JSON array
     117     * @return the created JSON parser
    115118     */
    116119    JsonParser createParser(JsonArray array);
  • trunk/src/javax/json/stream/JsonParsingException.java

    r6756 r13231  
    22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    33 *
    4  * Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved.
     4 * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
    55 *
    66 * The contents of this file are subject to the terms of either the GNU
     
    99 * may not use this file except in compliance with the License.  You can
    1010 * obtain a copy of the License at
    11  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
    12  * or packager/legal/LICENSE.txt.  See the License for the specific
     11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1
     12 * or LICENSE.txt.  See the License for the specific
    1313 * language governing permissions and limitations under the License.
    1414 *
    1515 * 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.
    1717 *
    1818 * GPL Classpath Exception:
     
    4646 * {@code JsonParsingException} is used when an incorrect JSON is
    4747 * being parsed.
    48  *
    49  * @author Jitendra Kotamraju
    5048 */
    5149public class JsonParsingException extends JsonException {
  • trunk/src/javax/json/stream/package-info.java

    r6756 r13231  
    22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    33 *
    4  * Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved.
     4 * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
    55 *
    66 * The contents of this file are subject to the terms of either the GNU
     
    99 * may not use this file except in compliance with the License.  You can
    1010 * obtain a copy of the License at
    11  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
    12  * or packager/legal/LICENSE.txt.  See the License for the specific
     11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1
     12 * or LICENSE.txt.  See the License for the specific
    1313 * language governing permissions and limitations under the License.
    1414 *
    1515 * 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.
    1717 *
    1818 * GPL Classpath Exception:
     
    6868 *
    6969 * @since JSON Processing 1.0
    70  * @author Jitendra Kotamraju
    7170 */
    7271package javax.json.stream;
Note: See TracChangeset for help on using the changeset viewer.