001 /* 002 * JBoss DNA (http://www.jboss.org/dna) 003 * See the COPYRIGHT.txt file distributed with this work for information 004 * regarding copyright ownership. Some portions may be licensed 005 * to Red Hat, Inc. under one or more contributor license agreements. 006 * See the AUTHORS.txt file in the distribution for a full listing of 007 * individual contributors. 008 * 009 * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA 010 * is licensed to you under the terms of the GNU Lesser General Public License as 011 * published by the Free Software Foundation; either version 2.1 of 012 * the License, or (at your option) any later version. 013 * 014 * JBoss DNA is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 017 * Lesser General Public License for more details. 018 * 019 * You should have received a copy of the GNU Lesser General Public 020 * License along with this software; if not, write to the Free 021 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 022 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 023 */ 024 package org.jboss.dna.common.collection; 025 026 import java.io.IOException; 027 import java.io.InputStream; 028 import java.io.OutputStream; 029 import java.io.PrintStream; 030 import java.io.PrintWriter; 031 import java.util.Collection; 032 import java.util.Collections; 033 import java.util.Enumeration; 034 import java.util.Map; 035 import java.util.Properties; 036 import java.util.Set; 037 import java.util.Map.Entry; 038 039 /** 040 * @author Randall Hauch 041 */ 042 public class UnmodifiableProperties extends Properties { 043 044 /** 045 */ 046 private static final long serialVersionUID = -4670639332874922546L; 047 private Properties delegate; 048 049 public UnmodifiableProperties( Properties props ) { 050 super(); 051 this.delegate = props != null ? props : new Properties(); 052 } 053 054 /** 055 * {@inheritDoc} 056 */ 057 @Override 058 public synchronized Object clone() { 059 return new UnmodifiableProperties(this.delegate); 060 } 061 062 /** 063 * {@inheritDoc} 064 */ 065 @Override 066 public synchronized boolean contains( Object value ) { 067 return delegate.contains(value); 068 } 069 070 /** 071 * {@inheritDoc} 072 */ 073 @Override 074 public boolean containsKey( Object key ) { 075 return this.delegate.containsKey(key); 076 } 077 078 /** 079 * {@inheritDoc} 080 */ 081 @Override 082 public boolean containsValue( Object value ) { 083 return this.delegate.containsValue(value); 084 } 085 086 /** 087 * {@inheritDoc} 088 */ 089 @Override 090 public Enumeration<Object> elements() { 091 return this.delegate.elements(); 092 } 093 094 /** 095 * {@inheritDoc} 096 */ 097 @Override 098 public boolean equals( Object o ) { 099 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 179 */ 180 @Deprecated 181 @Override 182 public void save( OutputStream out, 183 String comments ) { 184 this.delegate.save(out, comments); 185 } 186 187 /** 188 * {@inheritDoc} 189 */ 190 @Override 191 public int size() { 192 return this.delegate.size(); 193 } 194 195 /** 196 * {@inheritDoc} 197 */ 198 @Override 199 public void store( OutputStream out, 200 String comments ) throws IOException { 201 this.delegate.store(out, comments); 202 } 203 204 /** 205 * {@inheritDoc} 206 */ 207 @Override 208 public void storeToXML( OutputStream os, 209 String comment, 210 String encoding ) throws IOException { 211 this.delegate.storeToXML(os, comment, encoding); 212 } 213 214 /** 215 * {@inheritDoc} 216 */ 217 @Override 218 public void storeToXML( OutputStream os, 219 String comment ) throws IOException { 220 this.delegate.storeToXML(os, comment); 221 } 222 223 /** 224 * {@inheritDoc} 225 */ 226 @Override 227 public String toString() { 228 return this.delegate.toString(); 229 } 230 231 /** 232 * {@inheritDoc} 233 */ 234 @Override 235 public Collection<Object> values() { 236 return this.delegate.values(); 237 } 238 239 /** 240 * {@inheritDoc} 241 */ 242 @Override 243 public synchronized void clear() { 244 throw new UnsupportedOperationException(); 245 } 246 247 /** 248 * {@inheritDoc} 249 */ 250 @Override 251 public Set<Entry<Object, Object>> entrySet() { 252 return Collections.unmodifiableSet(super.entrySet()); 253 } 254 255 /** 256 * {@inheritDoc} 257 */ 258 @Override 259 public Set<Object> keySet() { 260 return Collections.unmodifiableSet(super.keySet()); 261 } 262 263 /** 264 * {@inheritDoc} 265 */ 266 @Override 267 public synchronized void load( InputStream inStream ) { 268 throw new UnsupportedOperationException(); 269 } 270 271 /** 272 * {@inheritDoc} 273 */ 274 @Override 275 public synchronized void loadFromXML( InputStream in ) { 276 throw new UnsupportedOperationException(); 277 } 278 279 /** 280 * {@inheritDoc} 281 */ 282 @Override 283 public synchronized Object put( Object key, 284 Object value ) { 285 throw new UnsupportedOperationException(); 286 } 287 288 /** 289 * {@inheritDoc} 290 */ 291 @Override 292 public synchronized void putAll( Map<? extends Object, ? extends Object> t ) { 293 throw new UnsupportedOperationException(); 294 } 295 296 /** 297 * {@inheritDoc} 298 */ 299 @Override 300 public synchronized Object remove( Object key ) { 301 throw new UnsupportedOperationException(); 302 } 303 304 /** 305 * {@inheritDoc} 306 */ 307 @Override 308 public synchronized Object setProperty( String key, 309 String value ) { 310 throw new UnsupportedOperationException(); 311 } 312 313 }