1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.johnzon.core; |
20 | |
|
21 | |
import java.io.InputStream; |
22 | |
import java.io.OutputStream; |
23 | |
import java.io.Reader; |
24 | |
import java.io.Serializable; |
25 | |
import java.io.Writer; |
26 | |
import java.util.Map; |
27 | |
|
28 | |
import javax.json.JsonArrayBuilder; |
29 | |
import javax.json.JsonBuilderFactory; |
30 | |
import javax.json.JsonObjectBuilder; |
31 | |
import javax.json.JsonReader; |
32 | |
import javax.json.JsonReaderFactory; |
33 | |
import javax.json.JsonWriter; |
34 | |
import javax.json.JsonWriterFactory; |
35 | |
import javax.json.spi.JsonProvider; |
36 | |
import javax.json.stream.JsonGenerator; |
37 | |
import javax.json.stream.JsonGeneratorFactory; |
38 | |
import javax.json.stream.JsonParser; |
39 | |
import javax.json.stream.JsonParserFactory; |
40 | |
|
41 | 520 | public class JsonProviderImpl extends JsonProvider implements Serializable { |
42 | 1 | private static final JsonProvider DELEGATE = new JsonProviderDelegate(); |
43 | |
|
44 | |
@Override |
45 | |
public JsonParser createParser(final Reader reader) { |
46 | 19 | return DELEGATE.createParser(reader); |
47 | |
} |
48 | |
|
49 | |
@Override |
50 | |
public JsonParser createParser(final InputStream inputStream) { |
51 | 24 | return DELEGATE.createParser(inputStream); |
52 | |
} |
53 | |
|
54 | |
@Override |
55 | |
public JsonParserFactory createParserFactory(final Map<String, ?> stringMap) { |
56 | 273 | return DELEGATE.createParserFactory(stringMap); |
57 | |
} |
58 | |
|
59 | |
@Override |
60 | |
public JsonGenerator createGenerator(final Writer writer) { |
61 | 0 | return DELEGATE.createGenerator(writer); |
62 | |
} |
63 | |
|
64 | |
@Override |
65 | |
public JsonGenerator createGenerator(final OutputStream outputStream) { |
66 | 21 | return DELEGATE.createGenerator(outputStream); |
67 | |
} |
68 | |
|
69 | |
@Override |
70 | |
public JsonGeneratorFactory createGeneratorFactory(final Map<String, ?> stringMap) { |
71 | 1 | return DELEGATE.createGeneratorFactory(stringMap); |
72 | |
} |
73 | |
|
74 | |
@Override |
75 | |
public JsonReader createReader(final Reader reader) { |
76 | 6 | return DELEGATE.createReader(reader); |
77 | |
} |
78 | |
|
79 | |
@Override |
80 | |
public JsonReader createReader(final InputStream inputStream) { |
81 | 79 | return DELEGATE.createReader(inputStream); |
82 | |
} |
83 | |
|
84 | |
@Override |
85 | |
public JsonWriter createWriter(final Writer writer) { |
86 | 0 | return DELEGATE.createWriter(writer); |
87 | |
} |
88 | |
|
89 | |
@Override |
90 | |
public JsonWriter createWriter(final OutputStream outputStream) { |
91 | 1 | return DELEGATE.createWriter(outputStream); |
92 | |
} |
93 | |
|
94 | |
@Override |
95 | |
public JsonWriterFactory createWriterFactory(final Map<String, ?> stringMap) { |
96 | 0 | return DELEGATE.createWriterFactory(stringMap); |
97 | |
} |
98 | |
|
99 | |
@Override |
100 | |
public JsonReaderFactory createReaderFactory(final Map<String, ?> stringMap) { |
101 | 62 | return DELEGATE.createReaderFactory(stringMap); |
102 | |
} |
103 | |
|
104 | |
@Override |
105 | |
public JsonObjectBuilder createObjectBuilder() { |
106 | 5 | return DELEGATE.createObjectBuilder(); |
107 | |
} |
108 | |
|
109 | |
@Override |
110 | |
public JsonArrayBuilder createArrayBuilder() { |
111 | 29 | return DELEGATE.createArrayBuilder(); |
112 | |
} |
113 | |
|
114 | |
@Override |
115 | |
public JsonBuilderFactory createBuilderFactory(final Map<String, ?> stringMap) { |
116 | 0 | return DELEGATE.createBuilderFactory(stringMap); |
117 | |
} |
118 | |
|
119 | 1 | static class JsonProviderDelegate extends JsonProvider { |
120 | 1 | private final JsonReaderFactory readerFactory = new JsonReaderFactoryImpl(null); |
121 | 1 | private final JsonParserFactory parserFactory = new JsonParserFactoryImpl(null); |
122 | 1 | private final JsonGeneratorFactory generatorFactory = new JsonGeneratorFactoryImpl(null); |
123 | 1 | private final JsonWriterFactory writerFactory = new JsonWriterFactoryImpl(null); |
124 | 1 | private final JsonBuilderFactory builderFactory = new JsonBuilderFactoryImpl(null); |
125 | |
|
126 | |
@Override |
127 | |
public JsonParser createParser(final InputStream in) { |
128 | 24 | return parserFactory.createParser(in); |
129 | |
} |
130 | |
|
131 | |
@Override |
132 | |
public JsonParser createParser(final Reader reader) { |
133 | 19 | return parserFactory.createParser(reader); |
134 | |
} |
135 | |
|
136 | |
@Override |
137 | |
public JsonReader createReader(final InputStream in) { |
138 | 79 | return readerFactory.createReader(in); |
139 | |
} |
140 | |
|
141 | |
@Override |
142 | |
public JsonReader createReader(final Reader reader) { |
143 | 6 | return readerFactory.createReader(reader); |
144 | |
} |
145 | |
|
146 | |
@Override |
147 | |
public JsonParserFactory createParserFactory(final Map<String, ?> config) { |
148 | 273 | return (config == null || config.isEmpty()) ? parserFactory : new JsonParserFactoryImpl(config); |
149 | |
} |
150 | |
|
151 | |
@Override |
152 | |
public JsonReaderFactory createReaderFactory(final Map<String, ?> config) { |
153 | 62 | return (config == null || config.isEmpty()) ? readerFactory : new JsonReaderFactoryImpl(config); |
154 | |
} |
155 | |
|
156 | |
@Override |
157 | |
public JsonGenerator createGenerator(final Writer writer) { |
158 | 0 | return generatorFactory.createGenerator(writer); |
159 | |
} |
160 | |
|
161 | |
@Override |
162 | |
public JsonGenerator createGenerator(final OutputStream out) { |
163 | 21 | return generatorFactory.createGenerator(out); |
164 | |
} |
165 | |
|
166 | |
@Override |
167 | |
public JsonGeneratorFactory createGeneratorFactory(final Map<String, ?> config) { |
168 | 1 | return (config == null || config.isEmpty()) ? generatorFactory : new JsonGeneratorFactoryImpl(config); |
169 | |
} |
170 | |
|
171 | |
@Override |
172 | |
public JsonWriter createWriter(final Writer writer) { |
173 | 0 | return writerFactory.createWriter(writer); |
174 | |
} |
175 | |
|
176 | |
@Override |
177 | |
public JsonWriter createWriter(final OutputStream out) { |
178 | 1 | return writerFactory.createWriter(out); |
179 | |
} |
180 | |
|
181 | |
@Override |
182 | |
public JsonWriterFactory createWriterFactory(final Map<String, ?> config) { |
183 | 0 | return (config == null || config.isEmpty()) ? writerFactory : new JsonWriterFactoryImpl(config); |
184 | |
} |
185 | |
|
186 | |
@Override |
187 | |
public JsonObjectBuilder createObjectBuilder() { |
188 | 5 | return builderFactory.createObjectBuilder(); |
189 | |
} |
190 | |
|
191 | |
@Override |
192 | |
public JsonArrayBuilder createArrayBuilder() { |
193 | 29 | return builderFactory.createArrayBuilder(); |
194 | |
} |
195 | |
|
196 | |
@Override |
197 | |
public JsonBuilderFactory createBuilderFactory(final Map<String, ?> config) { |
198 | 0 | return (config == null || config.isEmpty()) ? builderFactory : new JsonBuilderFactoryImpl(config); |
199 | |
} |
200 | |
} |
201 | |
} |