1 19 package org.openharmonise.commons.net; 20 21 import java.net.*; 22 import java.util.*; 23 import java.util.logging.*; 24 25 33 public class URIWrapper { 34 35 38 private URI m_uri = null; 39 40 43 private ArrayList m_aSegments = new ArrayList(); 44 45 48 private static final Logger m_logger = Logger.getLogger(URIWrapper.class.getName()); 49 50 55 public URIWrapper(String uri) { 56 try { 57 this.m_uri = new URI(uri); 58 } catch (URISyntaxException e) { 59 m_logger.log(Level.WARNING, e.getLocalizedMessage(), e); 60 } 61 this.setup(); 62 } 63 64 71 public URIWrapper(String scheme, String ssp, String fragment) { 72 try { 73 this.m_uri = new URI(scheme, ssp, fragment); 74 } catch (URISyntaxException e) { 75 m_logger.log(Level.WARNING, e.getLocalizedMessage(), e); 76 } 77 this.setup(); 78 } 79 80 91 public URIWrapper( 92 String scheme, 93 String userInfo, 94 String host, 95 int port, 96 String path, 97 String query, 98 String fragment) { 99 try { 100 this.m_uri = 101 new URI(scheme, userInfo, host, port, path, query, fragment); 102 } catch (URISyntaxException e) { 103 m_logger.log(Level.WARNING, e.getLocalizedMessage(), e); 104 } 105 this.setup(); 106 } 107 108 116 public URIWrapper(String scheme, String host, String path, String fragment) { 117 try { 118 this.m_uri = new URI(scheme, host, path, fragment); 119 } catch (URISyntaxException e) { 120 m_logger.log(Level.WARNING, e.getLocalizedMessage(), e); 121 } 122 this.setup(); 123 } 124 125 135 public URIWrapper( 136 String scheme, 137 String authority, 138 String path, 139 String query, 140 String fragment) { 141 try { 142 this.m_uri = new URI(scheme, authority, path, query, fragment); 143 } catch (URISyntaxException e) { 144 m_logger.log(Level.WARNING, e.getLocalizedMessage(), e); 145 } 146 this.setup(); 147 } 148 149 153 private void setup() { 154 StringTokenizer sTok = new StringTokenizer(this.getPath(), "/", false); 155 while(sTok.hasMoreElements()) { 156 this.m_aSegments.add( (String )sTok.nextElement() ); 157 } 158 } 159 160 165 public static URI create(String arg0) { 166 return URI.create(arg0); 167 } 168 169 174 public int compareTo(Object arg0) { 175 return m_uri.compareTo(arg0); 176 } 177 178 181 public boolean equals(Object arg0) { 182 return m_uri.equals(arg0); 183 } 184 185 190 public String getAuthority() { 191 return m_uri.getAuthority(); 192 } 193 194 199 public String getFragment() { 200 return m_uri.getFragment(); 201 } 202 203 208 public String getHost() { 209 return m_uri.getHost(); 210 } 211 212 217 public String getPath() { 218 return m_uri.getPath(); 219 } 220 221 226 public List getPathSegments() { 227 return (List) m_aSegments.clone(); 228 } 229 230 235 public int getPort() { 236 return m_uri.getPort(); 237 } 238 239 244 public String getQuery() { 245 return m_uri.getQuery(); 246 } 247 248 253 public String getRawAuthority() { 254 return m_uri.getRawAuthority(); 255 } 256 257 262 public String getRawFragment() { 263 return m_uri.getRawFragment(); 264 } 265 266 271 public String getRawPath() { 272 return m_uri.getRawPath(); 273 } 274 275 280 public String getRawQuery() { 281 return m_uri.getRawQuery(); 282 } 283 284 289 public String getRawSchemeSpecificPart() { 290 return m_uri.getRawSchemeSpecificPart(); 291 } 292 293 298 public String getRawUserInfo() { 299 return m_uri.getRawUserInfo(); 300 } 301 302 307 public String getScheme() { 308 return m_uri.getScheme(); 309 } 310 311 316 public String getSchemeSpecificPart() { 317 return m_uri.getSchemeSpecificPart(); 318 } 319 320 325 public String getUserInfo() { 326 return m_uri.getUserInfo(); 327 } 328 329 332 public int hashCode() { 333 return m_uri.hashCode(); 334 } 335 336 341 public boolean isAbsolute() { 342 return m_uri.isAbsolute(); 343 } 344 345 350 public boolean isOpaque() { 351 return m_uri.isOpaque(); 352 } 353 354 359 public URI normalize() { 360 return m_uri.normalize(); 361 } 362 363 368 public URI parseServerAuthority() throws URISyntaxException { 369 return m_uri.parseServerAuthority(); 370 } 371 372 377 public URI relativize(URI arg0) { 378 return m_uri.relativize(arg0); 379 } 380 381 386 public URI resolve(String arg0) { 387 return m_uri.resolve(arg0); 388 } 389 390 395 public URI resolve(URI arg0) { 396 return m_uri.resolve(arg0); 397 } 398 399 404 public String toASCIIString() { 405 return m_uri.toASCIIString(); 406 } 407 408 411 public String toString() { 412 return m_uri.toString(); 413 } 414 415 420 public URL toURL() throws MalformedURLException { 421 return m_uri.toURL(); 422 } 423 424 } 425 | Popular Tags |