@Test public void fromJavaNetUrlUnsupportedScheme_checked() throws Exception { try { HttpUrl.getChecked("mailto:user@example.com"); fail(); } catch (MalformedURLException e) { } }
static HttpUrl getChecked(String url) throws MalformedURLException, UnknownHostException { Builder builder = new Builder(); Builder.ParseResult result = builder.parse(null, url); switch (result) { case SUCCESS: return builder.build(); case INVALID_HOST: throw new UnknownHostException("Invalid host: " + url); case UNSUPPORTED_SCHEME: case MISSING_SCHEME: case INVALID_PORT: default: throw new MalformedURLException("Invalid URL: " + result + " for " + url); } }
HttpUrl { static HttpUrl getChecked(String url) throws MalformedURLException, UnknownHostException { Builder builder = new Builder(); Builder.ParseResult result = builder.parse(null, url); switch (result) { case SUCCESS: return builder.build(); case INVALID_HOST: throw new UnknownHostException("Invalid host: " + url); case UNSUPPORTED_SCHEME: case MISSING_SCHEME: case INVALID_PORT: default: throw new MalformedURLException("Invalid URL: " + result + " for " + url); } } }
HttpUrl { static HttpUrl getChecked(String url) throws MalformedURLException, UnknownHostException { Builder builder = new Builder(); Builder.ParseResult result = builder.parse(null, url); switch (result) { case SUCCESS: return builder.build(); case INVALID_HOST: throw new UnknownHostException("Invalid host: " + url); case UNSUPPORTED_SCHEME: case MISSING_SCHEME: case INVALID_PORT: default: throw new MalformedURLException("Invalid URL: " + result + " for " + url); } } private  HttpUrl(Builder builder); }
HttpUrl { static HttpUrl getChecked(String url) throws MalformedURLException, UnknownHostException { Builder builder = new Builder(); Builder.ParseResult result = builder.parse(null, url); switch (result) { case SUCCESS: return builder.build(); case INVALID_HOST: throw new UnknownHostException("Invalid host: " + url); case UNSUPPORTED_SCHEME: case MISSING_SCHEME: case INVALID_PORT: default: throw new MalformedURLException("Invalid URL: " + result + " for " + url); } } private  HttpUrl(Builder builder); URL url(); URI uri(); String scheme(); boolean isHttps(); String encodedUsername(); String username(); String encodedPassword(); String password(); String host(); int port(); static int defaultPort(String scheme); int pathSize(); String encodedPath(); List<String> encodedPathSegments(); List<String> pathSegments(); String encodedQuery(); String query(); int querySize(); String queryParameter(String name); Set<String> queryParameterNames(); List<String> queryParameterValues(String name); String queryParameterName(int index); String queryParameterValue(int index); String encodedFragment(); String fragment(); HttpUrl resolve(String link); Builder newBuilder(); Builder newBuilder(String link); static HttpUrl parse(String url); static HttpUrl get(URL url); static HttpUrl get(URI uri); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
HttpUrl { static HttpUrl getChecked(String url) throws MalformedURLException, UnknownHostException { Builder builder = new Builder(); Builder.ParseResult result = builder.parse(null, url); switch (result) { case SUCCESS: return builder.build(); case INVALID_HOST: throw new UnknownHostException("Invalid host: " + url); case UNSUPPORTED_SCHEME: case MISSING_SCHEME: case INVALID_PORT: default: throw new MalformedURLException("Invalid URL: " + result + " for " + url); } } private  HttpUrl(Builder builder); URL url(); URI uri(); String scheme(); boolean isHttps(); String encodedUsername(); String username(); String encodedPassword(); String password(); String host(); int port(); static int defaultPort(String scheme); int pathSize(); String encodedPath(); List<String> encodedPathSegments(); List<String> pathSegments(); String encodedQuery(); String query(); int querySize(); String queryParameter(String name); Set<String> queryParameterNames(); List<String> queryParameterValues(String name); String queryParameterName(int index); String queryParameterValue(int index); String encodedFragment(); String fragment(); HttpUrl resolve(String link); Builder newBuilder(); Builder newBuilder(String link); static HttpUrl parse(String url); static HttpUrl get(URL url); static HttpUrl get(URI uri); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }