01: package net.javacoding.jspider.mockobjects;
02:
03: import net.javacoding.jspider.core.util.config.PropertySet;
04:
05: import java.util.HashMap;
06:
07: /**
08: * $Id: OverridingPropertySet.java,v 1.1 2002/12/29 15:30:00 vanrogu Exp $
09: */
10: public class OverridingPropertySet implements PropertySet {
11:
12: protected PropertySet props;
13: protected HashMap overridden;
14:
15: public OverridingPropertySet(PropertySet props) {
16: this .props = props;
17: this .overridden = new HashMap();
18: }
19:
20: public void setValue(String name, Object value) {
21: overridden.put(name, value);
22: }
23:
24: public String getString(String name, String defaultValue) {
25: if (overridden.containsKey(name)) {
26: return (String) overridden.get(name);
27: } else {
28: return props.getString(name, defaultValue);
29: }
30: }
31:
32: public Class getClass(String name, Class defaultValue) {
33: if (overridden.containsKey(name)) {
34: return (Class) overridden.get(name);
35: } else {
36: return props.getClass(name, defaultValue);
37: }
38: }
39:
40: public int getInteger(String name, int defaultValue) {
41: if (overridden.containsKey(name)) {
42: return ((Integer) overridden.get(name)).intValue();
43: } else {
44: return props.getInteger(name, defaultValue);
45: }
46: }
47:
48: public boolean getBoolean(String name, boolean defaultValue) {
49: if (overridden.containsKey(name)) {
50: return ((Boolean) overridden.get(name)).booleanValue();
51: } else {
52: return props.getBoolean(name, defaultValue);
53: }
54: }
55: }
|