public URI build ( ) { try { StringBuilder builder = new StringBuilder ( ) ; Set < Entry < String , List < String > > > entrySet = parameters . entrySet ( ) ; for ( Iterator < Entry < String , List < String > > > entryIt = entrySet . iterator ( ) ; entryIt . hasNext ( ) ; ) { Entry < String , List < String > > entry = entryIt . next ( ) ; String name = entry . getKey ( ) ; List < String > values = entry . getValue ( ) ; for ( Iterator < String > valueIt = values . iterator ( ) ; valueIt . hasNext ( ) ; ) { String value = valueIt . next ( ) ; builder . append ( formEncode ( name ) ) . append ( "=" ) ; if ( value != null ) { builder . append ( formEncode ( value ) ) ; } if ( valueIt . hasNext ( ) ) { builder . append ( "&" ) ; } } if ( entryIt . hasNext ( ) ) { builder . append ( "&" ) ; } } String queryDelimiter = "?" ; if ( URI . create ( baseUri ) . getQuery ( ) != null ) { queryDelimiter = "&" ; } return new URI ( baseUri + ( builder . length ( ) > 0 ? queryDelimiter + builder . toString ( ) : "" ) ) ; } catch ( URISyntaxException e ) { throw new URIBuilderException ( "Unable to build URI: Bad URI syntax" , e ) ; } }
Builds the URI