001 /* 002 * JBoss, Home of Professional Open Source. 003 * Copyright 2008, Red Hat Middleware LLC, and individual contributors 004 * as indicated by the @author tags. See the copyright.txt file in the 005 * distribution for a full listing of individual contributors. 006 * 007 * This is free software; you can redistribute it and/or modify it 008 * under the terms of the GNU Lesser General Public License as 009 * published by the Free Software Foundation; either version 2.1 of 010 * the License, or (at your option) any later version. 011 * 012 * This software is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this software; if not, write to the Free 019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 021 */ 022 package org.jboss.dna.common.collection; 023 024 import java.io.IOException; 025 import java.io.InputStream; 026 import java.io.OutputStream; 027 import java.io.PrintStream; 028 import java.io.PrintWriter; 029 import java.util.Collection; 030 import java.util.Collections; 031 import java.util.Enumeration; 032 import java.util.Map; 033 import java.util.Properties; 034 import java.util.Set; 035 import java.util.Map.Entry; 036 037 /** 038 * @author Randall Hauch 039 */ 040 public class UnmodifiableProperties extends Properties { 041 042 /** 043 */ 044 private static final long serialVersionUID = -4670639332874922546L; 045 private Properties delegate; 046 047 public UnmodifiableProperties( Properties props ) { 048 super(); 049 this.delegate = props != null ? props : new Properties(); 050 } 051 052 /** 053 * {@inheritDoc} 054 */ 055 @Override 056 public synchronized Object clone() { 057 return new UnmodifiableProperties(this.delegate); 058 } 059 060 /** 061 * {@inheritDoc} 062 */ 063 @Override 064 public synchronized boolean contains( Object value ) { 065 return delegate.contains(value); 066 } 067 068 /** 069 * {@inheritDoc} 070 */ 071 @Override 072 public boolean containsKey( Object key ) { 073 return this.delegate.containsKey(key); 074 } 075 076 /** 077 * {@inheritDoc} 078 */ 079 @Override 080 public boolean containsValue( Object value ) { 081 return this.delegate.containsValue(value); 082 } 083 084 /** 085 * {@inheritDoc} 086 */ 087 @Override 088 public Enumeration<Object> elements() { 089 return this.delegate.elements(); 090 } 091 092 /** 093 * {@inheritDoc} 094 */ 095 @Override 096 public boolean equals( Object o ) { 097 return this.delegate.equals(o); 098 } 099 100 /** 101 * {@inheritDoc} 102 */ 103 @Override 104 public Object get( Object key ) { 105 return this.delegate.get(key); 106 } 107 108 /** 109 * {@inheritDoc} 110 */ 111 @Override 112 public String getProperty( String key, 113 String defaultValue ) { 114 return this.delegate.getProperty(key, defaultValue); 115 } 116 117 /** 118 * {@inheritDoc} 119 */ 120 @Override 121 public String getProperty( String key ) { 122 return this.delegate.getProperty(key); 123 } 124 125 /** 126 * {@inheritDoc} 127 */ 128 @Override 129 public int hashCode() { 130 return this.delegate.hashCode(); 131 } 132 133 /** 134 * {@inheritDoc} 135 */ 136 @Override 137 public boolean isEmpty() { 138 return this.delegate.isEmpty(); 139 } 140 141 /** 142 * {@inheritDoc} 143 */ 144 @Override 145 public Enumeration<Object> keys() { 146 return this.delegate.keys(); 147 } 148 149 /** 150 * {@inheritDoc} 151 */ 152 @Override 153 public void list( PrintStream out ) { 154 this.delegate.list(out); 155 } 156 157 /** 158 * {@inheritDoc} 159 */ 160 @Override 161 public void list( PrintWriter out ) { 162 this.delegate.list(out); 163 } 164 165 /** 166 * {@inheritDoc} 167 */ 168 @Override 169 public Enumeration<?> propertyNames() { 170 return this.delegate.propertyNames(); 171 } 172 173 /** 174 * {@inheritDoc} 175 * 176 * @deprecated 177 */ 178 @Deprecated 179 @Override 180 public void save( OutputStream out, 181 String comments ) { 182 this.delegate.save(out, comments); 183 } 184 185 /** 186 * {@inheritDoc} 187 */ 188 @Override 189 public int size() { 190 return this.delegate.size(); 191 } 192 193 /** 194 * {@inheritDoc} 195 */ 196 @Override 197 public void store( OutputStream out, 198 String comments ) throws IOException { 199 this.delegate.store(out, comments); 200 } 201 202 /** 203 * {@inheritDoc} 204 */ 205 @Override 206 public void storeToXML( OutputStream os, 207 String comment, 208 String encoding ) throws IOException { 209 this.delegate.storeToXML(os, comment, encoding); 210 } 211 212 /** 213 * {@inheritDoc} 214 */ 215 @Override 216 public void storeToXML( OutputStream os, 217 String comment ) throws IOException { 218 this.delegate.storeToXML(os, comment); 219 } 220 221 /** 222 * {@inheritDoc} 223 */ 224 @Override 225 public String toString() { 226 return this.delegate.toString(); 227 } 228 229 /** 230 * {@inheritDoc} 231 */ 232 @Override 233 public Collection<Object> values() { 234 return this.delegate.values(); 235 } 236 237 /** 238 * {@inheritDoc} 239 */ 240 @Override 241 public synchronized void clear() { 242 throw new UnsupportedOperationException(); 243 } 244 245 /** 246 * {@inheritDoc} 247 */ 248 @Override 249 public Set<Entry<Object, Object>> entrySet() { 250 return Collections.unmodifiableSet(super.entrySet()); 251 } 252 253 /** 254 * {@inheritDoc} 255 */ 256 @Override 257 public Set<Object> keySet() { 258 return Collections.unmodifiableSet(super.keySet()); 259 } 260 261 /** 262 * {@inheritDoc} 263 */ 264 @Override 265 public synchronized void load( InputStream inStream ) { 266 throw new UnsupportedOperationException(); 267 } 268 269 /** 270 * {@inheritDoc} 271 */ 272 @Override 273 public synchronized void loadFromXML( InputStream in ) { 274 throw new UnsupportedOperationException(); 275 } 276 277 /** 278 * {@inheritDoc} 279 */ 280 @Override 281 public synchronized Object put( Object key, 282 Object value ) { 283 throw new UnsupportedOperationException(); 284 } 285 286 /** 287 * {@inheritDoc} 288 */ 289 @Override 290 public synchronized void putAll( Map<? extends Object, ? extends Object> t ) { 291 throw new UnsupportedOperationException(); 292 } 293 294 /** 295 * {@inheritDoc} 296 */ 297 @Override 298 public synchronized Object remove( Object key ) { 299 throw new UnsupportedOperationException(); 300 } 301 302 /** 303 * {@inheritDoc} 304 */ 305 @Override 306 public synchronized Object setProperty( String key, 307 String value ) { 308 throw new UnsupportedOperationException(); 309 } 310 311 }