public URL buildAnnounceURL ( URL trackerAnnounceURL ) throws UnsupportedEncodingException , MalformedURLException { String base = trackerAnnounceURL . toString ( ) ; StringBuilder url = new StringBuilder ( base ) ; url . append ( base . contains ( "?" ) ? "&" : "?" ) . append ( "info_hash=" ) . append ( URLEncoder . encode ( new String ( this . getInfoHash ( ) , Constants . BYTE_ENCODING ) , Constants . BYTE_ENCODING ) ) . append ( "&peer_id=" ) . append ( URLEncoder . encode ( new String ( this . getPeerId ( ) , Constants . BYTE_ENCODING ) , Constants . BYTE_ENCODING ) ) . append ( "&port=" ) . append ( this . getPort ( ) ) . append ( "&uploaded=" ) . append ( this . getUploaded ( ) ) . append ( "&downloaded=" ) . append ( this . getDownloaded ( ) ) . append ( "&left=" ) . append ( this . getLeft ( ) ) . append ( "&compact=" ) . append ( this . isCompact ( ) ? 1 : 0 ) . append ( "&no_peer_id=" ) . append ( this . canOmitPeerId ( ) ? 1 : 0 ) ; if ( this . getEvent ( ) != null && ! RequestEvent . NONE . equals ( this . getEvent ( ) ) ) { url . append ( "&event=" ) . append ( this . getEvent ( ) . getEventName ( ) ) ; } if ( this . getIp ( ) != null ) { url . append ( "&ip=" ) . append ( this . getIp ( ) ) ; } return new URL ( url . toString ( ) ) ; }
Build the announce request URL for the given tracker announce URL .