public static URLBuilder createFromURL(String url)
      throws URISyntaxException {
    """
	Factory method from a url
	
	@param url the url
	@return the builder
	@throws URISyntaxException if the url is invalid
    """
    if(url == null)
    {
      return null;
    }
    else
    {
      url = url.trim();
    }
    
    URI uri = new URI(url);
    if (uri.isOpaque())
      throw new URISyntaxException(url, "opaque uris not supported");

    URLBuilder res = new URLBuilder();
    res.setScheme(uri.getScheme());
    res.setUserInfo(uri.getUserInfo());

    // CA-1599 -- Java's URI fails to parse the hostname if it has underscores in it.
    // this is because _ is not a valid char in hostnames, yet there are systems out there
    // that have it. Java's URL, however, handles it fine.
    if (uri.getHost() == null && res.getHasScheme())
    {
      try
      {
        java.net.URL u = new java.net.URL(url);
        res.setHost(u.getHost());
        res.setPort(u.getPort());
      }
      catch (java.net.MalformedURLException e)
      {
        URISyntaxException uex = new URISyntaxException(url, e.getMessage());
        uex.initCause(e); // keep the original exception
        throw uex;
      }
    }
    else
    {
      res.setHost(uri.getHost());
      res.setPort(uri.getPort());
    }

    res.setPath(uri.getRawPath());
    res.setFragment(uri.getFragment());
    res.addQuery(uri);

    return res;

  }
public static URLBuilder createFromURL(String url)
      throws URISyntaxException
  {
    if(url == null)
    {
      return null;
    }
    else
    {
      url = url.trim();
    }
    
    URI uri = new URI(url);
    if (uri.isOpaque())
      throw new URISyntaxException(url, "opaque uris not supported");

    URLBuilder res = new URLBuilder();
    res.setScheme(uri.getScheme());
    res.setUserInfo(uri.getUserInfo());

    // CA-1599 -- Java's URI fails to parse the hostname if it has underscores in it.
    // this is because _ is not a valid char in hostnames, yet there are systems out there
    // that have it. Java's URL, however, handles it fine.
    if (uri.getHost() == null && res.getHasScheme())
    {
      try
      {
        java.net.URL u = new java.net.URL(url);
        res.setHost(u.getHost());
        res.setPort(u.getPort());
      }
      catch (java.net.MalformedURLException e)
      {
        URISyntaxException uex = new URISyntaxException(url, e.getMessage());
        uex.initCause(e); // keep the original exception
        throw uex;
      }
    }
    else
    {
      res.setHost(uri.getHost());
      res.setPort(uri.getPort());
    }

    res.setPath(uri.getRawPath());
    res.setFragment(uri.getFragment());
    res.addQuery(uri);

    return res;

  }
public static URLBuilder createFromURL ( String url ) throws URISyntaxException { if ( url == null ) { return null ; } else { url = url . trim ( ) ; } URI uri = new URI ( url ) ; if ( uri . isOpaque ( ) ) throw new URISyntaxException ( url , "opaque uris not supported" ) ; URLBuilder res = new URLBuilder ( ) ; res . setScheme ( uri . getScheme ( ) ) ; res . setUserInfo ( uri . getUserInfo ( ) ) ; // CA-1599 -- Java's URI fails to parse the hostname if it has underscores in it. // this is because _ is not a valid char in hostnames, yet there are systems out there // that have it. Java's URL, however, handles it fine. if ( uri . getHost ( ) == null && res . getHasScheme ( ) ) { try { java . net . URL u = new java . net . URL ( url ) ; res . setHost ( u . getHost ( ) ) ; res . setPort ( u . getPort ( ) ) ; } catch ( java . net . MalformedURLException e ) { URISyntaxException uex = new URISyntaxException ( url , e . getMessage ( ) ) ; uex . initCause ( e ) ; // keep the original exception throw uex ; } } else { res . setHost ( uri . getHost ( ) ) ; res . setPort ( uri . getPort ( ) ) ; } res . setPath ( uri . getRawPath ( ) ) ; res . setFragment ( uri . getFragment ( ) ) ; res . addQuery ( uri ) ; return res ; }
Factory method from a url

@param url the url
@return the builder
@throws URISyntaxException if the url is invalid
Factory method from a url