Clover coverage report - [ini4j]
Coverage timestamp: Sze nov. 30 2005 08:31:05 CET
file stats: LOC: 95   Methods: 6
NCLOC: 67   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
IniFile.java 100% 100% 100% 100%
coverage
 1    /*
 2    * Copyright 2005 [ini4j] Development Team
 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   
 17    package org.ini4j;
 18   
 19    import java.io.*;
 20    import java.util.prefs.*;
 21   
 22    public class IniFile extends IniPreferences
 23    {
 24    public static enum Mode {RO,WO,RW};
 25   
 26    private Mode _mode;
 27    private File _file;
 28   
 29  6 public IniFile(File file, Mode mode) throws BackingStoreException
 30    {
 31  6 super(new Ini());
 32  6 _file = file;
 33  6 _mode = mode;
 34   
 35  6 if ( (_mode == Mode.RO) || ( (_mode != Mode.WO) && _file.exists() ) )
 36    {
 37  4 sync();
 38    }
 39    }
 40   
 41  1 public IniFile(File file) throws BackingStoreException
 42    {
 43  1 this(file, Mode.RO);
 44    }
 45   
 46  1 public Mode getMode()
 47    {
 48  1 return _mode;
 49    }
 50   
 51  1 public File getFile()
 52    {
 53  1 return _file;
 54    }
 55   
 56  6 public void sync() throws BackingStoreException
 57    {
 58  6 if ( _mode == Mode.WO )
 59    {
 60  1 throw new BackingStoreException("write only instance");
 61    }
 62   
 63  5 try
 64    {
 65  5 synchronized (lock)
 66    {
 67  5 getIni().load(_file.toURL());
 68    }
 69    }
 70    catch (Exception x)
 71    {
 72  1 throw new BackingStoreException(x);
 73    }
 74    }
 75   
 76  3 public void flush() throws BackingStoreException
 77    {
 78  3 if ( _mode == Mode.RO )
 79    {
 80  1 throw new BackingStoreException("read only instance");
 81    }
 82   
 83  2 try
 84    {
 85  2 synchronized (lock)
 86    {
 87  2 getIni().store(new FileWriter(_file));
 88    }
 89    }
 90    catch (Exception x)
 91    {
 92  1 throw new BackingStoreException(x);
 93    }
 94    }
 95    }