View Javadoc

1   /*
2    * ModeShape (http://www.modeshape.org)
3    * See the COPYRIGHT.txt file distributed with this work for information
4    * regarding copyright ownership.  Some portions may be licensed
5    * to Red Hat, Inc. under one or more contributor license agreements.
6    * See the AUTHORS.txt file in the distribution for a full listing of 
7    * individual contributors. 
8    *
9    * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10   * is licensed to you under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation; either version 2.1 of
12   * the License, or (at your option) any later version.
13   *
14   * ModeShape is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this software; if not, write to the Free
21   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23   */
24  package org.modeshape.jdbc.util;
25  
26  import java.io.IOException;
27  import java.io.InputStream;
28  import java.io.OutputStream;
29  import java.io.PrintStream;
30  import java.io.PrintWriter;
31  import java.util.Collection;
32  import java.util.Collections;
33  import java.util.Enumeration;
34  import java.util.Map;
35  import java.util.Properties;
36  import java.util.Set;
37  import java.util.Map.Entry;
38  
39  /**
40   * An immutable {@link Properties} implementation.
41   */
42  public class UnmodifiableProperties extends Properties {
43  
44      /**
45       */
46      private static final long serialVersionUID = -4670639332874922546L;
47      private Properties delegate;
48  
49      public UnmodifiableProperties( Properties props ) {
50          super();
51          this.delegate = props != null ? props : new Properties();
52      }
53  
54      /**
55       * {@inheritDoc}
56       */
57      @Override
58      public synchronized Object clone() {
59          return new UnmodifiableProperties(this.delegate);
60      }
61  
62      /**
63       * {@inheritDoc}
64       */
65      @Override
66      public synchronized boolean contains( Object value ) {
67          return delegate.contains(value);
68      }
69  
70      /**
71       * {@inheritDoc}
72       */
73      @Override
74      public boolean containsKey( Object key ) {
75          return this.delegate.containsKey(key);
76      }
77  
78      /**
79       * {@inheritDoc}
80       */
81      @Override
82      public boolean containsValue( Object value ) {
83          return this.delegate.containsValue(value);
84      }
85  
86      /**
87       * {@inheritDoc}
88       */
89      @Override
90      public Enumeration<Object> elements() {
91          return this.delegate.elements();
92      }
93  
94      /**
95       * {@inheritDoc}
96       */
97      @Override
98      public boolean equals( Object o ) {
99          return this.delegate.equals(o);
100     }
101 
102     /**
103      * {@inheritDoc}
104      */
105     @Override
106     public Object get( Object key ) {
107         return this.delegate.get(key);
108     }
109 
110     /**
111      * {@inheritDoc}
112      */
113     @Override
114     public String getProperty( String key,
115                                String defaultValue ) {
116         return this.delegate.getProperty(key, defaultValue);
117     }
118 
119     /**
120      * {@inheritDoc}
121      */
122     @Override
123     public String getProperty( String key ) {
124         return this.delegate.getProperty(key);
125     }
126 
127     /**
128      * {@inheritDoc}
129      */
130     @Override
131     public int hashCode() {
132         return this.delegate.hashCode();
133     }
134 
135     /**
136      * {@inheritDoc}
137      */
138     @Override
139     public boolean isEmpty() {
140         return this.delegate.isEmpty();
141     }
142 
143     /**
144      * {@inheritDoc}
145      */
146     @Override
147     public Enumeration<Object> keys() {
148         return this.delegate.keys();
149     }
150 
151     /**
152      * {@inheritDoc}
153      */
154     @Override
155     public void list( PrintStream out ) {
156         this.delegate.list(out);
157     }
158 
159     /**
160      * {@inheritDoc}
161      */
162     @Override
163     public void list( PrintWriter out ) {
164         this.delegate.list(out);
165     }
166 
167     /**
168      * {@inheritDoc}
169      */
170     @Override
171     public Enumeration<?> propertyNames() {
172         return this.delegate.propertyNames();
173     }
174 
175     /**
176      * {@inheritDoc}
177      * 
178      * @deprecated This method does not throw an IOException if an I/O error occurs while saving the property list. The preferred
179      *             way to save a properties list is via the <code>store(OutputStream out, 
180      * String comments)</code> method or the <code>storeToXML(OutputStream os, String comment)</code> method.
181      * @see java.util.Properties#save(java.io.OutputStream, java.lang.String)
182      */
183     @Deprecated
184     @Override
185     public void save( OutputStream out,
186                       String comments ) {
187         this.delegate.save(out, comments);
188     }
189 
190     /**
191      * {@inheritDoc}
192      */
193     @Override
194     public int size() {
195         return this.delegate.size();
196     }
197 
198     /**
199      * {@inheritDoc}
200      */
201     @Override
202     public void store( OutputStream out,
203                        String comments ) throws IOException {
204         this.delegate.store(out, comments);
205     }
206 
207     /**
208      * {@inheritDoc}
209      */
210     @Override
211     public void storeToXML( OutputStream os,
212                             String comment,
213                             String encoding ) throws IOException {
214         this.delegate.storeToXML(os, comment, encoding);
215     }
216 
217     /**
218      * {@inheritDoc}
219      */
220     @Override
221     public void storeToXML( OutputStream os,
222                             String comment ) throws IOException {
223         this.delegate.storeToXML(os, comment);
224     }
225 
226     /**
227      * {@inheritDoc}
228      */
229     @Override
230     public String toString() {
231         return this.delegate.toString();
232     }
233 
234     /**
235      * {@inheritDoc}
236      */
237     @Override
238     public Collection<Object> values() {
239         return this.delegate.values();
240     }
241 
242     /**
243      * {@inheritDoc}
244      */
245     @Override
246     public synchronized void clear() {
247         throw new UnsupportedOperationException();
248     }
249 
250     /**
251      * {@inheritDoc}
252      */
253     @Override
254     public Set<Entry<Object, Object>> entrySet() {
255         return Collections.unmodifiableSet(super.entrySet());
256     }
257 
258     /**
259      * {@inheritDoc}
260      */
261     @Override
262     public Set<Object> keySet() {
263         return Collections.unmodifiableSet(super.keySet());
264     }
265 
266     /**
267      * {@inheritDoc}
268      */
269     @Override
270     public synchronized void load( InputStream inStream ) {
271         throw new UnsupportedOperationException();
272     }
273 
274     /**
275      * {@inheritDoc}
276      */
277     @Override
278     public synchronized void loadFromXML( InputStream in ) {
279         throw new UnsupportedOperationException();
280     }
281 
282     /**
283      * {@inheritDoc}
284      */
285     @Override
286     public synchronized Object put( Object key,
287                                     Object value ) {
288         throw new UnsupportedOperationException();
289     }
290 
291     /**
292      * {@inheritDoc}
293      */
294     @Override
295     public synchronized void putAll( Map<? extends Object, ? extends Object> t ) {
296         throw new UnsupportedOperationException();
297     }
298 
299     /**
300      * {@inheritDoc}
301      */
302     @Override
303     public synchronized Object remove( Object key ) {
304         throw new UnsupportedOperationException();
305     }
306 
307     /**
308      * {@inheritDoc}
309      */
310     @Override
311     public synchronized Object setProperty( String key,
312                                             String value ) {
313         throw new UnsupportedOperationException();
314     }
315 
316 }