@Test public void testFromStringOnlyWithPathAndQuery2() { Address address = AddressBuilder.create("search?q=foobar"); assertEquals(null, address.getScheme()); assertEquals(null, address.getDomain()); assertEquals(null, address.getPort()); assertEquals("search", address.getPath()); assertEquals("q=foobar", address.getQuery()); assertEquals("search?q=foobar", address.getPathAndQuery()); }
public static Address create(String url) throws IllegalArgumentException { try { URI u = new URI(url); String scheme = u.getScheme(); String host = u.getHost(); if (scheme != null && host == null) return AddressBuilder.begin().scheme(u.getScheme()).schemeSpecificPart(u.getRawSchemeSpecificPart()) .buildLiteral(); else return AddressBuilder.begin().scheme(scheme).domain(host).port(u.getPort()) .path(u.getRawPath()).queryLiteral(u.getRawQuery()).anchor(u.getRawFragment()).buildLiteral(); } catch (URISyntaxException e) { throw new IllegalArgumentException( "[" + url + "] is not a valid URL fragment. Consider encoding relevant portions of the URL with [" + Encoder.class + "], or use the provided builder pattern via this class to specify part encoding.", e); } }
AddressBuilder { public static Address create(String url) throws IllegalArgumentException { try { URI u = new URI(url); String scheme = u.getScheme(); String host = u.getHost(); if (scheme != null && host == null) return AddressBuilder.begin().scheme(u.getScheme()).schemeSpecificPart(u.getRawSchemeSpecificPart()) .buildLiteral(); else return AddressBuilder.begin().scheme(scheme).domain(host).port(u.getPort()) .path(u.getRawPath()).queryLiteral(u.getRawQuery()).anchor(u.getRawFragment()).buildLiteral(); } catch (URISyntaxException e) { throw new IllegalArgumentException( "[" + url + "] is not a valid URL fragment. Consider encoding relevant portions of the URL with [" + Encoder.class + "], or use the provided builder pattern via this class to specify part encoding.", e); } } }
AddressBuilder { public static Address create(String url) throws IllegalArgumentException { try { URI u = new URI(url); String scheme = u.getScheme(); String host = u.getHost(); if (scheme != null && host == null) return AddressBuilder.begin().scheme(u.getScheme()).schemeSpecificPart(u.getRawSchemeSpecificPart()) .buildLiteral(); else return AddressBuilder.begin().scheme(scheme).domain(host).port(u.getPort()) .path(u.getRawPath()).queryLiteral(u.getRawQuery()).anchor(u.getRawFragment()).buildLiteral(); } catch (URISyntaxException e) { throw new IllegalArgumentException( "[" + url + "] is not a valid URL fragment. Consider encoding relevant portions of the URL with [" + Encoder.class + "], or use the provided builder pattern via this class to specify part encoding.", e); } } protected  AddressBuilder(); }
AddressBuilder { public static Address create(String url) throws IllegalArgumentException { try { URI u = new URI(url); String scheme = u.getScheme(); String host = u.getHost(); if (scheme != null && host == null) return AddressBuilder.begin().scheme(u.getScheme()).schemeSpecificPart(u.getRawSchemeSpecificPart()) .buildLiteral(); else return AddressBuilder.begin().scheme(scheme).domain(host).port(u.getPort()) .path(u.getRawPath()).queryLiteral(u.getRawQuery()).anchor(u.getRawFragment()).buildLiteral(); } catch (URISyntaxException e) { throw new IllegalArgumentException( "[" + url + "] is not a valid URL fragment. Consider encoding relevant portions of the URL with [" + Encoder.class + "], or use the provided builder pattern via this class to specify part encoding.", e); } } protected  AddressBuilder(); static AddressBuilderBase begin(); static Address create(String url); @Override String toString(); }
AddressBuilder { public static Address create(String url) throws IllegalArgumentException { try { URI u = new URI(url); String scheme = u.getScheme(); String host = u.getHost(); if (scheme != null && host == null) return AddressBuilder.begin().scheme(u.getScheme()).schemeSpecificPart(u.getRawSchemeSpecificPart()) .buildLiteral(); else return AddressBuilder.begin().scheme(scheme).domain(host).port(u.getPort()) .path(u.getRawPath()).queryLiteral(u.getRawQuery()).anchor(u.getRawFragment()).buildLiteral(); } catch (URISyntaxException e) { throw new IllegalArgumentException( "[" + url + "] is not a valid URL fragment. Consider encoding relevant portions of the URL with [" + Encoder.class + "], or use the provided builder pattern via this class to specify part encoding.", e); } } protected  AddressBuilder(); static AddressBuilderBase begin(); static Address create(String url); @Override String toString();  }