Coverage Report - org.apache.johnzon.core.JsonWriterFactoryImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
JsonWriterFactoryImpl
77%
7/9
N/A
1
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements. See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership. The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License. You may obtain a copy of the License at
 9  
  *
 10  
  * http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied. See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 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  
 }