1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.shared.release.transform.jdom2;
20
21 import java.io.IOException;
22 import java.io.InputStream;
23 import java.io.OutputStream;
24 import java.io.PrintStream;
25 import java.io.PrintWriter;
26 import java.io.Reader;
27 import java.io.Writer;
28 import java.util.Enumeration;
29 import java.util.InvalidPropertiesFormatException;
30 import java.util.Properties;
31 import java.util.Set;
32
33 import org.jdom2.Element;
34
35
36
37
38
39
40
41
42 public class JDomProperties extends Properties {
43 private final Element properties;
44
45
46
47
48
49
50 public JDomProperties(Element properties) {
51 this.properties = properties;
52 }
53
54 @Override
55 public synchronized Object put(Object key, Object value) {
56 Element property = properties.getChild((String) key, properties.getNamespace());
57
58 if (property == null) {
59 property = new Element((String) key, properties.getNamespace());
60 }
61 JDomUtils.rewriteValue(property, (String) value);
62
63
64 return null;
65 }
66
67 @Override
68 public synchronized void load(Reader reader) throws IOException {
69 throw new UnsupportedOperationException();
70 }
71
72 @Override
73 public synchronized void load(InputStream inStream) throws IOException {
74 throw new UnsupportedOperationException();
75 }
76
77 @SuppressWarnings("deprecation")
78 @Override
79 public void save(OutputStream out, String comments) {
80 throw new UnsupportedOperationException();
81 }
82
83 @Override
84 public void store(Writer writer, String comments) throws IOException {
85 throw new UnsupportedOperationException();
86 }
87
88 @Override
89 public void store(OutputStream out, String comments) throws IOException {
90 throw new UnsupportedOperationException();
91 }
92
93 @Override
94 public synchronized void loadFromXML(InputStream in) throws IOException, InvalidPropertiesFormatException {
95 throw new UnsupportedOperationException();
96 }
97
98 @Override
99 public void storeToXML(OutputStream os, String comment) throws IOException {
100 throw new UnsupportedOperationException();
101 }
102
103 @Override
104 public void storeToXML(OutputStream os, String comment, String encoding) throws IOException {
105 throw new UnsupportedOperationException();
106 }
107
108 @Override
109 public String getProperty(String key) {
110 Element property = properties.getChild(key, properties.getNamespace());
111
112 if (property == null) {
113 return null;
114 } else {
115 return property.getTextTrim();
116 }
117 }
118
119 @Override
120 public boolean containsKey(Object key) {
121 if (key instanceof String) {
122 Element property = properties.getChild((String) key, properties.getNamespace());
123 return property != null;
124 }
125 return false;
126 }
127
128 @Override
129 public String getProperty(String key, String defaultValue) {
130 String property = getProperty(key);
131
132 return property == null ? defaultValue : property;
133 }
134
135 @Override
136 public Enumeration<?> propertyNames() {
137 throw new UnsupportedOperationException();
138 }
139
140 @Override
141 public Set<String> stringPropertyNames() {
142 throw new UnsupportedOperationException();
143 }
144
145 @Override
146 public void list(PrintStream out) {
147 throw new UnsupportedOperationException();
148 }
149
150 @Override
151 public void list(PrintWriter out) {
152 throw new UnsupportedOperationException();
153 }
154 }