public static HostPort parse()

in src/main/java/com/jetbrains/jdi/SocketTransportService.java [227:249]


        public static HostPort parse(String hostPort) {
            int splitIndex = hostPort.lastIndexOf(':');

            int port;
            try {
                port = Integer.decode(hostPort.substring(splitIndex + 1));
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException("unable to parse port number in address");
            }
            if (port < 0 || port > 0xFFFF) {
                throw new IllegalArgumentException("port out of range");
            }

            if (splitIndex <= 0) {  // empty host means local connection
                return new HostPort(InetAddress.getLoopbackAddress().getHostAddress(), port);
            } else if (splitIndex == 1 && hostPort.charAt(0) == '*') {
                return new HostPort(null, port);
            } else if (hostPort.charAt(0) == '[' && hostPort.charAt(splitIndex - 1) == ']') {
                return new HostPort(hostPort.substring(1, splitIndex - 1), port);
            } else {
                return new HostPort(hostPort.substring(0, splitIndex), port);
            }
        }