72
73 while (st.hasMoreTokens()) {
74 urls[i++] = new DnsUrl(st.nextToken());
75 }
76 DnsUrl[] trimmed = new DnsUrl[i];
77 System.arraycopy(urls, 0, trimmed, 0, i);
78 return trimmed;
79 }
80
81 public DnsUrl(String url) throws MalformedURLException {
82 super(url);
83
84 if (!scheme.equals("dns")) {
85 throw new MalformedURLException(
86 url + " is not a valid DNS pseudo-URL");
87 }
88
89 domain = path.startsWith("/")
90 ? path.substring(1)
91 : path;
92 domain = domain.equals("")
93 ? "."
94 : UrlUtil.decode(domain);
95
96 // Debug
97 // System.out.println("host=" + host + " port=" + port +
98 // " domain=" + domain);
99 }
100
101 /**
102 * Returns the domain of this URL, or "." if none is provided.
103 * Never null.
104 */
105 public String getDomain() {
106 return domain;
107 }
108
109
110 /*
111 // Debug
112 public static void main(String args[]) throws MalformedURLException {
|
72
73 while (st.hasMoreTokens()) {
74 urls[i++] = new DnsUrl(st.nextToken());
75 }
76 DnsUrl[] trimmed = new DnsUrl[i];
77 System.arraycopy(urls, 0, trimmed, 0, i);
78 return trimmed;
79 }
80
81 public DnsUrl(String url) throws MalformedURLException {
82 super(url);
83
84 if (!scheme.equals("dns")) {
85 throw new MalformedURLException(
86 url + " is not a valid DNS pseudo-URL");
87 }
88
89 domain = path.startsWith("/")
90 ? path.substring(1)
91 : path;
92 domain = domain.isEmpty()
93 ? "."
94 : UrlUtil.decode(domain);
95
96 // Debug
97 // System.out.println("host=" + host + " port=" + port +
98 // " domain=" + domain);
99 }
100
101 /**
102 * Returns the domain of this URL, or "." if none is provided.
103 * Never null.
104 */
105 public String getDomain() {
106 return domain;
107 }
108
109
110 /*
111 // Debug
112 public static void main(String args[]) throws MalformedURLException {
|