132
|
1 /*******************************************************************************
|
|
2
|
|
3 copyright: Copyright (c) 2004 Kris Bell. All rights reserved
|
|
4
|
|
5 license: BSD style: $(LICENSE)
|
|
6
|
|
7 version: Initial release: April 2004
|
|
8
|
|
9 author: Kris
|
|
10
|
|
11 *******************************************************************************/
|
|
12
|
|
13 module tango.net.model.UriView;
|
|
14
|
|
15 /*******************************************************************************
|
|
16
|
|
17 Implements an RFC 2396 compliant URI specification. See
|
|
18 <A HREF="http://ftp.ics.uci.edu/pub/ietf/uri/rfc2396.txt">this page</A>
|
|
19 for more information.
|
|
20
|
|
21 The implementation fails the spec on two counts: it doesn't insist
|
|
22 on a scheme being present in the UriView, and it doesn't implement the
|
|
23 "Relative References" support noted in section 5.2.
|
|
24
|
|
25 Note that IRI support can be implied by assuming each of userinfo, path,
|
|
26 query, and fragment are UTF-8 encoded
|
|
27 (see <A HREF="http://www.w3.org/2001/Talks/0912-IUC-IRI/paper.html">
|
|
28 this page</A> for further details).
|
|
29
|
|
30 Use a Uri instead where you need to alter specific uri attributes.
|
|
31
|
|
32 *******************************************************************************/
|
|
33
|
|
34 abstract class UriView
|
|
35 {
|
|
36 public enum {InvalidPort = -1}
|
|
37
|
|
38 /***********************************************************************
|
|
39
|
|
40 Return the default port for the given scheme. InvalidPort
|
|
41 is returned if the scheme is unknown, or does not accept
|
|
42 a port.
|
|
43
|
|
44 ***********************************************************************/
|
|
45
|
|
46 abstract int getDefaultPort (char[] scheme);
|
|
47
|
|
48 /***********************************************************************
|
|
49
|
|
50 Return the parsed scheme, or null if the scheme was not
|
|
51 specified
|
|
52
|
|
53 ***********************************************************************/
|
|
54
|
|
55 abstract char[] getScheme();
|
|
56
|
|
57 /***********************************************************************
|
|
58
|
|
59 Return the parsed host, or null if the host was not
|
|
60 specified
|
|
61
|
|
62 ***********************************************************************/
|
|
63
|
|
64 abstract char[] getHost();
|
|
65
|
|
66 /***********************************************************************
|
|
67
|
|
68 Return the parsed port number, or InvalidPort if the port
|
|
69 was not provided.
|
|
70
|
|
71 ***********************************************************************/
|
|
72
|
|
73 abstract int getPort();
|
|
74
|
|
75 /***********************************************************************
|
|
76
|
|
77 Return a valid port number by performing a lookup on the
|
|
78 known schemes if the port was not explicitly specified.
|
|
79
|
|
80 ***********************************************************************/
|
|
81
|
|
82 abstract int getValidPort();
|
|
83
|
|
84 /***********************************************************************
|
|
85
|
|
86 Return the parsed userinfo, or null if userinfo was not
|
|
87 provided.
|
|
88
|
|
89 ***********************************************************************/
|
|
90
|
|
91 abstract char[] getUserInfo();
|
|
92
|
|
93 /***********************************************************************
|
|
94
|
|
95 Return the parsed path, or null if the path was not
|
|
96 provided.
|
|
97
|
|
98 ***********************************************************************/
|
|
99
|
|
100 abstract char[] getPath();
|
|
101
|
|
102 /***********************************************************************
|
|
103
|
|
104 Return the parsed query, or null if a query was not
|
|
105 provided.
|
|
106
|
|
107 ***********************************************************************/
|
|
108
|
|
109 abstract char[] getQuery();
|
|
110
|
|
111 /***********************************************************************
|
|
112
|
|
113 Return the parsed fragment, or null if a fragment was not
|
|
114 provided.
|
|
115
|
|
116 ***********************************************************************/
|
|
117
|
|
118 abstract char[] getFragment();
|
|
119
|
|
120 /***********************************************************************
|
|
121
|
|
122 Return whether or not the UriView scheme is considered generic.
|
|
123
|
|
124 ***********************************************************************/
|
|
125
|
|
126 abstract bool isGeneric ();
|
|
127
|
|
128 /***********************************************************************
|
|
129
|
|
130 Emit the content of this UriView. Output is constructed per
|
|
131 RFC 2396.
|
|
132
|
|
133 ***********************************************************************/
|
|
134
|
|
135 abstract char[] toString ();
|
|
136 }
|
|
137
|