1 package xdoclet.modules.ojb.model; 2 3 17 18 import java.util.*; 19 20 26 public abstract class DefBase 27 { 28 29 private DefBase _owner; 30 31 private String _name; 32 33 private Properties _properties = new Properties(); 34 35 40 public DefBase(String name) 41 { 42 _name = name; 43 } 44 45 51 public DefBase(DefBase src, String prefix) 52 { 53 _name = (prefix != null ? prefix + src._name : src._name); 54 55 String key; 56 57 for (Iterator it = src._properties.keySet().iterator(); it.hasNext();) 58 { 59 key = (String )it.next(); 60 setProperty(key, src._properties.getProperty(key)); 61 } 62 } 63 64 69 public DefBase getOwner() 70 { 71 return _owner; 72 } 73 74 79 public void setOwner(DefBase owner) 80 { 81 _owner = owner; 82 } 83 84 89 public String getName() 90 { 91 return _name; 92 } 93 94 100 public String getProperty(String name) 101 { 102 return _properties.getProperty(name); 103 } 104 105 112 public boolean getBooleanProperty(String name, boolean defaultValue) 113 { 114 return PropertyHelper.toBoolean(_properties.getProperty(name), defaultValue); 115 } 116 117 122 public Iterator getPropertyNames() 123 { 124 return _properties.keySet().iterator(); 125 } 126 127 133 public void setProperty(String name, String value) 134 { 135 if ((value == null) || (value.length() == 0)) 136 { 137 _properties.remove(name); 138 } 139 else 140 { 141 _properties.setProperty(name, value); 142 } 143 } 144 145 151 public boolean hasProperty(String name) 152 { 153 return _properties.containsKey(name); 154 } 155 156 163 public void applyModifications(Properties mods) 164 { 165 String key; 166 String value; 167 168 for (Iterator it = mods.keySet().iterator(); it.hasNext();) 169 { 170 key = (String )it.next(); 171 value = mods.getProperty(key); 172 setProperty(key, value); 173 } 174 } 175 176 public String toString() 177 { 178 return getName(); 179 } 180 } 181 | Popular Tags |