Coverage Report - org.ini4j.spi.RegBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
RegBuilder
100%
16/16
100%
6/6
1.5
 
 1  
 /*
 2  
  * Copyright 2005,2009 Ivan SZKIBA
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.ini4j.spi;
 17  
 
 18  
 import org.ini4j.Config;
 19  
 import org.ini4j.Profile;
 20  
 import org.ini4j.Reg;
 21  
 
 22  
 import org.ini4j.Registry.Key;
 23  
 import org.ini4j.Registry.Type;
 24  
 
 25  418
 public class RegBuilder extends AbstractProfileBuilder
 26  
 {
 27  
     private Reg _reg;
 28  
 
 29  
     public static RegBuilder newInstance(Reg reg)
 30  
     {
 31  11
         RegBuilder instance = newInstance();
 32  
 
 33  11
         instance.setReg(reg);
 34  
 
 35  11
         return instance;
 36  
     }
 37  
 
 38  
     public void setReg(Reg value)
 39  
     {
 40  11
         _reg = value;
 41  11
     }
 42  
 
 43  
     @Override public void handleOption(String rawName, String rawValue)
 44  
     {
 45  494
         String name = (rawName.charAt(0) == EscapeTool.DOUBLE_QUOTE) ? RegEscapeTool.getInstance().unquote(rawName) : rawName;
 46  494
         TypeValuesPair tv = RegEscapeTool.getInstance().decode(rawValue);
 47  
 
 48  494
         if (tv.getType() != Type.REG_SZ)
 49  
         {
 50  175
             ((Key) getCurrentSection()).putType(name, tv.getType());
 51  
         }
 52  
 
 53  1038
         for (String value : tv.getValues())
 54  
         {
 55  544
             super.handleOption(name, value);
 56  
         }
 57  494
     }
 58  
 
 59  
     @Override Config getConfig()
 60  
     {
 61  779
         return _reg.getConfig();
 62  
     }
 63  
 
 64  
     @Override Profile getProfile()
 65  
     {
 66  358
         return _reg;
 67  
     }
 68  
 
 69  
     private static RegBuilder newInstance()
 70  
     {
 71  11
         return ServiceFinder.findService(RegBuilder.class);
 72  
     }
 73  
 }