View Javadoc
1   package org.apache.maven.shared.release.transform.jdom;
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.jdom.Element;
35  
36  /**
37   * JDom 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      public JDomProperties( Element properties )
47      {
48          this.properties = properties;
49      }
50  
51      @Override
52      public synchronized Object setProperty( String key, String value )
53      {
54          Element property = properties.getChild( key, properties.getNamespace() );
55  
56          JDomUtils.rewriteValue( property, value );
57  
58          // todo follow specs of Hashtable.put
59          return null;
60      }
61  
62      @Override
63      public synchronized void load( Reader reader )
64          throws IOException
65      {
66          throw new UnsupportedOperationException();
67      }
68  
69      @Override
70      public synchronized void load( InputStream inStream )
71          throws IOException
72      {
73          throw new UnsupportedOperationException();
74      }
75  
76      @Override
77      public void save( OutputStream out, String comments )
78      {
79          throw new UnsupportedOperationException();
80      }
81  
82      @Override
83      public void store( Writer writer, String comments )
84          throws IOException
85      {
86          throw new UnsupportedOperationException();
87      }
88  
89      @Override
90      public void store( OutputStream out, String comments )
91          throws IOException
92      {
93          throw new UnsupportedOperationException();
94      }
95  
96      @Override
97      public synchronized void loadFromXML( InputStream in )
98          throws IOException, InvalidPropertiesFormatException
99      {
100         throw new UnsupportedOperationException();
101     }
102 
103     @Override
104     public void storeToXML( OutputStream os, String comment )
105         throws IOException
106     {
107         throw new UnsupportedOperationException();
108     }
109 
110     @Override
111     public void storeToXML( OutputStream os, String comment, String encoding )
112         throws IOException
113     {
114         throw new UnsupportedOperationException();
115     }
116 
117     @Override
118     public String getProperty( String key )
119     {
120         Element property = properties.getChild( key, properties.getNamespace() );
121 
122         if ( property == null )
123         {
124             return null;
125         }
126         else
127         {
128             return property.getTextTrim();
129         }
130     }
131 
132     @Override
133     public String getProperty( String key, String defaultValue )
134     {
135         throw new UnsupportedOperationException();
136     }
137 
138     @Override
139     public Enumeration<?> propertyNames()
140     {
141         throw new UnsupportedOperationException();
142     }
143 
144     @Override
145     public Set<String> stringPropertyNames()
146     {
147         throw new UnsupportedOperationException();
148     }
149 
150     @Override
151     public void list( PrintStream out )
152     {
153         throw new UnsupportedOperationException();
154     }
155 
156     @Override
157     public void list( PrintWriter out )
158     {
159         throw new UnsupportedOperationException();
160     }
161 }