30
31
32 /**
33 * A Uri object represents an absolute Uniform Resource Identifier
34 * (URI) as defined by RFC 2396 and updated by RFC 2373 and RFC 2732.
35 * The most commonly used form of URI is the Uniform Resource Locator (URL).
36 *
37 * <p> The java.net.URL class cannot be used to parse URIs since it
38 * requires the installation of URL stream handlers that may not be
39 * available. The hack of getting around this by temporarily
40 * replacing the scheme part of a URI is not appropriate here: JNDI
41 * service providers must work on older Java platforms, and we want
42 * new features and bug fixes that are not available in old versions
43 * of the URL class.
44 *
45 * <p> It may be appropriate to drop this code in favor of the
46 * java.net.URI class. The changes would need to be written so as to
47 * still run on pre-1.4 platforms not containing that class.
48 *
49 * <p> The format of an absolute URI (see the RFCs mentioned above) is:
50 * <p><blockquote><pre>
51 * absoluteURI = scheme ":" ( hier_part | opaque_part )
52 *
53 * scheme = alpha *( alpha | digit | "+" | "-" | "." )
54 *
55 * hier_part = ( net_path | abs_path ) [ "?" query ]
56 * opaque_part = uric_no_slash *uric
57 *
58 * net_path = "//" authority [ abs_path ]
59 * abs_path = "/" path_segments
60 *
61 * authority = server | reg_name
62 * reg_name = 1*( unreserved | escaped | "$" | "," |
63 * ";" | ":" | "@" | "&" | "=" | "+" )
64 * server = [ [ userinfo "@" ] hostport ]
65 * userinfo = *( unreserved | escaped |
66 * ";" | ":" | "&" | "=" | "+" | "$" | "," )
67 *
68 * hostport = host [ ":" port ]
69 * host = hostname | IPv4address | IPv6reference
70 * port = *digit
77 * hex4 = 1*4hex
78 *
79 * path = [ abs_path | opaque_part ]
80 * path_segments = segment *( "/" segment )
81 * segment = *pchar *( ";" param )
82 * param = *pchar
83 * pchar = unreserved | escaped |
84 * ":" | "@" | "&" | "=" | "+" | "$" | ","
85 *
86 * query = *uric
87 *
88 * uric = reserved | unreserved | escaped
89 * uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
90 * "&" | "=" | "+" | "$" | ","
91 * reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
92 * "$" | "," | "[" | "]"
93 * unreserved = alphanum | mark
94 * mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
95 * escaped = "%" hex hex
96 * unwise = "{" | "}" | "|" | "\" | "^" | "`"
97 * </pre></blockquote>
98 *
99 * <p> Currently URIs containing <tt>userinfo</tt> or <tt>reg_name</tt>
100 * are not supported.
101 * The <tt>opaque_part</tt> of a non-hierarchical URI is treated as if
102 * if were a <tt>path</tt> without a leading slash.
103 */
104
105
106 public class Uri {
107
108 protected String uri;
109 protected String scheme;
110 protected String host = null;
111 protected int port = -1;
112 protected boolean hasAuthority;
113 protected String path;
114 protected String query = null;
115
116
117 /**
118 * Creates a Uri object given a URI string.
119 */
120 public Uri(String uri) throws MalformedURLException {
121 init(uri);
122 }
|
30
31
32 /**
33 * A Uri object represents an absolute Uniform Resource Identifier
34 * (URI) as defined by RFC 2396 and updated by RFC 2373 and RFC 2732.
35 * The most commonly used form of URI is the Uniform Resource Locator (URL).
36 *
37 * <p> The java.net.URL class cannot be used to parse URIs since it
38 * requires the installation of URL stream handlers that may not be
39 * available. The hack of getting around this by temporarily
40 * replacing the scheme part of a URI is not appropriate here: JNDI
41 * service providers must work on older Java platforms, and we want
42 * new features and bug fixes that are not available in old versions
43 * of the URL class.
44 *
45 * <p> It may be appropriate to drop this code in favor of the
46 * java.net.URI class. The changes would need to be written so as to
47 * still run on pre-1.4 platforms not containing that class.
48 *
49 * <p> The format of an absolute URI (see the RFCs mentioned above) is:
50 * <blockquote><pre>{@code
51 * absoluteURI = scheme ":" ( hier_part | opaque_part )
52 *
53 * scheme = alpha *( alpha | digit | "+" | "-" | "." )
54 *
55 * hier_part = ( net_path | abs_path ) [ "?" query ]
56 * opaque_part = uric_no_slash *uric
57 *
58 * net_path = "//" authority [ abs_path ]
59 * abs_path = "/" path_segments
60 *
61 * authority = server | reg_name
62 * reg_name = 1*( unreserved | escaped | "$" | "," |
63 * ";" | ":" | "@" | "&" | "=" | "+" )
64 * server = [ [ userinfo "@" ] hostport ]
65 * userinfo = *( unreserved | escaped |
66 * ";" | ":" | "&" | "=" | "+" | "$" | "," )
67 *
68 * hostport = host [ ":" port ]
69 * host = hostname | IPv4address | IPv6reference
70 * port = *digit
77 * hex4 = 1*4hex
78 *
79 * path = [ abs_path | opaque_part ]
80 * path_segments = segment *( "/" segment )
81 * segment = *pchar *( ";" param )
82 * param = *pchar
83 * pchar = unreserved | escaped |
84 * ":" | "@" | "&" | "=" | "+" | "$" | ","
85 *
86 * query = *uric
87 *
88 * uric = reserved | unreserved | escaped
89 * uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
90 * "&" | "=" | "+" | "$" | ","
91 * reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
92 * "$" | "," | "[" | "]"
93 * unreserved = alphanum | mark
94 * mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
95 * escaped = "%" hex hex
96 * unwise = "{" | "}" | "|" | "\" | "^" | "`"
97 * }</pre></blockquote>
98 *
99 * <p> Currently URIs containing {@code userinfo} or {@code reg_name}
100 * are not supported.
101 * The {@code opaque_part} of a non-hierarchical URI is treated as if
102 * if were a {@code path} without a leading slash.
103 */
104
105
106 public class Uri {
107
108 protected String uri;
109 protected String scheme;
110 protected String host = null;
111 protected int port = -1;
112 protected boolean hasAuthority;
113 protected String path;
114 protected String query = null;
115
116
117 /**
118 * Creates a Uri object given a URI string.
119 */
120 public Uri(String uri) throws MalformedURLException {
121 init(uri);
122 }
|