1 18 package org.apache.beehive.netui.core.urls; 19 20 import java.net.URI ; 21 import java.net.URISyntaxException ; 22 import java.net.URL ; 23 import java.util.Map ; 24 25 30 public class FreezableMutableURI extends MutableURI 31 { 32 33 private boolean _frozen = false; 34 35 38 public FreezableMutableURI() 39 { 40 } 41 42 49 public FreezableMutableURI( String uriString, boolean encoded ) throws URISyntaxException 50 { 51 super( uriString, encoded ); 52 } 53 54 65 public FreezableMutableURI( String scheme, String userInfo, String host, int port, 66 String path, String query, String fragment ) 67 { 68 super( scheme, userInfo, host, port, path, query, fragment ); 69 } 70 71 76 public FreezableMutableURI( URI uri ) 77 { 78 super( uri ); 79 } 80 81 97 public FreezableMutableURI( URL url ) throws URISyntaxException 98 { 99 super( url ); 100 } 101 102 public final boolean isFrozen() 103 { 104 return _frozen; 105 } 106 107 112 public void setFrozen( boolean frozen ) 113 { 114 this._frozen = frozen; 115 } 116 117 private void testFrozen() 118 { 119 if ( _frozen ) 120 { 121 throw new IllegalStateException ( "Cannot modify the URI data. This instance was set to be immutable." ); 122 } 123 } 124 125 134 135 public void setURI( String uriString, boolean encoded ) throws URISyntaxException 136 { 137 testFrozen(); 138 super.setURI( uriString, encoded ); 139 } 140 141 146 147 public void setEncoding( String encoding ) 148 { 149 testFrozen(); 150 super.setEncoding( encoding ); 151 } 152 153 158 159 public void setScheme( String scheme ) 160 { 161 testFrozen(); 162 super.setScheme( scheme ); 163 } 164 165 170 171 public void setUserInfo( String userInfo ) 172 { 173 testFrozen(); 174 super.setUserInfo( userInfo ); 175 } 176 177 182 183 public void setHost( String host ) 184 { 185 testFrozen(); 186 super.setHost( host ); 187 } 188 189 194 195 public void setPort( int port ) 196 { 197 testFrozen(); 198 super.setPort( port ); 199 } 200 201 206 207 public void setPath( String path ) 208 { 209 testFrozen(); 210 super.setPath( path ); 211 } 212 213 220 221 public void setQuery( String query ) 222 { 223 testFrozen(); 224 super.setQuery( query ); 225 } 226 227 243 244 public void addParameter( String name, String value, boolean encoded ) 245 { 246 testFrozen(); 247 super.addParameter( name, value, encoded ); 248 } 249 250 263 264 public void addParameters( Map newParams, boolean encoded ) 265 { 266 testFrozen(); 267 super.addParameters( newParams, encoded ); 268 } 269 270 275 276 public void removeParameter( String name ) 277 { 278 testFrozen(); 279 super.removeParameter( name ); 280 } 281 282 287 288 public void setFragment( String fragment ) 289 { 290 testFrozen(); 291 super.setFragment( fragment ); 292 } 293 294 public boolean equals( Object o ) 295 { 296 if ( this == o ) 297 { 298 return true; 299 } 300 if ( !( o instanceof FreezableMutableURI ) ) 301 { 302 return false; 303 } 304 if ( !super.equals( o ) ) 305 { 306 return false; 307 } 308 309 final FreezableMutableURI freezableMutableURI = ( FreezableMutableURI ) o; 310 311 if ( _frozen != freezableMutableURI._frozen ) 312 { 313 return false; 314 } 315 316 return true; 317 } 318 319 public int hashCode() 320 { 321 int result = super.hashCode(); 322 result = 29 * result + ( _frozen ? 1 : 0 ); 323 return result; 324 } 325 } 326 327 | Popular Tags |