URL API

This is a small library for parsing URLs, which provides an actual object model of the elements of URLs and their component objects. Unlike java.net.url, URLs and all of their components can be invalid and provide human-friendly localized messages as to what's wrong with them - no MalformedURLExceptions and nothing that will unexpectedly make a network connection if you use it as a HashMap key. URLs also do minimal self-normalizing when parsed (handling .. in paths, replacing "localhost" with 127.0.0.1 or ::1, lower-casing host labels - very minimal, but sufficient to de-duplicate equivalent URLs, and all standards-compliant. A lot of work went into reading RFCs to get things right here, and it has an exhaustive test-suite. URLs can be parsed or built with builders. java.net.URL was developed for HotJava in the 90s, and was probably great for that use case - and that use case only. This is a library for doing modern Java coding with URLs.

Usage

In the simplest form:
    URL url = URL.parse("http://joe:password@foo.com:8080/foo/bar?baz=quux#hey");
    assert "hey".equals(url.getAnchor());
    assert "joe".equals(url.getUsername();
    assert "password".equals(url.getPassword();
    assert "bar".equals(url.getPath().getLastElement().toString());
    assert Host.parse("foo.com").equals(url.getHost());
    assert 8080 == url.getPort().intValue();
    assert url.isValid();