1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.generator.config;
17
18 import java.util.Enumeration;
19 import java.util.Properties;
20
21 import org.mybatis.generator.api.dom.xml.Attribute;
22 import org.mybatis.generator.api.dom.xml.XmlElement;
23
24
25
26
27 public abstract class PropertyHolder {
28 private Properties properties;
29
30
31
32
33 public PropertyHolder() {
34 super();
35 properties = new Properties();
36 }
37
38 public void addProperty(String name, String value) {
39 properties.setProperty(name, value);
40 }
41
42 public String getProperty(String name) {
43 return properties.getProperty(name);
44 }
45
46 public Properties getProperties() {
47 return properties;
48 }
49
50 protected void addPropertyXmlElements(XmlElement xmlElement) {
51 Enumeration<?> enumeration = properties.propertyNames();
52 while (enumeration.hasMoreElements()) {
53 String propertyName = (String) enumeration.nextElement();
54
55 XmlElement propertyElement = new XmlElement("property");
56 propertyElement.addAttribute(new Attribute("name", propertyName));
57 propertyElement.addAttribute(new Attribute(
58 "value", properties.getProperty(propertyName)));
59 xmlElement.addElement(propertyElement);
60 }
61 }
62 }