/** * Attempts to parse this URI's authority component, if defined, into user-information, host, and * port components. The purpose of this method was to disambiguate between some authority * sections, which form invalid server-based authories, but valid registry based authorities. In * the updated RFC 3986, the authority section is defined differently, with registry-based * authorities part of the host section. Thus, this method is now simply an explicit way of * parsing any authority section. * * @return the URI, with the authority section parsed into user information, host and port * components. * @throws URISyntaxException if the given string violates RFC 2396 */ public URI parseServerAuthority() throws URISyntaxException { if (rawAuthority != null) { if (AUTHORITY_PATTERN == null) AUTHORITY_PATTERN = Pattern.compile(AUTHORITY_REGEXP); Matcher matcher = AUTHORITY_PATTERN.matcher(rawAuthority); if (matcher.matches()) { rawUserInfo = getURIGroup(matcher, AUTHORITY_USERINFO_GROUP); rawHost = getURIGroup(matcher, AUTHORITY_HOST_GROUP); String portStr = getURIGroup(matcher, AUTHORITY_PORT_GROUP); if (portStr != null) try { port = Integer.parseInt(portStr); } catch (NumberFormatException e) { URISyntaxException use = new URISyntaxException(string, "doesn't match URI regular expression"); use.initCause(e); throw use; } } else throw new URISyntaxException(string, "doesn't match URI regular expression"); } return this; }