org.apache.hc.core5.net

## Class URLEncodedUtils

- java.lang.Object
- - org.apache.hc.core5.net.URLEncodedUtils

-     public class URLEncodedUtils
      extends Object

  A collection of utilities for encoding URLs.
  Since:
    4.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `URLEncodedUtils()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `format(Iterable<? extends NameValuePair> parameters, char parameterSeparator, Charset charset)` Returns a String that is suitable for use as an `application/x-www-form-urlencoded` list of parameters in an HTTP PUT or HTTP POST.
    `static String` | `format(Iterable<? extends NameValuePair> parameters, Charset charset)` Returns a String that is suitable for use as an `application/x-www-form-urlencoded` list of parameters in an HTTP PUT or HTTP POST.
    `static String` | `formatSegments(Iterable<String> segments, Charset charset)` Returns a string consisting of joint encoded path segments.
    `static String` | `formatSegments(String... segments)` Returns a string consisting of joint encoded path segments.
    `static List<NameValuePair>` | `parse(CharSequence s, Charset charset)` Returns a list of `NameValuePair`s URI query parameters.
    `static List<NameValuePair>` | `parse(CharSequence s, Charset charset, char... separators)` Returns a list of `NameValuePair`s parameters.
    `static List<NameValuePair>` | `parse(URI uri, Charset charset)` Returns a list of `NameValuePair`s URI query parameters.
    `static List<String>` | `parsePathSegments(CharSequence s)` Returns a list of URI path segments.
    `static List<String>` | `parsePathSegments(CharSequence s, Charset charset)` Returns a list of URI path segments.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### URLEncodedUtils

          public URLEncodedUtils()

  - ### Method Detail

    - #### parse

          public static List<NameValuePair> parse(URI uri,
                                  Charset charset)

      Returns a list of `NameValuePair`s URI query parameters. By convention, `'&'` and `';'` are accepted as parameter separators.
      Parameters:
        `uri` - input URI.
        `charset` - parameter charset.
      Returns:
        list of query parameters.
      Since:
        4.5

    - #### parse

          public static List<NameValuePair> parse(CharSequence s,
                                  Charset charset)

      Returns a list of `NameValuePair`s URI query parameters. By convention, `'&'` and `';'` are accepted as parameter separators.
      Parameters:
        `s` - URI query component.
        `charset` - charset to use when decoding the parameters.
      Returns:
        list of query parameters.
      Since:
        4.2

    - #### parse

          public static List<NameValuePair> parse(CharSequence s,
                                  Charset charset,
                                  char... separators)

      Returns a list of `NameValuePair`s parameters.
      Parameters:
        `s` - input text.
        `charset` - parameter charset.
        `separators` - parameter separators.
      Returns:
        list of query parameters.
      Since:
        4.4

    - #### parsePathSegments

          public static List<String> parsePathSegments(CharSequence s,
                                       Charset charset)

      Returns a list of URI path segments.
      Parameters:
        `s` - URI path component.
        `charset` - parameter charset.
      Returns:
        list of segments.
      Since:
        4.5

    - #### parsePathSegments

          public static List<String> parsePathSegments(CharSequence s)

      Returns a list of URI path segments.
      Parameters:
        `s` - URI path component.
      Returns:
        list of segments.
      Since:
        4.5

    - #### formatSegments

          public static String formatSegments(Iterable<String> segments,
                              Charset charset)

      Returns a string consisting of joint encoded path segments.
      Parameters:
        `segments` - the segments.
        `charset` - parameter charset.
      Returns:
        URI path component
      Since:
        4.5

    - #### formatSegments

          public static String formatSegments(String... segments)

      Returns a string consisting of joint encoded path segments.
      Parameters:
        `segments` - the segments.
      Returns:
        URI path component
      Since:
        4.5

    - #### format

          public static String format(Iterable<? extends NameValuePair> parameters,
                      char parameterSeparator,
                      Charset charset)

      Returns a String that is suitable for use as an `application/x-www-form-urlencoded` list of parameters in an HTTP PUT or HTTP POST.
      Parameters:
        `parameters` - The parameters to include.
        `parameterSeparator` - The parameter separator, by convention, `'&'` or `';'`.
        `charset` - The encoding to use.
      Returns:
        An `application/x-www-form-urlencoded` string
      Since:
        4.3

    - #### format

          public static String format(Iterable<? extends NameValuePair> parameters,
                      Charset charset)

      Returns a String that is suitable for use as an `application/x-www-form-urlencoded` list of parameters in an HTTP PUT or HTTP POST.
      Parameters:
        `parameters` - The parameters to include.
        `charset` - The encoding to use.
      Returns:
        An `application/x-www-form-urlencoded` string
      Since:
        4.2

Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.