Coverage Report - org.ini4j.addon.StrictPreferences
 
Classes in this File Line Coverage Branch Coverage Complexity
StrictPreferences
93%
14/15
75%
3/4
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.addon;
 17  
 
 18  
 import java.util.NoSuchElementException;
 19  
 import java.util.prefs.Preferences;
 20  
 
 21  
 public class StrictPreferences extends PreferencesWrapper
 22  
 {
 23  
     public StrictPreferences(Preferences peer)
 24  
     {
 25  1
         super(peer);
 26  1
     }
 27  
 
 28  
     public boolean getBoolean(String key) throws NoSuchElementException
 29  
     {
 30  1
         return Boolean.valueOf(get(key));
 31  
     }
 32  
 
 33  
     public byte[] getByteArray(String key) throws NoSuchElementException
 34  
     {
 35  1
         byte[] value = getByteArray(key, null);
 36  
 
 37  1
         if (value == null)
 38  
         {
 39  1
             throw new NoSuchElementException();
 40  
         }
 41  
 
 42  0
         return value;
 43  
     }
 44  
 
 45  
     public double getDouble(String key) throws NoSuchElementException
 46  
     {
 47  1
         return Double.parseDouble(get(key));
 48  
     }
 49  
 
 50  
     public float getFloat(String key) throws NoSuchElementException
 51  
     {
 52  1
         return Float.parseFloat(get(key));
 53  
     }
 54  
 
 55  
     public int getInt(String key) throws NoSuchElementException
 56  
     {
 57  1
         return Integer.parseInt(get(key));
 58  
     }
 59  
 
 60  
     public long getLong(String key) throws NoSuchElementException
 61  
     {
 62  1
         return Long.parseLong(get(key));
 63  
     }
 64  
 
 65  
     public String get(String key) throws NoSuchElementException
 66  
     {
 67  7
         String value = get(key, null);
 68  
 
 69  7
         if (value == null)
 70  
         {
 71  6
             throw new NoSuchElementException();
 72  
         }
 73  
 
 74  1
         return value;
 75  
     }
 76  
 }