@Test public void testCreateFromString() throws Exception { Assert.assertEquals(new URIAuthority("somehost", 8080), URIAuthority.create("somehost:8080")); Assert.assertEquals(new URIAuthority("SomeHost", 8080), URIAuthority.create("SomeHost:8080")); Assert.assertEquals(new URIAuthority("somehost", 1234), URIAuthority.create("somehost:1234")); Assert.assertEquals(new URIAuthority("somehost", -1), URIAuthority.create("somehost")); Assert.assertEquals(new URIAuthority("user", "somehost", -1), URIAuthority.create("user@somehost")); try { URIAuthority.create(" host"); Assert.fail("URISyntaxException expected"); } catch (final URISyntaxException expected) { } try { URIAuthority.create("host "); Assert.fail("URISyntaxException expected"); } catch (final URISyntaxException expected) { } try { URIAuthority.create("host :8080"); Assert.fail("URISyntaxException expected"); } catch (final URISyntaxException expected) { } try { URIAuthority.create("user @ host:8080"); Assert.fail("URISyntaxException expected"); } catch (final URISyntaxException expected) { } }
public static URIAuthority create(final String s) throws URISyntaxException { if (TextUtils.isBlank(s)) { return null; } final Tokenizer.Cursor cursor = new Tokenizer.Cursor(0, s.length()); final URIAuthority uriAuthority = parse(s, cursor); if (!cursor.atEnd()) { throw createException(s, cursor, "Unexpected content"); } return uriAuthority; }
URIAuthority implements NamedEndpoint, Serializable { public static URIAuthority create(final String s) throws URISyntaxException { if (TextUtils.isBlank(s)) { return null; } final Tokenizer.Cursor cursor = new Tokenizer.Cursor(0, s.length()); final URIAuthority uriAuthority = parse(s, cursor); if (!cursor.atEnd()) { throw createException(s, cursor, "Unexpected content"); } return uriAuthority; } }
URIAuthority implements NamedEndpoint, Serializable { public static URIAuthority create(final String s) throws URISyntaxException { if (TextUtils.isBlank(s)) { return null; } final Tokenizer.Cursor cursor = new Tokenizer.Cursor(0, s.length()); final URIAuthority uriAuthority = parse(s, cursor); if (!cursor.atEnd()) { throw createException(s, cursor, "Unexpected content"); } return uriAuthority; } private  URIAuthority(final String userInfo, final String hostname, final int port, final boolean internal);  URIAuthority(final String userInfo, final String hostname, final int port);  URIAuthority(final String hostname, final int port);  URIAuthority(final NamedEndpoint namedEndpoint);  URIAuthority(final String hostname); }
URIAuthority implements NamedEndpoint, Serializable { public static URIAuthority create(final String s) throws URISyntaxException { if (TextUtils.isBlank(s)) { return null; } final Tokenizer.Cursor cursor = new Tokenizer.Cursor(0, s.length()); final URIAuthority uriAuthority = parse(s, cursor); if (!cursor.atEnd()) { throw createException(s, cursor, "Unexpected content"); } return uriAuthority; } private  URIAuthority(final String userInfo, final String hostname, final int port, final boolean internal);  URIAuthority(final String userInfo, final String hostname, final int port);  URIAuthority(final String hostname, final int port);  URIAuthority(final NamedEndpoint namedEndpoint);  URIAuthority(final String hostname); static URIAuthority create(final String s); String getUserInfo(); @Override String getHostName(); @Override int getPort(); @Override String toString(); @Override boolean equals(final Object obj); @Override int hashCode(); }
URIAuthority implements NamedEndpoint, Serializable { public static URIAuthority create(final String s) throws URISyntaxException { if (TextUtils.isBlank(s)) { return null; } final Tokenizer.Cursor cursor = new Tokenizer.Cursor(0, s.length()); final URIAuthority uriAuthority = parse(s, cursor); if (!cursor.atEnd()) { throw createException(s, cursor, "Unexpected content"); } return uriAuthority; } private  URIAuthority(final String userInfo, final String hostname, final int port, final boolean internal);  URIAuthority(final String userInfo, final String hostname, final int port);  URIAuthority(final String hostname, final int port);  URIAuthority(final NamedEndpoint namedEndpoint);  URIAuthority(final String hostname); static URIAuthority create(final String s); String getUserInfo(); @Override String getHostName(); @Override int getPort(); @Override String toString(); @Override boolean equals(final Object obj); @Override int hashCode();  }