private String encode(String str) {
        if (str == null) {
            return null;
        }
        try {
            return URLEncoder.encode(str, Charsets.UTF_8.name());
        } catch (UnsupportedEncodingException e) {
            // Should never happen
            throw Throwables.propagate(e);
        }
    }
private String encode ( String str ) { if ( str == null ) { return null ; } try { return URLEncoder . encode ( str , Charsets . UTF_8 . name ( ) ) ; } catch ( UnsupportedEncodingException e ) { throw Throwables . propagate ( e ) ; } }
URL encodes the given string.