private void parse() throws MalformedUriException, MalformedDomainException {
        int colon = string.lastIndexOf(':');
        if (string.charAt(0) == '[') {
            int bracket = string.indexOf(']');
            if (bracket < 0)
                throw new MalformedUriException(string, "Unmatched escape bracket in IPv6 endpoint!");
            if (bracket != colon - 1)
                throw new MalformedUriException(string, "Expected colon after IPv6 host-part!");
            if (-1 < string.indexOf('.'))
                throw new MalformedUriException(string, "Detected escape brackets for non IPv6 host!");
            host = Host.get(string.substring(1, bracket));
        } else if (-1 < colon) {
            host = Host.get(string.substring(0, colon));
        } else {
            host = Host.get(string);
        }
        if (-1 < colon) {
            try {
                port = Integer.parseInt(string.substring(colon + 1));
            } catch (NumberFormatException e) {
                throw new MalformedUriException(string, "Invalid port number format!");
            }
            if (port < 1 || 65535 < port)
                throw new MalformedUriException(string, "Port number out of range!");
        }
    }