1 package org.tanukisoftware.wrapper; 2 3 27 28 import java.io.InputStream ; 29 import java.io.IOException ; 30 import java.util.Collection ; 31 import java.util.Collections ; 32 import java.util.Iterator ; 33 import java.util.Map ; 34 import java.util.Properties ; 35 import java.util.Set ; 36 37 43 class WrapperProperties 44 extends Properties 45 { 46 boolean m_locked = false; 47 48 51 public void lock() 52 { 53 m_locked = true; 54 } 55 56 public void load( InputStream inStream ) 57 throws IOException 58 { 59 if ( m_locked ) 60 { 61 throw new IllegalStateException ( "Read Only" ); 62 } 63 super.load( inStream ); 64 } 65 66 public Object setProperty( String key, String value ) 67 { 68 if ( m_locked ) 69 { 70 throw new IllegalStateException ( "Read Only" ); 71 } 72 return super.setProperty( key, value ); 73 } 74 75 public void clear() 76 { 77 if ( m_locked ) 78 { 79 throw new IllegalStateException ( "Read Only" ); 80 } 81 super.clear(); 82 } 83 84 public Set entrySet() 85 { 86 if ( m_locked ) 87 { 88 return Collections.unmodifiableSet( super.entrySet() ); 89 } 90 else 91 { 92 return super.entrySet(); 93 } 94 } 95 96 public Set keySet() 97 { 98 if ( m_locked ) 99 { 100 return Collections.unmodifiableSet( super.keySet() ); 101 } 102 else 103 { 104 return super.keySet(); 105 } 106 } 107 108 public Object put( Object key, Object value ) 109 { 110 if ( m_locked ) 111 { 112 throw new IllegalStateException ( "Read Only" ); 113 } 114 return super.put( key, value ); 115 } 116 117 public void putAll( Map map ) 118 { 119 if ( m_locked ) 120 { 121 throw new IllegalStateException ( "Read Only" ); 122 } 123 super.putAll( map ); 124 } 125 126 public Object remove( Object key ) 127 { 128 if ( m_locked ) 129 { 130 throw new IllegalStateException ( "Read Only" ); 131 } 132 return super.remove( key ); 133 } 134 135 public Collection values() 136 { 137 if ( m_locked ) 138 { 139 return Collections.unmodifiableCollection( super.values() ); 140 } 141 else 142 { 143 return super.values(); 144 } 145 } 146 } 147 148 | Popular Tags |