public URI(String scheme,String userInfo,String host,int port,String path,String query,String fragment) throws URISyntaxException {
  if (scheme == null && userInfo == null && host == null && path == null && query == null && fragment == null) {
    this.path="";
    return;
  }
  if (scheme != null && path != null && !path.isEmpty() && path.charAt(0) != '/') {
    throw new URISyntaxException(path,"Relative path");
  }
  StringBuilder uri=new StringBuilder();
  if (scheme != null) {
    uri.append(scheme);
    uri.append(':');
  }
  if (userInfo != null || host != null || port != -1) {
    uri.append("//");
  }
  if (userInfo != null) {
    USER_INFO_ENCODER.appendEncoded(uri,userInfo);
    uri.append('@');
  }
  if (host != null) {
    if (host.indexOf(':') != -1 && host.indexOf(']') == -1 && host.indexOf('[') == -1) {
      host="[" + host + "]";
    }
    uri.append(host);
  }
  if (port != -1) {
    uri.append(':');
    uri.append(port);
  }
  if (path != null) {
    PATH_ENCODER.appendEncoded(uri,path);
  }
  if (query != null) {
    uri.append('?');
    ALL_LEGAL_ENCODER.appendEncoded(uri,query);
  }
  if (fragment != null) {
    uri.append('#');
    ALL_LEGAL_ENCODER.appendEncoded(uri,fragment);
  }
  parseURI(uri.toString(),true);
}

public URI ( String scheme , String userInfo , String host , int port , String path , String query , String fragment ) throws URISyntaxException { if ( scheme == null && userInfo == null && host == null && path == null && query == null && fragment == null ) { this . path = "" ; return ; } if ( scheme != null && path != null && ! path . isEmpty ( ) && path . charAt ( 0 ) != '/' ) { throw new URISyntaxException ( path , "Relative path" ) ; } StringBuilder uri = new StringBuilder ( ) ; if ( scheme != null ) { uri . append ( scheme ) ; uri . append ( ':' ) ; } if ( userInfo != null || host != null || port != - 1 ) { uri . append ( "//" ) ; } if ( userInfo != null ) { USER_INFO_ENCODER . appendEncoded ( uri , userInfo ) ; uri . append ( '@' ) ; } if ( host != null ) { if ( host . indexOf ( ':' ) != - 1 && host . indexOf ( ']' ) == - 1 && host . indexOf ( '[' ) == - 1 ) { host = "[" + host + "]" ; } uri . append ( host ) ; } if ( port != - 1 ) { uri . append ( ':' ) ; uri . append ( port ) ; } if ( path != null ) { PATH_ENCODER . appendEncoded ( uri , path ) ; } if ( query != null ) { uri . append ( '?' ) ; ALL_LEGAL_ENCODER . appendEncoded ( uri , query ) ; } if ( fragment != null ) { uri . append ( '#' ) ; ALL_LEGAL_ENCODER . appendEncoded ( uri , fragment ) ; } parseURI ( uri . toString ( ) , true ) ; }
creates a new uri instance of the given unencoded component parts .
