Class AcceptEncodingList

java.lang.Object
com.helger.http.header.AbstractQValueList<String>
com.helger.http.header.specific.AcceptEncodingList

@NotThreadSafe public class AcceptEncodingList extends AbstractQValueList<String>
Contains a list of Accept-Encoding values as specified by the HTTP header
Author:
Philip Helger
  • Constructor Details

    • AcceptEncodingList

      public AcceptEncodingList()
      Constructor creating an empty accept encoding list.
  • Method Details

    • addEncoding

      public @NonNull AcceptEncodingList addEncoding(@NonNull String sEncoding, @Nonnegative double dQuality)
      Add an encoding with the given quality.
      Parameters:
      sEncoding - The encoding name to add. May neither be null nor empty.
      dQuality - The quality value between 0 and 1.
      Returns:
      this for chaining
    • getQValueOfEncoding

      public @NonNull QValue getQValueOfEncoding(@NonNull String sEncoding)
      Return the associated quality of the given encoding.
      Parameters:
      sEncoding - The encoding name to query. May not be null.
      Returns:
      The matching QValue and never null.
    • getQualityOfEncoding

      public double getQualityOfEncoding(@NonNull String sEncoding)
      Return the associated quality of the given encoding.
      Parameters:
      sEncoding - The encoding name to query. May not be null.
      Returns:
      0 means not accepted, 1 means fully accepted.
    • supportsEncoding

      public boolean supportsEncoding(@NonNull String sEncoding)
      Check if the passed encoding is supported. Supported means the quality is > 0.
      Parameters:
      sEncoding - The encoding to be checked. May not be null.
      Returns:
      true if the encoding is supported, false if not.
    • explicitlySupportsEncoding

      public boolean explicitlySupportsEncoding(@NonNull String sEncoding)
      Check if the passed encoding is explicitly supported (without wildcard fallback). Supported means the quality is > 0.
      Parameters:
      sEncoding - The encoding to be checked. May not be null.
      Returns:
      true if the encoding is explicitly supported, false if not.
    • supportsGZIP

      public boolean supportsGZIP()
      Returns:
      true if GZIP encoding (gzip or x-gzip) is supported, false otherwise.
    • getUsedGZIPEncoding

      public @Nullable String getUsedGZIPEncoding()
      Returns:
      the accepted GZip encoding. May either be AcceptEncodingHandler.GZIP_ENCODING or AcceptEncodingHandler.X_GZIP_ENCODING or null
    • supportsDeflate

      public boolean supportsDeflate()
      Returns:
      true if deflate encoding is supported, false otherwise.
    • getUsedDeflateEncoding

      public @Nullable String getUsedDeflateEncoding()
      Returns:
      the accepted GZip encoding. May either be AcceptEncodingHandler.DEFLATE_ENCODING or null
    • supportsCompress

      public boolean supportsCompress()
      Returns:
      true if compress encoding (compress or x-compress) is supported, false otherwise.
    • getUsedCompressEncoding

      public @Nullable String getUsedCompressEncoding()
      Returns:
      the accepted GZip encoding. May either be AcceptEncodingHandler.COMPRESS_ENCODING or AcceptEncodingHandler.X_COMPRESS_ENCODING or null
    • getAsHttpHeaderValue

      public @NonNull String getAsHttpHeaderValue()
      Specified by:
      getAsHttpHeaderValue in class AbstractQValueList<String>
      Returns:
      The string representation of this list e.g. for usage in HTTP headers.