Coverage Report - org.apache.johnzon.core.JsonReaderFactoryImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
JsonReaderFactoryImpl
92%
13/14
100%
6/6
1,6
 
 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 java.io.InputStream;
 22  
 import java.io.Reader;
 23  
 import java.io.Serializable;
 24  
 import java.nio.charset.Charset;
 25  
 import java.util.Collections;
 26  
 import java.util.HashMap;
 27  
 import java.util.Map;
 28  
 
 29  
 import javax.json.JsonReader;
 30  
 import javax.json.JsonReaderFactory;
 31  
 
 32  
 class JsonReaderFactoryImpl implements JsonReaderFactory, Serializable {
 33  45
     private final Map<String, Object> internalConfig = new HashMap<String, Object>();
 34  1
     private static final String[] SUPPORTED_CONFIG_KEYS = new String[] {
 35  
         JsonParserFactoryImpl.BUFFER_STRATEGY, JsonParserFactoryImpl.MAX_STRING_LENGTH, JsonParserFactoryImpl.BUFFER_LENGTH
 36  
     };
 37  
     private final JsonParserFactoryImpl parserFactory;
 38  
 
 39  45
     JsonReaderFactoryImpl(final Map<String, ?> config) {
 40  
 
 41  45
         if(config != null) {
 42  
             
 43  176
             for (String configKey : SUPPORTED_CONFIG_KEYS) {
 44  132
                 if(config.containsKey(configKey)) {
 45  44
                     internalConfig.put(configKey, config.get(configKey));
 46  
                 }
 47  
             }
 48  
             
 49  44
             this.parserFactory = new JsonParserFactoryImpl(internalConfig);
 50  
             
 51  
         } else {
 52  1
             this.parserFactory = new JsonParserFactoryImpl(null);
 53  
         }
 54  
         
 55  44
     }
 56  
 
 57  
     @Override
 58  
     public JsonReader createReader(final Reader reader) {
 59  7
         return new JsonReaderImpl(parserFactory.createInternalParser(reader));
 60  
     }
 61  
 
 62  
     @Override
 63  
     public JsonReader createReader(final InputStream in) {
 64  84
         return new JsonReaderImpl(parserFactory.createInternalParser(in));
 65  
     }
 66  
 
 67  
     @Override
 68  
     public JsonReader createReader(final InputStream in, final Charset charset) {
 69  54
         return new JsonReaderImpl(parserFactory.createInternalParser(in, charset));
 70  
     }
 71  
 
 72  
     @Override
 73  
     public Map<String, ?> getConfigInUse() {
 74  0
         return Collections.unmodifiableMap(internalConfig);
 75  
     }
 76  
 }