@Test public void testParseScheme() { final HostParser.Value<String> value = new HostParser.Value<>(); final String test = "https:"; final HostParser.StringReader reader = new HostParser.StringReader(test); assertTrue(HostParser.parseScheme(reader, value)); assertEquals("https", value.getValue()); }
static boolean parseScheme(final StringReader reader, final Value<String> scheme) { final StringBuilder stringBuilder = new StringBuilder(); int tracker = reader.position; while(!reader.endOfString()) { final char c = (char) reader.read(); if(Character.isAlphabetic(c) || Character.isDigit(c) || URI_SCHEME.indexOf(c) != -1) { if(c == '.') { reader.skip(tracker - reader.position); return false; } stringBuilder.append(c); } else if(c == ':') { tracker = reader.position; break; } else { if(c == ' ' && stringBuilder.length() == 0) { continue; } reader.skip(tracker - reader.position); return false; } } reader.skip(tracker - reader.position); scheme.setValue(stringBuilder.toString()); return true; }
HostParser { static boolean parseScheme(final StringReader reader, final Value<String> scheme) { final StringBuilder stringBuilder = new StringBuilder(); int tracker = reader.position; while(!reader.endOfString()) { final char c = (char) reader.read(); if(Character.isAlphabetic(c) || Character.isDigit(c) || URI_SCHEME.indexOf(c) != -1) { if(c == '.') { reader.skip(tracker - reader.position); return false; } stringBuilder.append(c); } else if(c == ':') { tracker = reader.position; break; } else { if(c == ' ' && stringBuilder.length() == 0) { continue; } reader.skip(tracker - reader.position); return false; } } reader.skip(tracker - reader.position); scheme.setValue(stringBuilder.toString()); return true; } }
HostParser { static boolean parseScheme(final StringReader reader, final Value<String> scheme) { final StringBuilder stringBuilder = new StringBuilder(); int tracker = reader.position; while(!reader.endOfString()) { final char c = (char) reader.read(); if(Character.isAlphabetic(c) || Character.isDigit(c) || URI_SCHEME.indexOf(c) != -1) { if(c == '.') { reader.skip(tracker - reader.position); return false; } stringBuilder.append(c); } else if(c == ':') { tracker = reader.position; break; } else { if(c == ' ' && stringBuilder.length() == 0) { continue; } reader.skip(tracker - reader.position); return false; } } reader.skip(tracker - reader.position); scheme.setValue(stringBuilder.toString()); return true; } HostParser();  HostParser(final ProtocolFactory factory);  HostParser(final ProtocolFactory factory, final Protocol defaultScheme); }
HostParser { static boolean parseScheme(final StringReader reader, final Value<String> scheme) { final StringBuilder stringBuilder = new StringBuilder(); int tracker = reader.position; while(!reader.endOfString()) { final char c = (char) reader.read(); if(Character.isAlphabetic(c) || Character.isDigit(c) || URI_SCHEME.indexOf(c) != -1) { if(c == '.') { reader.skip(tracker - reader.position); return false; } stringBuilder.append(c); } else if(c == ':') { tracker = reader.position; break; } else { if(c == ' ' && stringBuilder.length() == 0) { continue; } reader.skip(tracker - reader.position); return false; } } reader.skip(tracker - reader.position); scheme.setValue(stringBuilder.toString()); return true; } HostParser();  HostParser(final ProtocolFactory factory);  HostParser(final ProtocolFactory factory, final Protocol defaultScheme); Host get(final String url); static Host parse(final String url); }
HostParser { static boolean parseScheme(final StringReader reader, final Value<String> scheme) { final StringBuilder stringBuilder = new StringBuilder(); int tracker = reader.position; while(!reader.endOfString()) { final char c = (char) reader.read(); if(Character.isAlphabetic(c) || Character.isDigit(c) || URI_SCHEME.indexOf(c) != -1) { if(c == '.') { reader.skip(tracker - reader.position); return false; } stringBuilder.append(c); } else if(c == ':') { tracker = reader.position; break; } else { if(c == ' ' && stringBuilder.length() == 0) { continue; } reader.skip(tracker - reader.position); return false; } } reader.skip(tracker - reader.position); scheme.setValue(stringBuilder.toString()); return true; } HostParser();  HostParser(final ProtocolFactory factory);  HostParser(final ProtocolFactory factory, final Protocol defaultScheme); Host get(final String url); static Host parse(final String url);  }