1 package com.icesoft.faces.webapp.http.common; 2 3 public abstract class Configuration { 4 5 public abstract String getName(); 6 7 public abstract Configuration getChild(String child) throws ConfigurationException; 8 9 public abstract Configuration[] getChildren(String name) throws ConfigurationException; 10 11 public abstract String getAttribute(String paramName) throws ConfigurationException; 12 13 public abstract String getValue() throws ConfigurationException; 14 15 public int getAttributeAsInteger(String name) throws ConfigurationException { 16 return Integer.parseInt(getAttribute(name)); 17 } 18 19 public long getAttributeAsLong(String name) throws ConfigurationException { 20 return Long.parseLong(getAttribute(name)); 21 } 22 23 public float getAttributeAsFloat(String name) throws ConfigurationException { 24 return Float.parseFloat(getAttribute(name)); 25 } 26 27 public double getAttributeAsDouble(String name) throws ConfigurationException { 28 return Double.parseDouble(getAttribute(name)); 29 } 30 31 public boolean getAttributeAsBoolean(String name) throws ConfigurationException { 32 return Boolean.valueOf(getAttribute(name)).booleanValue(); 33 } 34 35 public String getAttribute(String name, String defaultValue) { 36 try { 37 return getAttribute(name); 38 } catch (Exception e) { 39 return defaultValue; 40 } 41 } 42 43 public int getAttributeAsInteger(String name, int defaultValue) { 44 try { 45 return getAttributeAsInteger(name); 46 } catch (Exception e) { 47 return defaultValue; 48 } 49 } 50 51 public long getAttributeAsLong(String name, long defaultValue) { 52 try { 53 return getAttributeAsLong(name); 54 } catch (Exception e) { 55 return defaultValue; 56 } 57 } 58 59 public float getAttributeAsFloat(String name, float defaultValue) { 60 try { 61 return getAttributeAsFloat(name); 62 } catch (Exception e) { 63 return defaultValue; 64 } 65 } 66 67 public double getAttributeAsDouble(String name, double defaultValue) { 68 try { 69 return getAttributeAsDouble(name); 70 } catch (Exception e) { 71 return defaultValue; 72 } 73 } 74 75 public boolean getAttributeAsBoolean(String name, boolean defaultValue) { 76 try { 77 return getAttributeAsBoolean(name); 78 } catch (Exception e) { 79 return defaultValue; 80 } 81 } 82 83 public int getValueAsInteger() throws ConfigurationException { 84 return Integer.parseInt(getValue()); 85 } 86 87 public float getValueAsFloat() throws ConfigurationException { 88 return Float.parseFloat(getValue()); 89 } 90 91 public double getValueAsDouble() throws ConfigurationException { 92 return Double.parseDouble(getValue()); 93 } 94 95 public boolean getValueAsBoolean() throws ConfigurationException { 96 return Boolean.valueOf(getValue()).booleanValue(); 97 } 98 99 public long getValueAsLong() throws ConfigurationException { 100 return Long.parseLong(getValue()); 101 } 102 103 public String getValue(String defaultValue) { 104 try { 105 return getValue(); 106 } catch (Exception e) { 107 return defaultValue; 108 } 109 } 110 111 public int getValueAsInteger(int defaultValue) { 112 try { 113 return getValueAsInteger(); 114 } catch (Exception e) { 115 return defaultValue; 116 } 117 } 118 119 public long getValueAsLong(long defaultValue) { 120 try { 121 return getValueAsLong(); 122 } catch (Exception e) { 123 return defaultValue; 124 } 125 } 126 127 public float getValueAsFloat(float defaultValue) { 128 try { 129 return getValueAsFloat(); 130 } catch (Exception e) { 131 return defaultValue; 132 } 133 } 134 135 public double getValueAsDouble(double defaultValue) { 136 try { 137 return getValueAsDouble(); 138 } catch (Exception e) { 139 return defaultValue; 140 } 141 } 142 143 public boolean getValueAsBoolean(boolean defaultValue) { 144 try { 145 return getValueAsBoolean(); 146 } catch (Exception e) { 147 return defaultValue; 148 } 149 } 150 } 151 | Popular Tags |