| 1 7 8 package java.net; 9 10 import java.io.IOException ; 11 import java.io.InvalidObjectException ; 12 import java.io.ObjectInputStream ; 13 import java.io.ObjectOutputStream ; 14 import java.io.Serializable ; 15 import java.nio.ByteBuffer ; 16 import java.nio.CharBuffer ; 17 import java.nio.charset.CharsetDecoder ; 18 import java.nio.charset.CharsetEncoder ; 19 import java.nio.charset.CoderResult ; 20 import java.nio.charset.CodingErrorAction ; 21 import java.nio.charset.CharacterCodingException ; 22 import sun.nio.cs.ThreadLocalCoders; 23 import sun.text.Normalizer; 24 25 import java.lang.Character ; import java.lang.NullPointerException ; 28 29 453 454 public final class URI 455 implements Comparable <URI >, Serializable  456 { 457 458 462 static final long serialVersionUID = -6052424284110960213L; 463 464 465 467 private transient String scheme; private transient String fragment; 470 471 private transient String authority; 474 private transient String userInfo; 476 private transient String host; private transient int port = -1; 479 private transient String path; private transient String query; 482 483 485 private volatile transient String schemeSpecificPart; 486 private volatile transient int hash; 488 private volatile transient String decodedUserInfo = null; 489 private volatile transient String decodedAuthority = null; 490 private volatile transient String decodedPath = null; 491 private volatile transient String decodedQuery = null; 492 private volatile transient String decodedFragment = null; 493 private volatile transient String decodedSchemeSpecificPart = null; 494 495 500 private volatile String string; 502 503 504 506 private URI() { } 508 577 public URI(String str) throws URISyntaxException { 578 new Parser(str).parse(false); 579 } 580 581 654 public URI(String scheme, 655 String userInfo, String host, int port, 656 String path, String query, String fragment) 657 throws URISyntaxException  658 { 659 String s = toString(scheme, null, 660 null, userInfo, host, port, 661 path, query, fragment); 662 checkPath(s, scheme, path); 663 new Parser(s).parse(true); 664 } 665 666 727 public URI(String scheme, 728 String authority, 729 String path, String query, String fragment) 730 throws URISyntaxException  731 { 732 String s = toString(scheme, null, 733 authority, null, null, -1, 734 path, query, fragment); 735 checkPath(s, scheme, path); 736 new Parser(s).parse(false); 737 } 738 739 761 public URI(String scheme, String host, String path, String fragment) 762 throws URISyntaxException  763 { 764 this(scheme, null, host, -1, path, null, fragment); 765 } 766 767 804 public URI(String scheme, String ssp, String fragment) 805 throws URISyntaxException  806 { 807 new Parser(toString(scheme, ssp, 808 null, null, null, -1, 809 null, null, fragment)) 810 .parse(false); 811 } 812 813 838 public static URI create(String str) { 839 try { 840 return new URI (str); 841 } catch (URISyntaxException x) { 842 IllegalArgumentException y = new IllegalArgumentException (); 843 y.initCause(x); 844 throw y; 845 } 846 } 847 848 849 851 898 public URI parseServerAuthority() 899 throws URISyntaxException  900 { 901 if ((host != null) || (authority == null)) 905 return this; 906 defineString(); 907 new Parser(string).parse(true); 908 return this; 909 } 910 911 948 public URI normalize() { 949 return normalize(this); 950 } 951 952 |