etf.org/rfc/rfc2396.txt">RFC 2396 cannot always distinguish a malformed server-based authority from a legitimate registry-based authority. It must therefore treat some instances of the former as instances of the latter. The authority component in the URI string
"//foo:bar", for example, is not a legal server-based authority but it is legal as a registry-based authority.
In many common situations, for example when working URIs that are known to be either URNs or URLs, the hierarchical URIs being used will always be server-based. They therefore must either be parsed as such or treated as an error. In these cases a statement such as
URI u = new URI(str).parseServerAuthority();
can be used to ensure that u always refers to a URI that, if it has an authority component, has a server-based authority with proper user-information, host, and port components. Invoking this method also ensures that if the authority could not be parsed in that way then an appropriate diagnostic message can be issued based upon the exception that is thrown.
@return A URI whose authority field has been parsedas a server-based authority
@throws URISyntaxException If the authority component of this URI is defined but cannot be parsed as a server-based authority according to RFC 2396