Enum Class URLCodec

java.lang.Object
java.lang.Enum<URLCodec>
com.linkedin.alpini.base.misc.URLCodec
All Implemented Interfaces:
Serializable, Comparable<URLCodec>, Constable

public enum URLCodec extends Enum<URLCodec>
Copies of the implementation of URLEncoder.encode(String, String) and URLDecoder.decode(String, String) except with the following changes:
  • Enum Constant Details

    • SINGLETON

      public static final URLCodec SINGLETON
  • Method Details

    • values

      public static URLCodec[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static URLCodec valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • encode

      @Nonnull public static String encode(@Nonnull String s, @Nonnull Charset charset)
      Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme. This method uses the supplied encoding scheme to obtain the bytes for unsafe characters.

      Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilities.

      Parameters:
      s - String to be translated.
      charset - The name of a supported character encoding.
      Returns:
      the translated String.
      See Also:
    • encode

      @Nonnull public static CharSequence encode(@Nonnull CharSequence s, @Nonnull Charset charset)
      Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme. This method uses the supplied encoding scheme to obtain the bytes for unsafe characters.

      Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilities.

      Parameters:
      s - CharSequence to be translated.
      charset - The name of a supported character encoding.
      Returns:
      the translated CharSequence. Note that if a conversion was required, the returned CharSequence is shared thread local and that the caller is required to copy it.
      See Also:
    • decode

      @Nonnull public static String decode(@Nonnull String s, @Nonnull Charset enc)
      Decodes a application/x-www-form-urlencoded string using a specific encoding scheme. The supplied encoding is used to determine what characters are represented by any consecutive sequences of the form "%xy".

      Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilities.

      Parameters:
      s - the String to decode
      enc - The name of a supported character encoding.
      Returns:
      the newly decoded String
      See Also:
    • decode

      @Nonnull public static CharSequence decode(@Nonnull CharSequence s, @Nonnull Charset enc)
      Decodes a application/x-www-form-urlencoded string using a specific encoding scheme. The supplied encoding is used to determine what characters are represented by any consecutive sequences of the form "%xy".

      Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilities.

      Parameters:
      s - the CharSequence to decode
      enc - The name of a supported character encoding.
      Returns:
      the newly decoded CharSequence. Note that if a conversion was required, the returned CharSequence is shared thread local and that the caller is required to copy it.
      See Also: