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

Last change on this file since 10957 was 6756, checked in by Don-vip, 10 years ago

fix #9590 - replace org.json with GPL-compliant jsonp + remove mention of old world image removed in r1680

File size: 4.8 KB
Line 
1/*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright (c) 2011-2013 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://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
12 * or packager/legal/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 packager/legal/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 *
72 * @author Jitendra Kotamraju
73 */
74public interface JsonParserFactory {
75
76 /**
77 * Creates a JSON parser from a character stream.
78 *
79 * @param reader a i/o reader from which JSON is to be read
80 */
81 JsonParser createParser(Reader reader);
82
83 /**
84 * Creates a JSON parser from the specified byte stream.
85 * The character encoding of the stream is determined
86 * as specified in <a href="http://tools.ietf.org/rfc/rfc4627.txt">RFC 4627</a>.
87 *
88 * @param in i/o stream from which JSON is to be read
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 */
102 JsonParser createParser(InputStream in, Charset charset);
103
104 /**
105 * Creates a JSON parser from the specified JSON object.
106 *
107 * @param obj a JSON object
108 */
109 JsonParser createParser(JsonObject obj);
110
111 /**
112 * Creates a JSON parser from the specified JSON array.
113 *
114 * @param array a JSON array
115 */
116 JsonParser createParser(JsonArray array);
117
118 /**
119 * Returns a read-only map of supported provider specific configuration
120 * properties that are used to configure the JSON parsers.
121 * If there are any specified configuration properties that are not
122 * supported by the provider, they won't be part of the returned map.
123 *
124 * @return a map of supported provider specific properties that are used
125 * to configure the created parsers. The map may be empty but not null
126 */
127 Map<String, ?> getConfigInUse();
128
129}
Note: See TracBrowser for help on using the repository browser.