Enum ContentCoding

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<ContentCoding>

    public enum ContentCoding
    extends java.lang.Enum<ContentCoding>
    Enumeration of the canonical IANA content-coding tokens supported by HttpClient for HTTP request and response bodies.

    Each constant corresponds to the standard token used in the Content-Encoding and Accept-Encoding headers. Some codings (e.g. Brotli, Zstandard, XZ/LZMA) may require additional helper libraries at runtime.

    Since:
    5.6
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      BROTLI
      Brotli compression format.
      BZIP2
      BZIP2 compression format.
      DEFLATE
      "deflate" compression format (zlib or raw).
      DEFLATE64
      Deflate64 compression format.
      GZIP
      GZIP compression format.
      LZ4_BLOCK
      Block LZ4 compression format.
      LZ4_FRAMED
      Framed LZ4 compression format.
      LZMA
      LZMA compression format.
      PACK200
      Pack200 compression format.
      X_GZIP
      Legacy alias for GZIP.
      XZ
      XZ compression format.
      ZSTD
      Zstandard compression format.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String token  
      private static java.util.Map<java.lang.String,​ContentCoding> TOKEN_LOOKUP  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ContentCoding​(java.lang.String token)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static ContentCoding fromToken​(java.lang.String token)
      Lookup an enum by its token (case‐insensitive), or null if none matches.
      java.lang.String token()
      Returns the standard IANA token string for this content-coding.
      static ContentCoding valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static ContentCoding[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • GZIP

        public static final ContentCoding GZIP
        GZIP compression format.
      • DEFLATE

        public static final ContentCoding DEFLATE
        "deflate" compression format (zlib or raw).
      • X_GZIP

        public static final ContentCoding X_GZIP
        Legacy alias for GZIP.
      • BROTLI

        public static final ContentCoding BROTLI
        Brotli compression format.
      • ZSTD

        public static final ContentCoding ZSTD
        Zstandard compression format.
      • XZ

        public static final ContentCoding XZ
        XZ compression format.
      • LZMA

        public static final ContentCoding LZMA
        LZMA compression format.
      • LZ4_FRAMED

        public static final ContentCoding LZ4_FRAMED
        Framed LZ4 compression format.
      • LZ4_BLOCK

        public static final ContentCoding LZ4_BLOCK
        Block LZ4 compression format.
      • BZIP2

        public static final ContentCoding BZIP2
        BZIP2 compression format.
      • PACK200

        public static final ContentCoding PACK200
        Pack200 compression format.
      • DEFLATE64

        public static final ContentCoding DEFLATE64
        Deflate64 compression format.
    • Field Detail

      • TOKEN_LOOKUP

        private static final java.util.Map<java.lang.String,​ContentCoding> TOKEN_LOOKUP
      • token

        private final java.lang.String token
    • Constructor Detail

      • ContentCoding

        private ContentCoding​(java.lang.String token)
    • Method Detail

      • values

        public static ContentCoding[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ContentCoding c : ContentCoding.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ContentCoding valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • token

        public java.lang.String token()
        Returns the standard IANA token string for this content-coding.
        Returns:
        the lowercase token used in HTTP headers
      • fromToken

        public static ContentCoding fromToken​(java.lang.String token)
        Lookup an enum by its token (case‐insensitive), or null if none matches.

        This method is backed by a static, pre‐populated map so the lookup is O(1) instead of O(n).

        Parameters:
        token - the content‐coding token to look up
        Returns:
        the matching enum constant, or null if none