Class AcceptMimeTypeList

java.lang.Object
com.helger.http.header.AbstractQValueList<com.helger.mime.IMimeType>
com.helger.http.header.specific.AcceptMimeTypeList

@NotThreadSafe public class AcceptMimeTypeList extends AbstractQValueList<com.helger.mime.IMimeType>
Represents a list of "Accept" HTTP header values, created e.g. by the AcceptMimeTypeHandler.
Author:
Philip Helger
  • Constructor Details

    • AcceptMimeTypeList

      public AcceptMimeTypeList()
  • Method Details

    • addMimeType

      @Nonnull public AcceptMimeTypeList addMimeType(@Nonnull @Nonempty String sMimeType, @Nonnegative double dQuality) throws com.helger.mime.parse.MimeTypeParserException
      Throws:
      com.helger.mime.parse.MimeTypeParserException
    • addMimeType

      @Nonnull public AcceptMimeTypeList addMimeType(@Nonnull com.helger.mime.IMimeType aMimeType, @Nonnegative double dQuality)
    • getQValueOfMimeType

      @Nonnull public QValue getQValueOfMimeType(@Nonnull com.helger.mime.IMimeType aMimeType)
      Return the associated quality of the given MIME type using the fallback mechanism.
      Parameters:
      aMimeType - The charset name to query. May not be null.
      Returns:
      The QValue of the mime type
    • getQualityOfMimeType

      public double getQualityOfMimeType(@Nonnull String sMimeType)
      Return the associated quality of the given MIME type using the fallback mechanism.
      Parameters:
      sMimeType - The MIME type name to query. May be null.
      Returns:
      0 means not accepted, 1 means fully accepted. If the passed MIME type is invalid, the "not accepted" quality is returned.
    • getQualityOfMimeType

      public double getQualityOfMimeType(@Nullable com.helger.mime.IMimeType aMimeType)
      Return the associated quality of the given MIME type using the fallback mechanism.
      Parameters:
      aMimeType - The MIME type to query. May be null.
      Returns:
      0 means not accepted, 1 means fully accepted. If the passed MIME type is null, the "not accepted" quality is returned.
    • supportsMimeType

      public boolean supportsMimeType(@Nonnull String sMimeType)
      Check if the passed MIME type is supported, incl. fallback handling
      Parameters:
      sMimeType - The MIME type to check
      Returns:
      true if it is supported, false if not
    • supportsMimeType

      public boolean supportsMimeType(@Nullable com.helger.mime.IMimeType aMimeType)
      Check if the passed MIME type is supported, incl. fallback handling
      Parameters:
      aMimeType - The MIME type to check. May be null.
      Returns:
      true if it is supported, false if not
    • explicitlySupportsMimeType

      public boolean explicitlySupportsMimeType(@Nonnull String sMimeType)
      Check if the passed MIME type is supported, without considering fallback MIME types (xxx/*)
      Parameters:
      sMimeType - The MIME type to check
      Returns:
      true if it is supported, false if not
    • explicitlySupportsMimeType

      public boolean explicitlySupportsMimeType(@Nullable com.helger.mime.IMimeType aMimeType)
      Check if the passed MIME type is supported, without considering fallback MIME types (xxx/*)
      Parameters:
      aMimeType - The MIME type to check. May be null.
      Returns:
      true if it is supported, false if not
    • getPreferredMimeType

      @Nullable public com.helger.mime.IMimeType getPreferredMimeType(@Nonnull com.helger.mime.IMimeType... aMimeTypes)
      Pick the preferred mime type of the provided list of mime types.
      Parameters:
      aMimeTypes - The MIME type array to be used. May be null.
      Returns:
      null if no matching MIME type was found.
      Since:
      9.6.4
      See Also:
    • getAsHttpHeaderValue

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