| 1 |  |  | 
            
  
    | 2 |  |  | 
            
  
    | 3 |  |  | 
            
  
    | 4 |  |  | 
            
  
    | 5 |  |  | 
            
  
    | 6 |  |  | 
            
  
    | 7 |  |  | 
            
  
    | 8 |  |  | 
            
  
    | 9 |  |  | 
            
  
    | 10 |  |  | 
            
  
    | 11 |  |  | 
            
  
    | 12 |  |  | 
            
  
    | 13 |  |  | 
            
  
    | 14 |  |  | 
            
  
    | 15 |  |  | 
            
  
    | 16 |  | package org.kuali.student.common.util; | 
            
  
    | 17 |  |  | 
            
  
    | 18 |  | import java.io.File; | 
            
  
    | 19 |  | import java.io.FileInputStream; | 
            
  
    | 20 |  | import java.io.FileNotFoundException; | 
            
  
    | 21 |  | import java.io.IOException; | 
            
  
    | 22 |  | import java.io.InputStream; | 
            
  
    | 23 |  | import java.net.URL; | 
            
  
    | 24 |  | import java.util.HashMap; | 
            
  
    | 25 |  | import java.util.Map; | 
            
  
    | 26 |  | import java.util.Properties; | 
            
  
    | 27 |  |  | 
            
  
    | 28 |  |  | 
            
  
    | 29 |  |  | 
            
  
    | 30 |  |  | 
            
  
    | 31 |  |  | 
            
  
    | 32 |  |  | 
            
  
    | 33 |  |  | 
            
  
    | 34 |  |  | 
            
  
    | 35 |  |  | 
            
  
    | 36 |  |  | 
            
  
    | 37 |  |  | 
            
  
    | 38 |  |  | 
            
  
    | 39 |  |  | 
            
  
    | 40 |  |  | 
            
  
    | 41 |  |  | 
            
  
    | 42 |  |  | 
            
  
    | 43 |  |  | 
            
  
    | 44 |  |  | 
            
  
    | 45 |  |  | 
            
  
    | 46 |  |  | 
            
  
    | 47 |  | @author | 
            
  
    | 48 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 42 (42) | Complexity: 11 | Complexity Density: 0.38 |  | 
  
  
    | 49 |  | public class PropertiesFactory { | 
            
  
    | 50 |  |  | 
            
  
    | 51 |  | Properties properties = new Properties(); | 
            
  
    | 52 |  |  | 
            
  
    | 53 |  |  | 
            
  
    | 54 |  |  | 
            
  
    | 55 |  |  | 
            
  
    | 56 |  | @param | 
            
  
    | 57 |  | @link | 
            
  
    | 58 |  | @throws | 
            
  
    | 59 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 60 | 0 |  public PropertiesFactory(String filename) throws IOException {... | 
            
  
    | 61 | 0 | this(ClassLoader.getSystemResource(filename).openStream()); | 
            
  
    | 62 |  | } | 
            
  
    | 63 |  |  | 
            
  
    | 64 |  |  | 
            
  
    | 65 |  |  | 
            
  
    | 66 |  |  | 
            
  
    | 67 |  | @param | 
            
  
    | 68 |  |  | 
            
  
    | 69 |  | @throws | 
            
  
    | 70 |  | @throws | 
            
  
    | 71 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 72 | 0 |  public PropertiesFactory(File file) throws FileNotFoundException, IOException {... | 
            
  
    | 73 | 0 | this(new FileInputStream(file)); | 
            
  
    | 74 |  | } | 
            
  
    | 75 |  |  | 
            
  
    | 76 |  |  | 
            
  
    | 77 |  |  | 
            
  
    | 78 |  |  | 
            
  
    | 79 |  | @param | 
            
  
    | 80 |  |  | 
            
  
    | 81 |  | @throws | 
            
  
    | 82 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 7 (7) | Complexity: 3 | Complexity Density: 0.6 |  | 
  
  
    | 83 | 0 |  public PropertiesFactory(InputStream in) throws IOException {... | 
            
  
    | 84 | 0 | try { | 
            
  
    | 85 | 0 | properties.load(in); | 
            
  
    | 86 |  | } finally { | 
            
  
    | 87 | 0 | if (in != null) { | 
            
  
    | 88 | 0 | try { | 
            
  
    | 89 | 0 | in.close(); | 
            
  
    | 90 |  | } catch (IOException e) {} | 
            
  
    | 91 |  | } | 
            
  
    | 92 |  | } | 
            
  
    | 93 |  | } | 
            
  
    | 94 |  |  | 
            
  
    | 95 |  |  | 
            
  
    | 96 |  |  | 
            
  
    | 97 |  |  | 
            
  
    | 98 |  |  | 
            
  
    | 99 |  | @param | 
            
  
    | 100 |  |  | 
            
  
    | 101 |  | @return | 
            
  
    | 102 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 9 (9) | Complexity: 2 | Complexity Density: 0.29 |  | 
  
  
    | 103 | 0 |  public Map<Object, Object> getProperties(String prefix) {... | 
            
  
    | 104 | 0 | Map<Object, Object> map = new HashMap<Object, Object>(); | 
            
  
    | 105 | 0 | for (Object key : properties.keySet()) { | 
            
  
    | 106 | 0 | String realPrefix = prefix + "."; | 
            
  
    | 107 | 0 | String keyString = key.toString(); | 
            
  
    | 108 | 0 | if (keyString.startsWith(realPrefix)) { | 
            
  
    | 109 | 0 | map.put(keyString.substring(realPrefix.length()), properties.get(key)); | 
            
  
    | 110 |  | } | 
            
  
    | 111 |  | } | 
            
  
    | 112 |  |  | 
            
  
    | 113 | 0 | return map; | 
            
  
    | 114 |  | } | 
            
  
    | 115 |  |  | 
            
  
    | 116 |  |  | 
            
  
    | 117 |  |  | 
            
  
    | 118 |  |  | 
            
  
    | 119 |  |  | 
            
  
    | 120 |  |  | 
            
  
    | 121 |  |  | 
            
  
    | 122 |  |  | 
            
  
    | 123 |  |  | 
            
  
    | 124 |  | @param | 
            
  
    | 125 |  | @param | 
            
  
    | 126 |  |  | 
            
  
    | 127 |  | @return | 
            
  
    | 128 |  | @throws | 
            
  
    | 129 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 19 (19) | Complexity: 4 | Complexity Density: 0.27 |  | 
  
  
    | 130 | 0 |  public static Map<Object, Object> getProperties(String filename, String prefix) throws IOException {... | 
            
  
    | 131 | 0 | Properties props = new Properties(); | 
            
  
    | 132 | 0 | InputStream in = null; | 
            
  
    | 133 | 0 | URL propFile = ClassLoader.getSystemResource(filename); | 
            
  
    | 134 |  |  | 
            
  
    | 135 | 0 | try { | 
            
  
    | 136 | 0 | props.load(in = propFile.openStream()); | 
            
  
    | 137 |  | } finally { | 
            
  
    | 138 | 0 | if (in != null) { | 
            
  
    | 139 | 0 | try { | 
            
  
    | 140 | 0 | in.close(); | 
            
  
    | 141 |  | } catch (IOException e) {} | 
            
  
    | 142 |  | } | 
            
  
    | 143 |  | } | 
            
  
    | 144 |  |  | 
            
  
    | 145 | 0 | Map<Object, Object> map = new HashMap<Object, Object>(); | 
            
  
    | 146 | 0 | for (Object key : props.keySet()) { | 
            
  
    | 147 | 0 | String realPrefix = prefix + "."; | 
            
  
    | 148 | 0 | String keyString = key.toString(); | 
            
  
    | 149 | 0 | if (keyString.startsWith(realPrefix)) { | 
            
  
    | 150 | 0 | map.put(keyString.substring(realPrefix.length()), props.get(key)); | 
            
  
    | 151 |  | } | 
            
  
    | 152 |  | } | 
            
  
    | 153 |  |  | 
            
  
    | 154 | 0 | return map; | 
            
  
    | 155 |  | } | 
            
  
    | 156 |  |  | 
            
  
    | 157 |  | } |