public static String encode(final List<NameValue> input, final Charset charset) {
        if (input == null) {
            throw new NullPointerException("input");
        }
        if (charset == null) {
            throw new NullPointerException("charset");
        }

        // 2. Let output be the empty string.
        final StringBuilder sb = new StringBuilder();

        // 3. For each pair in pairs, run these substeps:
        for (int i = 0; i < input.size(); i++) {
            final NameValue pair = input.get(i);

            // 1. Let outputPair be a copy of pair.
            // N/A

            // 2. Replace outputPair's name and value with the result of running encode on them using
            //    encoding override, respectively.
            // 3. Replace outputPair's name and value with their serialization.
            final String outputName = serialize(charset.encode(pair.name()));
            final String outputValue = serialize(charset.encode(pair.value()));

            // 4. If pair is not the first pair in pairs, append "&" to output.
            if (i != 0) {
                sb.append('&');
            }

            // 5. Append outputPair's name, followed by "=", followed by outputPair's value to output.
            sb.append(outputName).append('=').append(outputValue);
        }

        // 4. Return output.
        return sb.toString();
    }
public static String encode(final List<NameValue> input, final Charset charset) {
        if (input == null) {
            throw new NullPointerException("input");
        }
        if (charset == null) {
            throw new NullPointerException("charset");
        }

        
        final StringBuilder sb = new StringBuilder();

        
        for (int i = 0; i < input.size(); i++) {
            final NameValue pair = input.get(i);

            
            

            
            
            
            final String outputName = serialize(charset.encode(pair.name()));
            final String outputValue = serialize(charset.encode(pair.value()));

            
            if (i != 0) {
                sb.append('&');
            }

            
            sb.append(outputName).append('=').append(outputValue);
        }

        
        return sb.toString();
    }
public static String encode ( final List < NameValue > input , final Charset charset ) { if ( input == null ) { throw new NullPointerException ( "input" ) ; } if ( charset == null ) { throw new NullPointerException ( "charset" ) ; } // 2. Let output be the empty string. final StringBuilder sb = new StringBuilder ( ) ; // 3. For each pair in pairs, run these substeps: for ( int i = 0 ; i < input . size ( ) ; i ++ ) { final NameValue pair = input . get ( i ) ; // 1. Let outputPair be a copy of pair. // N/A // 2. Replace outputPair's name and value with the result of running encode on them using //    encoding override, respectively. // 3. Replace outputPair's name and value with their serialization. final String outputName = serialize ( charset . encode ( pair . name ( ) ) ) ; final String outputValue = serialize ( charset . encode ( pair . value ( ) ) ) ; // 4. If pair is not the first pair in pairs, append "&" to output. if ( i != 0 ) { sb . append ( ' ' ) ; } // 5. Append outputPair's name, followed by "=", followed by outputPair's value to output. sb . append ( outputName ) . append ( ' ' ) . append ( outputValue ) ; } // 4. Return output. return sb . toString ( ) ; }
Implements the application/x-www-form-urlencoded serializer.

@param input
@param charset
@return
Implements the application / x - www - form - urlencoded serializer .