View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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   * JDOM2 implementation of poms PROPERTIES element
37   *
38   * @author Robert Scholte
39   * @since 3.0
40   */
41  public class JDomProperties extends Properties {
42      private final Element properties;
43  
44      /**
45       * <p>Constructor for JDomProperties.</p>
46       *
47       * @param properties a {@link org.jdom2.Element} object
48       */
49      public JDomProperties(Element properties) {
50          this.properties = properties;
51      }
52  
53      @Override
54      public synchronized Object setProperty(String key, String value) {
55          Element property = properties.getChild(key, properties.getNamespace());
56  
57          JDomUtils.rewriteValue(property, value);
58  
59          // todo follow specs of Hashtable.put
60          return null;
61      }
62  
63      @Override
64      public synchronized void load(Reader reader) throws IOException {
65          throw new UnsupportedOperationException();
66      }
67  
68      @Override
69      public synchronized void load(InputStream inStream) throws IOException {
70          throw new UnsupportedOperationException();
71      }
72  
73      @SuppressWarnings("deprecation")
74      @Override
75      public void save(OutputStream out, String comments) {
76          throw new UnsupportedOperationException();
77      }
78  
79      @Override
80      public void store(Writer writer, String comments) throws IOException {
81          throw new UnsupportedOperationException();
82      }
83  
84      @Override
85      public void store(OutputStream out, String comments) throws IOException {
86          throw new UnsupportedOperationException();
87      }
88  
89      @Override
90      public synchronized void loadFromXML(InputStream in) throws IOException, InvalidPropertiesFormatException {
91          throw new UnsupportedOperationException();
92      }
93  
94      @Override
95      public void storeToXML(OutputStream os, String comment) throws IOException {
96          throw new UnsupportedOperationException();
97      }
98  
99      @Override
100     public void storeToXML(OutputStream os, String comment, String encoding) throws IOException {
101         throw new UnsupportedOperationException();
102     }
103 
104     @Override
105     public String getProperty(String key) {
106         Element property = properties.getChild(key, properties.getNamespace());
107 
108         if (property == null) {
109             return null;
110         } else {
111             return property.getTextTrim();
112         }
113     }
114 
115     @Override
116     public String getProperty(String key, String defaultValue) {
117         throw new UnsupportedOperationException();
118     }
119 
120     @Override
121     public Enumeration<?> propertyNames() {
122         throw new UnsupportedOperationException();
123     }
124 
125     @Override
126     public Set<String> stringPropertyNames() {
127         throw new UnsupportedOperationException();
128     }
129 
130     @Override
131     public void list(PrintStream out) {
132         throw new UnsupportedOperationException();
133     }
134 
135     @Override
136     public void list(PrintWriter out) {
137         throw new UnsupportedOperationException();
138     }
139 }