Package com.helger.http.header.specific
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull AcceptMimeTypeListaddMimeType(@NonNull com.helger.mime.IMimeType aMimeType, double dQuality) Add a MIME type with the given quality.@NonNull AcceptMimeTypeListaddMimeType(@NonNull @Nonempty String sMimeType, double dQuality) Add a MIME type with the given quality by parsing the provided string.booleanexplicitlySupportsMimeType(@Nullable com.helger.mime.IMimeType aMimeType) Check if the passed MIME type is supported, without considering fallback MIME types (xxx/*)booleanexplicitlySupportsMimeType(@NonNull String sMimeType) Check if the passed MIME type is supported, without considering fallback MIME types (xxx/*)@NonNull String@Nullable com.helger.mime.IMimeTypegetPreferredMimeType(@NonNull com.helger.mime.IMimeType... aMimeTypes) Pick the preferred mime type of the provided list of mime types.doublegetQualityOfMimeType(@Nullable com.helger.mime.IMimeType aMimeType) Return the associated quality of the given MIME type using the fallback mechanism.doublegetQualityOfMimeType(@NonNull String sMimeType) Return the associated quality of the given MIME type using the fallback mechanism.@NonNull QValuegetQValueOfMimeType(@NonNull com.helger.mime.IMimeType aMimeType) Return the associated quality of the given MIME type using the fallback mechanism.booleansupportsMimeType(@Nullable com.helger.mime.IMimeType aMimeType) Check if the passed MIME type is supported, incl. fallback handlingbooleansupportsMimeType(@NonNull String sMimeType) Check if the passed MIME type is supported, incl. fallback handlingMethods inherited from class com.helger.http.header.AbstractQValueList
equals, getAllQValues, getAllQValuesGreaterOrEqual, getAllQValuesGreaterThan, getAllQValuesLowerOrEqual, getAllQValuesLowerThan, getAsHttpHeaderValue, getAsHttpHeaderValue, hashCode, qvalueMap, toString
-
Constructor Details
-
AcceptMimeTypeList
public AcceptMimeTypeList()Constructor creating an empty accept MIME type list.
-
-
Method Details
-
addMimeType
public @NonNull AcceptMimeTypeList addMimeType(@Nonempty @NonNull @Nonempty String sMimeType, @Nonnegative double dQuality) throws com.helger.mime.parse.MimeTypeParserException Add a MIME type with the given quality by parsing the provided string.- Parameters:
sMimeType- The MIME type string to parse and add. May neither benullnor empty.dQuality- The quality value between 0 and 1.- Returns:
- this for chaining
- Throws:
com.helger.mime.parse.MimeTypeParserException- If the MIME type string cannot be parsed.
-
addMimeType
public @NonNull AcceptMimeTypeList addMimeType(@NonNull com.helger.mime.IMimeType aMimeType, @Nonnegative double dQuality) Add a MIME type with the given quality. The MIME type must not contain any parameters.- Parameters:
aMimeType- The MIME type to add. May not benulland must not have any parameters.dQuality- The quality value between 0 and 1.- Returns:
- this for chaining
-
getQValueOfMimeType
Return the associated quality of the given MIME type using the fallback mechanism.- Parameters:
aMimeType- The charset name to query. May not benull.- Returns:
- The
QValueof the mime type
-
getQualityOfMimeType
Return the associated quality of the given MIME type using the fallback mechanism.- Parameters:
sMimeType- The MIME type name to query. May benull.- 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 benull.- Returns:
- 0 means not accepted, 1 means fully accepted. If the passed MIME type is
null, the "not accepted" quality is returned.
-
supportsMimeType
Check if the passed MIME type is supported, incl. fallback handling- Parameters:
sMimeType- The MIME type to check- Returns:
trueif it is supported,falseif 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 benull.- Returns:
trueif it is supported,falseif not
-
explicitlySupportsMimeType
Check if the passed MIME type is supported, without considering fallback MIME types (xxx/*)- Parameters:
sMimeType- The MIME type to check- Returns:
trueif it is supported,falseif 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 benull.- Returns:
trueif it is supported,falseif not
-
getPreferredMimeType
public @Nullable 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 benull.- Returns:
nullif no matching MIME type was found.- Since:
- 9.6.4
- See Also:
-
getAsHttpHeaderValue
- Specified by:
getAsHttpHeaderValuein classAbstractQValueList<com.helger.mime.IMimeType>- Returns:
- The string representation of this list e.g. for usage in HTTP headers.
-