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 static java.util.Arrays.asList; |
22 | |
|
23 | |
import java.io.OutputStream; |
24 | |
import java.io.OutputStreamWriter; |
25 | |
import java.io.Writer; |
26 | |
import java.nio.charset.Charset; |
27 | |
import java.util.Collection; |
28 | |
import java.util.Collections; |
29 | |
import java.util.Map; |
30 | |
|
31 | |
import javax.json.JsonWriter; |
32 | |
import javax.json.JsonWriterFactory; |
33 | |
import javax.json.stream.JsonGeneratorFactory; |
34 | |
|
35 | |
class JsonWriterFactoryImpl extends AbstractJsonFactory implements JsonWriterFactory{ |
36 | 1 | private static final Charset UTF8_CHARSET = Charset.forName("UTF-8"); |
37 | 1 | static final Collection<String> SUPPORTED_CONFIG_KEYS = asList( |
38 | |
|
39 | |
); |
40 | |
private final JsonGeneratorFactory factory; |
41 | |
|
42 | |
JsonWriterFactoryImpl(final Map<String, ?> config) { |
43 | 1 | super(config, SUPPORTED_CONFIG_KEYS, JsonGeneratorFactoryImpl.SUPPORTED_CONFIG_KEYS); |
44 | 1 | this.factory = new JsonGeneratorFactoryImpl(internalConfig); |
45 | 1 | } |
46 | |
|
47 | |
@Override |
48 | |
public JsonWriter createWriter(final Writer writer) { |
49 | 1 | return new JsonWriterImpl(factory.createGenerator(writer)); |
50 | |
} |
51 | |
|
52 | |
@Override |
53 | |
public JsonWriter createWriter(final OutputStream out) { |
54 | 1 | return createWriter(new OutputStreamWriter(out, UTF8_CHARSET)); |
55 | |
} |
56 | |
|
57 | |
@Override |
58 | |
public JsonWriter createWriter(final OutputStream out, final Charset charset) { |
59 | 0 | return createWriter(new OutputStreamWriter(out, charset)); |
60 | |
} |
61 | |
|
62 | |
@Override |
63 | |
public Map<String, ?> getConfigInUse() { |
64 | 0 | return Collections.unmodifiableMap(internalConfig); |
65 | |
} |
66 | |
} |