Coverage Report - org.ini4j.spi.OptionsParser
 
Classes in this File Line Coverage Branch Coverage Complexity
OptionsParser
94%
16/17
100%
2/2
1.143
 
 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.InvalidFileFormatException;
 20  
 
 21  
 import java.io.IOException;
 22  
 import java.io.InputStream;
 23  
 import java.io.Reader;
 24  
 
 25  
 import java.net.URL;
 26  
 
 27  
 public class OptionsParser extends AbstractParser
 28  
 {
 29  
     private static final String COMMENTS = "!#";
 30  
     private static final String OPERATORS = ":=";
 31  
 
 32  
     public OptionsParser()
 33  
     {
 34  30
         super(OPERATORS, COMMENTS);
 35  30
     }
 36  
 
 37  
     public static OptionsParser newInstance()
 38  
     {
 39  26
         return ServiceFinder.findService(OptionsParser.class);
 40  
     }
 41  
 
 42  
     public static OptionsParser newInstance(Config config)
 43  
     {
 44  25
         OptionsParser instance = newInstance();
 45  
 
 46  25
         instance.setConfig(config);
 47  
 
 48  25
         return instance;
 49  
     }
 50  
 
 51  
     public void parse(InputStream input, OptionsHandler handler) throws IOException, InvalidFileFormatException
 52  
     {
 53  1
         parse(newIniSource(input, handler), handler);
 54  0
     }
 55  
 
 56  
     public void parse(Reader input, OptionsHandler handler) throws IOException, InvalidFileFormatException
 57  
     {
 58  19
         parse(newIniSource(input, handler), handler);
 59  16
     }
 60  
 
 61  
     public void parse(URL input, OptionsHandler handler) throws IOException, InvalidFileFormatException
 62  
     {
 63  8
         parse(newIniSource(input, handler), handler);
 64  8
     }
 65  
 
 66  
     private void parse(IniSource source, OptionsHandler handler) throws IOException, InvalidFileFormatException
 67  
     {
 68  28
         handler.startOptions();
 69  784
         for (String line = source.readLine(); line != null; line = source.readLine())
 70  
         {
 71  760
             parseOptionLine(line, handler, source.getLineNumber());
 72  
         }
 73  
 
 74  24
         handler.endOptions();
 75  24
     }
 76  
 }