1 41 42 package org.jfree.util; 43 44 import java.util.Iterator ; 45 import java.util.Enumeration ; 46 47 52 public class ExtendedConfigurationWrapper 53 implements ExtendedConfiguration 54 { 55 56 private Configuration parent; 57 58 64 public ExtendedConfigurationWrapper (final Configuration parent) 65 { 66 if (parent == null) 67 { 68 throw new NullPointerException ("Parent given must not be null"); 69 } 70 this.parent = parent; 71 } 72 73 80 public boolean getBoolProperty (final String name) 81 { 82 return getBoolProperty(name, false); 83 } 84 85 94 public boolean getBoolProperty (final String name, 95 final boolean defaultValue) 96 { 97 return "true".equals(parent.getConfigProperty(name, String.valueOf(defaultValue))); 98 } 99 100 107 public int getIntProperty (final String name) 108 { 109 return getIntProperty(name, 0); 110 } 111 112 120 public int getIntProperty (final String name, 121 final int defaultValue) 122 { 123 final String retval = parent.getConfigProperty(name); 124 if (retval == null) 125 { 126 return defaultValue; 127 } 128 try 129 { 130 return Integer.parseInt(retval); 131 } 132 catch (Exception e) 133 { 134 return defaultValue; 135 } 136 } 137 138 144 public boolean isPropertySet (final String name) 145 { 146 return parent.getConfigProperty(name) != null; 147 } 148 149 155 public Iterator findPropertyKeys (final String prefix) 156 { 157 return parent.findPropertyKeys(prefix); 158 } 159 160 166 public String getConfigProperty (final String key) 167 { 168 return parent.getConfigProperty(key); 169 } 170 171 182 public String getConfigProperty (final String key, final String defaultValue) 183 { 184 return parent.getConfigProperty(key, defaultValue); 185 } 186 187 public Enumeration getConfigProperties() 188 { 189 return parent.getConfigProperties(); 190 } 191 192 public Object clone () throws CloneNotSupportedException 193 { 194 ExtendedConfigurationWrapper wrapper = (ExtendedConfigurationWrapper) super.clone(); 195 wrapper.parent = (Configuration) parent.clone(); 196 return parent; 197 } 198 } 199 | Popular Tags |