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