private void setPort ( int p_port ) throws MalformedURIException { if ( p_port >= 0 && p_port <= 65535 ) { if ( m_host == null ) { throw new MalformedURIException ( "Port cannot be set when host is null!" ) ; } } else if ( p_port != - 1 ) { throw new MalformedURIException ( "Invalid port number!" ) ; } n_port = p_port ; }
Set the port for this URI . - 1 is used to indicate that the port is not specified otherwise valid port numbers are between 0 and 65535 . If a valid port number is passed in and the host field is null an exception is thrown .