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.common.collection;
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  import net.jcip.annotations.Immutable;
39  
40  /**
41   * An immutable {@link Properties} implementation.
42   */
43  @Immutable
44  public class UnmodifiableProperties extends Properties {
45  
46      /**
47       */
48      private static final long serialVersionUID = -4670639332874922546L;
49      private Properties delegate;
50  
51      public UnmodifiableProperties( Properties props ) {
52          super();
53          this.delegate = props != null ? props : new Properties();
54      }
55  
56      /**
57       * {@inheritDoc}
58       */
59      @Override
60      public synchronized Object clone() {
61          return new UnmodifiableProperties(this.delegate);
62      }
63  
64      /**
65       * {@inheritDoc}
66       */
67      @Override
68      public synchronized boolean contains( Object value ) {
69          return delegate.contains(value);
70      }
71  
72      /**
73       * {@inheritDoc}
74       */
75      @Override
76      public boolean containsKey( Object key ) {
77          return this.delegate.containsKey(key);
78      }
79  
80      /**
81       * {@inheritDoc}
82       */
83      @Override
84      public boolean containsValue( Object value ) {
85          return this.delegate.containsValue(value);
86      }
87  
88      /**
89       * {@inheritDoc}
90       */
91      @Override
92      public Enumeration<Object> elements() {
93          return this.delegate.elements();
94      }
95  
96      /**
97       * {@inheritDoc}
98       */
99      @Override
100     public boolean equals( Object o ) {
101         return this.delegate.equals(o);
102     }
103 
104     /**
105      * {@inheritDoc}
106      */
107     @Override
108     public Object get( Object key ) {
109         return this.delegate.get(key);
110     }
111 
112     /**
113      * {@inheritDoc}
114      */
115     @Override
116     public String getProperty( String key,
117                                String defaultValue ) {
118         return this.delegate.getProperty(key, defaultValue);
119     }
120 
121     /**
122      * {@inheritDoc}
123      */
124     @Override
125     public String getProperty( String key ) {
126         return this.delegate.getProperty(key);
127     }
128 
129     /**
130      * {@inheritDoc}
131      */
132     @Override
133     public int hashCode() {
134         return this.delegate.hashCode();
135     }
136 
137     /**
138      * {@inheritDoc}
139      */
140     @Override
141     public boolean isEmpty() {
142         return this.delegate.isEmpty();
143     }
144 
145     /**
146      * {@inheritDoc}
147      */
148     @Override
149     public Enumeration<Object> keys() {
150         return this.delegate.keys();
151     }
152 
153     /**
154      * {@inheritDoc}
155      */
156     @Override
157     public void list( PrintStream out ) {
158         this.delegate.list(out);
159     }
160 
161     /**
162      * {@inheritDoc}
163      */
164     @Override
165     public void list( PrintWriter out ) {
166         this.delegate.list(out);
167     }
168 
169     /**
170      * {@inheritDoc}
171      */
172     @Override
173     public Enumeration<?> propertyNames() {
174         return this.delegate.propertyNames();
175     }
176 
177     /**
178      * {@inheritDoc}
179      * 
180      * @deprecated
181      */
182     @Deprecated
183     @Override
184     public void save( OutputStream out,
185                       String comments ) {
186         this.delegate.save(out, comments);
187     }
188 
189     /**
190      * {@inheritDoc}
191      */
192     @Override
193     public int size() {
194         return this.delegate.size();
195     }
196 
197     /**
198      * {@inheritDoc}
199      */
200     @Override
201     public void store( OutputStream out,
202                        String comments ) throws IOException {
203         this.delegate.store(out, comments);
204     }
205 
206     /**
207      * {@inheritDoc}
208      */
209     @Override
210     public void storeToXML( OutputStream os,
211                             String comment,
212                             String encoding ) throws IOException {
213         this.delegate.storeToXML(os, comment, encoding);
214     }
215 
216     /**
217      * {@inheritDoc}
218      */
219     @Override
220     public void storeToXML( OutputStream os,
221                             String comment ) throws IOException {
222         this.delegate.storeToXML(os, comment);
223     }
224 
225     /**
226      * {@inheritDoc}
227      */
228     @Override
229     public String toString() {
230         return this.delegate.toString();
231     }
232 
233     /**
234      * {@inheritDoc}
235      */
236     @Override
237     public Collection<Object> values() {
238         return this.delegate.values();
239     }
240 
241     /**
242      * {@inheritDoc}
243      */
244     @Override
245     public synchronized void clear() {
246         throw new UnsupportedOperationException();
247     }
248 
249     /**
250      * {@inheritDoc}
251      */
252     @Override
253     public Set<Entry<Object, Object>> entrySet() {
254         return Collections.unmodifiableSet(super.entrySet());
255     }
256 
257     /**
258      * {@inheritDoc}
259      */
260     @Override
261     public Set<Object> keySet() {
262         return Collections.unmodifiableSet(super.keySet());
263     }
264 
265     /**
266      * {@inheritDoc}
267      */
268     @Override
269     public synchronized void load( InputStream inStream ) {
270         throw new UnsupportedOperationException();
271     }
272 
273     /**
274      * {@inheritDoc}
275      */
276     @Override
277     public synchronized void loadFromXML( InputStream in ) {
278         throw new UnsupportedOperationException();
279     }
280 
281     /**
282      * {@inheritDoc}
283      */
284     @Override
285     public synchronized Object put( Object key,
286                                     Object value ) {
287         throw new UnsupportedOperationException();
288     }
289 
290     /**
291      * {@inheritDoc}
292      */
293     @Override
294     public synchronized void putAll( Map<? extends Object, ? extends Object> t ) {
295         throw new UnsupportedOperationException();
296     }
297 
298     /**
299      * {@inheritDoc}
300      */
301     @Override
302     public synchronized Object remove( Object key ) {
303         throw new UnsupportedOperationException();
304     }
305 
306     /**
307      * {@inheritDoc}
308      */
309     @Override
310     public synchronized Object setProperty( String key,
311                                             String value ) {
312         throw new UnsupportedOperationException();
313     }
314 
315 }