1 16 17 package org.apache.cocoon.components.slide.impl; 18 19 import java.util.Enumeration ; 20 import java.util.Vector ; 21 22 import org.apache.slide.util.conf.Configuration; 23 import org.apache.slide.util.conf.ConfigurationException; 24 25 30 public class SlideConfigurationAdapter implements Configuration { 31 32 private org.apache.avalon.framework.configuration.Configuration configuration; 33 34 40 public SlideConfigurationAdapter(org.apache.avalon.framework.configuration.Configuration configuration) { 41 this.configuration = configuration; 42 } 43 44 49 public String getName() { 50 return this.configuration.getName(); 51 } 52 53 63 public Configuration getConfiguration(String child) 64 throws ConfigurationException { 65 if (this.configuration.getChild(child, false) == null) 66 throw new ConfigurationException("No configuration element " + child 67 + " at " + this.configuration.getLocation(), this); 68 return new SlideConfigurationAdapter(this.configuration.getChild(child)); 69 } 70 71 80 public Enumeration getConfigurations(String name) { 81 82 Vector configurations = new Vector (); 83 org.apache.avalon.framework.configuration.Configuration[] childs = this.configuration.getChildren(name); 84 85 for (int i = 0; i<childs.length; i++) { 86 configurations.addElement(new SlideConfigurationAdapter(childs[i])); 87 } 88 return configurations.elements(); 89 } 90 91 100 public String getAttribute(String paramName) 101 throws ConfigurationException { 102 103 try { 104 return this.configuration.getAttribute(paramName); 105 } catch (org.apache.avalon.framework.configuration.ConfigurationException ce) { 106 throw new ConfigurationException(ce.getMessage(), this); 107 } 108 } 109 110 121 public int getAttributeAsInt(String paramName) 122 throws ConfigurationException { 123 124 try { 125 return this.configuration.getAttributeAsInteger(paramName); 126 } catch (org.apache.avalon.framework.configuration.ConfigurationException ce) { 127 throw new ConfigurationException(ce.getMessage(), this); 128 } 129 } 130 131 143 public long getAttributeAsLong(String name) 144 throws ConfigurationException { 145 146 try { 147 return this.configuration.getAttributeAsLong(name); 148 } catch (org.apache.avalon.framework.configuration.ConfigurationException ce) { 149 throw new ConfigurationException(ce.getMessage(), this); 150 } 151 } 152 153 164 public float getAttributeAsFloat(String paramName) 165 throws ConfigurationException { 166 167 try { 168 return this.configuration.getAttributeAsFloat(paramName); 169 } catch (org.apache.avalon.framework.configuration.ConfigurationException ce) { 170 throw new ConfigurationException(ce.getMessage(), this); 171 } 172 } 173 174 185 public boolean getAttributeAsBoolean(String paramName) 186 throws ConfigurationException { 187 188 try { 189 return this.configuration.getAttributeAsBoolean(paramName); 190 } catch (org.apache.avalon.framework.configuration.ConfigurationException ce) { 191 throw new ConfigurationException(ce.getMessage(), this); 192 } 193 } 194 195 200 public String getValue() { 201 202 try { 203 return this.configuration.getValue(); 204 } catch (org.apache.avalon.framework.configuration.ConfigurationException ce) { 205 return ""; 206 } 207 } 208 209 216 public int getValueAsInt() throws ConfigurationException { 217 218 try { 219 return this.configuration.getValueAsInteger(); 220 } catch (org.apache.avalon.framework.configuration.ConfigurationException ce) { 221 throw new ConfigurationException(ce.getMessage(), this); 222 } 223 } 224 225 232 public float getValueAsFloat() throws ConfigurationException { 233 234 try { 235 return this.configuration.getValueAsFloat(); 236 } catch (org.apache.avalon.framework.configuration.ConfigurationException ce) { 237 throw new ConfigurationException(ce.getMessage(), this); 238 } 239 } 240 241 248 public boolean getValueAsBoolean() throws ConfigurationException { 249 250 try { 251 return this.configuration.getValueAsBoolean(); 252 } catch (org.apache.avalon.framework.configuration.ConfigurationException ce) { 253 throw new ConfigurationException(ce.getMessage(), this); 254 } 255 } 256 257 264 public long getValueAsLong() throws ConfigurationException { 265 266 try { 267 return this.configuration.getValueAsLong(); 268 } catch (org.apache.avalon.framework.configuration.ConfigurationException ce) { 269 throw new ConfigurationException(ce.getMessage(), this); 270 } 271 } 272 273 283 public String getValue(String defaultValue) { 284 285 return this.configuration.getValue(defaultValue); 286 } 287 288 298 public int getValueAsInt(int defaultValue) { 299 300 return this.configuration.getValueAsInteger(defaultValue); 301 } 302 303 313 public long getValueAsLong(long defaultValue) { 314 315 return this.configuration.getValueAsLong(defaultValue); 316 } 317 318 328 public float getValueAsFloat(float defaultValue) { 329 330 return this.configuration.getValueAsFloat(defaultValue); 331 } 332 333 343 public boolean getValueAsBoolean(boolean defaultValue) { 344 345 return this.configuration.getValueAsBoolean(defaultValue); 346 } 347 348 360 public String getAttribute(String name, String defaultValue) { 361 362 return this.configuration.getAttribute(name, defaultValue); 363 } 364 365 377 public int getAttributeAsInt(String name, int defaultValue) { 378 379 return this.configuration.getAttributeAsInteger(name, defaultValue); 380 } 381 382 394 public long getAttributeAsLong(String name, long defaultValue) { 395 396 return this.configuration.getAttributeAsLong(name, defaultValue); 397 } 398 399 411 public float getAttributeAsFloat(String name, float defaultValue) { 412 413 return this.configuration.getAttributeAsFloat(name, defaultValue); 414 } 415 416 428 public boolean getAttributeAsBoolean(String name, boolean defaultValue) { 429 430 return this.configuration.getAttributeAsBoolean(name, defaultValue); 431 } 432 433 440 public String getLocation() { 441 442 return this.configuration.getLocation(); 443 } 444 } 445 | Popular Tags |