class UrlUtilities {

    public static ThreeTuple<String, String, Integer> getProtocolHostPort(String url, int defaultPort)
    {
        int wheresTheColon = url.indexOf(':');
        int hostBeginIndex = wheresTheColon + 3;
        String protocol = url.substring(0, wheresTheColon);
        int hostEndIndex = url.indexOf('/', hostBeginIndex);

        String host = url.substring(hostBeginIndex);

        if (hostEndIndex > 0)
        {
            host = host.substring(0, hostEndIndex - hostBeginIndex);
        }

        int rtmpPort = defaultPort;

        int portIndex = host.indexOf(':');
        if (portIndex > 0)
        {
            String portString = host.substring(portIndex + 1);
            rtmpPort = Integer.parseInt(portString);
            host = host.substring(0, portIndex);
        }

        return new ThreeTuple<>(protocol, host, Integer.valueOf(rtmpPort));
    }

    private  UrlUtilities();

}