Class AcceptCharsetList

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

public class AcceptCharsetList extends AbstractQValueList<String>
Represents a list of Accept-Charset values as specified in the HTTP header
Author:
Philip Helger
  • Constructor Details

    • AcceptCharsetList

      public AcceptCharsetList()
      Constructor creating an empty accept charset list.
  • Method Details

    • addCharset

      public @NonNull AcceptCharsetList addCharset(@NonNull Charset aCharset, @Nonnegative double dQuality)
      Add a charset with the given quality.
      Parameters:
      aCharset - The charset to add. May not be null.
      dQuality - The quality value between 0 and 1.
      Returns:
      this for chaining
    • addCharset

      public @NonNull AcceptCharsetList addCharset(@Nonempty @NonNull @Nonempty String sCharset, @Nonnegative double dQuality)
      Add a charset by name with the given quality.
      Parameters:
      sCharset - The charset name to add. May neither be null nor empty.
      dQuality - The quality value between 0 and 1.
      Returns:
      this for chaining
    • getQValueOfCharset

      public @NonNull QValue getQValueOfCharset(@NonNull String sCharset)
      Return the associated quality of the given charset.
      Parameters:
      sCharset - The charset name to query. May not be null.
      Returns:
      The associated QValue.
    • getQualityOfCharset

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

      public boolean supportsCharset(@NonNull String sCharset)
      Check if the passed charset is supported. Supported means the quality is > 0.
      Parameters:
      sCharset - The charset name to be checked. May not be null.
      Returns:
      true if the charset is supported, false if not.
    • explicitlySupportsCharset

      public boolean explicitlySupportsCharset(@NonNull String sCharset)
      Check if the passed charset is explicitly supported (without wildcard fallback). Supported means the quality is > 0.
      Parameters:
      sCharset - The charset name to be checked. May not be null.
      Returns:
      true if the charset is explicitly supported, false if not.
    • 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.