MCPcopy Create free account
hub / github.com/ReadyTalk/avian / parseURL

Method parseURL

classpath/java/net/URLStreamHandler.java:16–53  ·  view source on GitHub ↗
(URL url, String s, int start, int end)

Source from the content-addressed store, hash-verified

14
15public abstract class URLStreamHandler {
16 protected void parseURL(URL url, String s, int start, int end)
17 throws MalformedURLException
18 {
19 String protocol = s.substring(0, start - 1);
20 s = s.substring(start, end);
21
22 String host = null;
23 int port = -1;
24 if (s.startsWith("//")) {
25 s = s.substring(2);
26 int colon = s.indexOf(':');
27 int slash = s.indexOf('/');
28 if (slash < 0) {
29 if (colon < 0) {
30 host = s;
31 } else {
32 host = s.substring(0, colon);
33 port = Integer.parseInt(s.substring(colon + 1));
34 }
35 s = "";
36 } else {
37 if (colon < 0 || colon > slash) {
38 host = s.substring(0, slash);
39 } else {
40 host = s.substring(0, colon);
41 port = Integer.parseInt(s.substring(colon + 1, slash));
42 }
43 s = s.substring(slash);
44 }
45 }
46
47 String file = null;
48 if (s.length() > 0) {
49 file = s;
50 }
51
52 url.set(protocol, host, port, file, null);
53 }
54
55 private static boolean equals(String a, String b) {
56 return (a == null && b == null) || (a != null && a.equals(b));

Callers 1

URLMethod · 0.45

Calls 6

parseIntMethod · 0.95
startsWithMethod · 0.80
indexOfMethod · 0.65
lengthMethod · 0.65
setMethod · 0.65
substringMethod · 0.45

Tested by

no test coverage detected