001: package com.icesoft.faces.webapp.http.common;
002:
003: public abstract class Configuration {
004:
005: public abstract String getName();
006:
007: public abstract Configuration getChild(String child)
008: throws ConfigurationException;
009:
010: public abstract Configuration[] getChildren(String name)
011: throws ConfigurationException;
012:
013: public abstract String getAttribute(String paramName)
014: throws ConfigurationException;
015:
016: public abstract String getValue() throws ConfigurationException;
017:
018: public int getAttributeAsInteger(String name)
019: throws ConfigurationException {
020: return Integer.parseInt(getAttribute(name));
021: }
022:
023: public long getAttributeAsLong(String name)
024: throws ConfigurationException {
025: return Long.parseLong(getAttribute(name));
026: }
027:
028: public float getAttributeAsFloat(String name)
029: throws ConfigurationException {
030: return Float.parseFloat(getAttribute(name));
031: }
032:
033: public double getAttributeAsDouble(String name)
034: throws ConfigurationException {
035: return Double.parseDouble(getAttribute(name));
036: }
037:
038: public boolean getAttributeAsBoolean(String name)
039: throws ConfigurationException {
040: return Boolean.valueOf(getAttribute(name)).booleanValue();
041: }
042:
043: public String getAttribute(String name, String defaultValue) {
044: try {
045: return getAttribute(name);
046: } catch (Exception e) {
047: return defaultValue;
048: }
049: }
050:
051: public int getAttributeAsInteger(String name, int defaultValue) {
052: try {
053: return getAttributeAsInteger(name);
054: } catch (Exception e) {
055: return defaultValue;
056: }
057: }
058:
059: public long getAttributeAsLong(String name, long defaultValue) {
060: try {
061: return getAttributeAsLong(name);
062: } catch (Exception e) {
063: return defaultValue;
064: }
065: }
066:
067: public float getAttributeAsFloat(String name, float defaultValue) {
068: try {
069: return getAttributeAsFloat(name);
070: } catch (Exception e) {
071: return defaultValue;
072: }
073: }
074:
075: public double getAttributeAsDouble(String name, double defaultValue) {
076: try {
077: return getAttributeAsDouble(name);
078: } catch (Exception e) {
079: return defaultValue;
080: }
081: }
082:
083: public boolean getAttributeAsBoolean(String name,
084: boolean defaultValue) {
085: try {
086: return getAttributeAsBoolean(name);
087: } catch (Exception e) {
088: return defaultValue;
089: }
090: }
091:
092: public int getValueAsInteger() throws ConfigurationException {
093: return Integer.parseInt(getValue());
094: }
095:
096: public float getValueAsFloat() throws ConfigurationException {
097: return Float.parseFloat(getValue());
098: }
099:
100: public double getValueAsDouble() throws ConfigurationException {
101: return Double.parseDouble(getValue());
102: }
103:
104: public boolean getValueAsBoolean() throws ConfigurationException {
105: return Boolean.valueOf(getValue()).booleanValue();
106: }
107:
108: public long getValueAsLong() throws ConfigurationException {
109: return Long.parseLong(getValue());
110: }
111:
112: public String getValue(String defaultValue) {
113: try {
114: return getValue();
115: } catch (Exception e) {
116: return defaultValue;
117: }
118: }
119:
120: public int getValueAsInteger(int defaultValue) {
121: try {
122: return getValueAsInteger();
123: } catch (Exception e) {
124: return defaultValue;
125: }
126: }
127:
128: public long getValueAsLong(long defaultValue) {
129: try {
130: return getValueAsLong();
131: } catch (Exception e) {
132: return defaultValue;
133: }
134: }
135:
136: public float getValueAsFloat(float defaultValue) {
137: try {
138: return getValueAsFloat();
139: } catch (Exception e) {
140: return defaultValue;
141: }
142: }
143:
144: public double getValueAsDouble(double defaultValue) {
145: try {
146: return getValueAsDouble();
147: } catch (Exception e) {
148: return defaultValue;
149: }
150: }
151:
152: public boolean getValueAsBoolean(boolean defaultValue) {
153: try {
154: return getValueAsBoolean();
155: } catch (Exception e) {
156: return defaultValue;
157: }
158: }
159: }
|