source: josm/trunk/src/javax/json/stream/JsonParserFactory.java@ 14578

Last change on this file since 14578 was 13231, checked in by Don-vip, 7 years ago

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

File size: 4.8 KB
Line 
1/*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright (c) 2011-2017 Oracle and/or its affiliates. All rights reserved.
5 *
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common Development
8 * and Distribution License("CDDL") (collectively, the "License"). You
9 * may not use this file except in compliance with the License. You can
10 * obtain a copy of the License at
11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1
12 * or LICENSE.txt. See the License for the specific
13 * language governing permissions and limitations under the License.
14 *
15 * When distributing the software, include this License Header Notice in each
16 * file and include the License file at LICENSE.txt.
17 *
18 * GPL Classpath Exception:
19 * Oracle designates this particular file as subject to the "Classpath"
20 * exception as provided by Oracle in the GPL Version 2 section of the License
21 * file that accompanied this code.
22 *
23 * Modifications:
24 * If applicable, add the following below the License Header, with the fields
25 * enclosed by brackets [] replaced by your own identifying information:
26 * "Portions Copyright [year] [name of copyright owner]"
27 *
28 * Contributor(s):
29 * If you wish your version of this file to be governed by only the CDDL or
30 * only the GPL Version 2, indicate your decision by adding "[Contributor]
31 * elects to include this software in this distribution under the [CDDL or GPL
32 * Version 2] license." If you don't indicate a single choice of license, a
33 * recipient has the option to distribute your version of this file under
34 * either the CDDL, the GPL Version 2 or to extend the choice of license to
35 * its licensees as provided above. However, if you add GPL Version 2 code
36 * and therefore, elected the GPL Version 2 license, then the option applies
37 * only if the new code is made subject to such option by the copyright
38 * holder.
39 */
40
41package javax.json.stream;
42
43import javax.json.JsonArray;
44import javax.json.JsonObject;
45import java.io.InputStream;
46import java.io.Reader;
47import java.nio.charset.Charset;
48import java.util.Map;
49
50/**
51 * Factory for creating {@link JsonParser} instances. If a factory
52 * instance is configured with a configuration, the configuration applies
53 * to all parser instances created using that factory instance.
54 *
55 * <p>
56 * The class {@link javax.json.Json Json} also provides methods to create
57 * {@link JsonParser} instances, but using {@code JsonParserFactory} is
58 * preferred when creating multiple parser instances as shown in the following
59 * example:
60 *
61 * <pre>
62 * <code>
63 * JsonParserFactory factory = Json.createParserFactory();
64 * JsonParser parser1 = factory.createParser(...);
65 * JsonParser parser2 = factory.createParser(...);
66 * </code>
67 * </pre>
68 *
69 * <p> All the methods in this class are safe for use by multiple concurrent
70 * threads.
71 */
72public interface JsonParserFactory {
73
74 /**
75 * Creates a JSON parser from a character stream.
76 *
77 * @param reader a i/o reader from which JSON is to be read
78 * @return the created JSON parser
79 */
80 JsonParser createParser(Reader reader);
81
82 /**
83 * Creates a JSON parser from the specified byte stream.
84 * The character encoding of the stream is determined
85 * as specified in <a href="http://tools.ietf.org/rfc/rfc7159.txt">RFC 7159</a>.
86 *
87 * @param in i/o stream from which JSON is to be read
88 * @return the created JSON parser
89 * @throws javax.json.JsonException if encoding cannot be determined
90 * or i/o error (IOException would be cause of JsonException)
91 */
92 JsonParser createParser(InputStream in);
93
94 /**
95 * Creates a JSON parser from the specified byte stream.
96 * The bytes of the stream are decoded to characters using the
97 * specified charset.
98 *
99 * @param in i/o stream from which JSON is to be read
100 * @param charset a charset
101 * @return the created JSON parser
102 */
103 JsonParser createParser(InputStream in, Charset charset);
104
105 /**
106 * Creates a JSON parser from the specified JSON object.
107 *
108 * @param obj a JSON object
109 * @return the created JSON parser
110 */
111 JsonParser createParser(JsonObject obj);
112
113 /**
114 * Creates a JSON parser from the specified JSON array.
115 *
116 * @param array a JSON array
117 * @return the created JSON parser
118 */
119 JsonParser createParser(JsonArray array);
120
121 /**
122 * Returns a read-only map of supported provider specific configuration
123 * properties that are used to configure the JSON parsers.
124 * If there are any specified configuration properties that are not
125 * supported by the provider, they won't be part of the returned map.
126 *
127 * @return a map of supported provider specific properties that are used
128 * to configure the created parsers. The map may be empty but not null
129 */
130 Map<String, ?> getConfigInUse();
131
132}
Note: See TracBrowser for help on using the repository browser.