Class MediaType

java.lang.Object
com.globalmentor.net.MediaType

public final class MediaType extends Object
An encapsulation of an Internet media content type as previously defined in RFC 2046: MIME Part 2: Media Types; and most recently in RFC 6838: Media Type Specifications and Registration Procedures. The full syntax for a media type and its parameters are found in RFC 2045: MIME Part 1: Format of Internet Message Bodies
Author:
Garret Wilson
API Note:
Neither javax.activation.MimeType nor javax.mail.internet.ContentType correctly implements Object.equals(Object) and therefore cannot reliably be used in sets and maps. Furthermore, javax.mail.internet.ContentType as of JDK 6 is not included in default JDK distributions. javax.activation.MimeType was recently added to JDK distributions, so in an earlier implementation this class provided appropriate factory methods, to provide special javax.activation.MimeType instances that provide correct equality checking. Because the javax.activation package is not included in the Android Development Kit, however, and seeing that neither javax.activation.MimeType nor javax.mail.internet.ContentType are in common use, the current implementation provides a fully independent version., Internet media types are currently governed by RFC 6838: Media Type Specifications and Registration Procedures. RFC 6532: Internationalized Email Headers § 3.2. Syntax Extensions to RFC 5322 extends extends the syntax to support UTF-8. According to the WhatWG, a quoted string follows RFC 7230: Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing § 3.2.6. Field Value Components.
Implementation Specification:
This class normalizes type, subtype, and parameter names, which are ASCII case-insensitive, to ASCII lowercase; along with the charset parameter value. All other parameter values are left as-is. All other parameter values that are case-insensitive should be passed as lowercase to ensure correct equality comparisons., This implementation does not support parameter values containing control characters except for the horizontal tab character, permitted by RFC 7230 § 3.2.6.., This implementation supports empty parameter values if they are quoted.
Implementation Note:
Compare this implementation to that of Guava's com.google.common.net.MediaType which, in addition to normalizing type, subtype, and parameter names to lowercase, also normalizes the value of the charset attribute to lowercase. Note also that RFC 7231 § 3.1.1.1. Media Type indicates that a lowercase form of charset value is preferred, e.g.text/html;charset=utf-8. In addition RFC 2046 § 4.1.2. Charset Parameter indicates that if non-text types specify a charset value, "the same syntax and values should be used".
See Also:
  • Field Details

    • TYPE_DIVIDER

      public static final char TYPE_DIVIDER
      The divider character for media type strings.
      See Also:
    • PARAMETER_DELIMITER_CHAR

      public static final char PARAMETER_DELIMITER_CHAR
      The delimiter character separating parameters from the base media type and from each other.
      See Also:
    • PARAMETER_ASSIGNMENT_CHAR

      public static final char PARAMETER_ASSIGNMENT_CHAR
      The character used to assign parameter values.
      See Also:
    • STRING_QUOTE_CHAR

      public static final char STRING_QUOTE_CHAR
      The character for quoting a string, such as a parameter value with special characters.
      See Also:
    • STRING_ESCAPE_CHAR

      public static final char STRING_ESCAPE_CHAR
      The character for escaping a quoted string.
      See Also:
    • FACET_DELIMITER_CHAR

      public static final char FACET_DELIMITER_CHAR
      The character delimiting a facet name from the rest of the name as per RFC 6838.
      See Also:
    • SUBTYPE_EXTENSION_PREFIX

      public static final String SUBTYPE_EXTENSION_PREFIX
      The separator character that begins a non-standard extension type.
      See Also:
    • SUBTYPE_SUFFIX_DELIMITER_CHAR

      public static final char SUBTYPE_SUFFIX_DELIMITER_CHAR
      The separator character that delimits a subtype suffix.
      See Also:
    • TYPE_WILDCARD_CHAR

      public static final char TYPE_WILDCARD_CHAR
      The wildcard character.
      See Also:
    • WILDCARD_SUBTYPE

      public static final String WILDCARD_SUBTYPE
      The wildcard subtype, matching any subtype.
    • RESTRICTED_NAME_FIRST_CHARACTERS

      public static final Characters RESTRICTED_NAME_FIRST_CHARACTERS
      The restricted-name-first characters of RFC 6838, defining the first character of a restricted-name.
    • RESTRICTED_NAME_CHARACTERS

      public static final Characters RESTRICTED_NAME_CHARACTERS
      The restricted-name-chars characters of RFC 6838, making up a restricted-name.
    • RESTRICTED_NAME_CHARS_MAX_LENGTH

      public static final byte RESTRICTED_NAME_CHARS_MAX_LENGTH
      The maximum number of restricted-name-chars of a restricted-name according to RFC 6838.
      See Also:
    • RESTRICTED_NAME_MAX_LENGTH

      public static final byte RESTRICTED_NAME_MAX_LENGTH
      The maximum length of a restricted-name according to RFC 6838.
      See Also:
    • RESTRICTED_NAME_PATTERN

      public static final Pattern RESTRICTED_NAME_PATTERN
      The regular expression pattern defining a restricted-name as per RFC 6838.
    • SPECIAL_CHARACTERS

      public static final Characters SPECIAL_CHARACTERS
      The tspecials characters of RFC 2045, which require a string to be quoted in a parameter value.
    • ILLEGAL_TOKEN_CHARACTERS

      public static final Characters ILLEGAL_TOKEN_CHARACTERS
      The characters of RFC 2045 which are considered illegal in tokens such as non-quoted strings.
      Implementation Specification:
      This currently does not include the control characters other than the horizontal tab. A future version may detect this using the \p{Cntrl} character class; for now the implementation checks manually and forbids control characters except for tab.
      See Also:
    • QUOTED_STRING_PROHIBITED_CONTROL_CHARACTERS

      public static final Characters QUOTED_STRING_PROHIBITED_CONTROL_CHARACTERS
      The control characters not allowed in a quoted string as per RFC 7230.
      See Also:
    • QUOTED_STRING_REQUIRED_ESCAPED_CHARACTERS

      public static final Characters QUOTED_STRING_REQUIRED_ESCAPED_CHARACTERS
      Characters required to be escaped in a quoted string.
    • PARAMETER_PATTERN

      public static final Pattern PARAMETER_PATTERN
      A pattern for checking the basic form of a parameter, including the ';' delimiter that precedes and separates each parameter. The pattern may be repeated. The two matching groups are the name and value.
      See Also:
    • PARAMETER_ITERATE_PATTERN

      public static final Pattern PARAMETER_ITERATE_PATTERN
      A pattern for checking the basic form of a parameter, including the ';' delimiter that precedes and separates each parameter. Suitable for iterating through parameters using Matcher.find(). The two matching groups are the name and value.
      See Also:
    • PARAMETER_PATTERN_NAME_GROUP

      public static final int PARAMETER_PATTERN_NAME_GROUP
      The parameters pattern matching group for the parameter name.
      See Also:
    • PARAMETER_PATTERN_VALUE_GROUP

      public static final int PARAMETER_PATTERN_VALUE_GROUP
      The parameters pattern matching group for the parameter name.
      See Also:
    • PATTERN

      public static final Pattern PATTERN
      A pattern for checking the basic form of regular expressions. This pattern does not take into account all aspects of a regular expression, e.g. special characters. The parameters group will be null if there are no parameters at all.
    • PATTERN_PRIMARY_TYPE_GROUP

      public static final int PATTERN_PRIMARY_TYPE_GROUP
      The pattern matching group for the primary type.
      See Also:
    • PATTERN_SUBTYPE_GROUP

      public static final int PATTERN_SUBTYPE_GROUP
      The pattern matching group for the subtype.
      See Also:
    • PATTERN_PARAMETERS_GROUP

      public static final int PATTERN_PARAMETERS_GROUP
      The pattern matching group for all the parameters, with delimiters.
      See Also:
    • TEXT_PRIMARY_TYPE

      public static final String TEXT_PRIMARY_TYPE
      The text top-level type.
      See Also:
    • IMAGE_PRIMARY_TYPE

      public static final String IMAGE_PRIMARY_TYPE
      The image top-level type.
      See Also:
    • AUDIO_PRIMARY_TYPE

      public static final String AUDIO_PRIMARY_TYPE
      The audio top-level type.
      See Also:
    • VIDEO_PRIMARY_TYPE

      public static final String VIDEO_PRIMARY_TYPE
      The video top-level type.
      See Also:
    • APPLICATION_PRIMARY_TYPE

      public static final String APPLICATION_PRIMARY_TYPE
      The application top-level type.
      See Also:
    • MULTIPART_PRIMARY_TYPE

      public static final String MULTIPART_PRIMARY_TYPE
      The multipart top-level type.
      See Also:
    • MESSAGE_PRIMARY_TYPE

      public static final String MESSAGE_PRIMARY_TYPE
      The message top-level type.
      See Also:
    • CONTENT_PRIMARY_TYPE

      public static final String CONTENT_PRIMARY_TYPE
      The pseudo top-level type used by Java URLConnection to indicate unknown content by content/unknown.
      See Also:
    • CHARSET_PARAMETER

      public static final String CHARSET_PARAMETER
      The character set parameters.
      See Also:
    • UNKNOWN_SUBTYPE

      public static final String UNKNOWN_SUBTYPE
      The pseudo subtype used by Java URLConnection to indicate unknown content by content/unknown.
      See Also:
    • OCTET_STREAM_SUBTYPE

      public static final String OCTET_STREAM_SUBTYPE
      A stream of bytes.
      See Also:
    • X_JAVA_OBJECT

      public static final String X_JAVA_OBJECT
      A Java object.
      See Also:
    • APPLICATION_OCTET_STREAM_MEDIA_TYPE

      public static final MediaType APPLICATION_OCTET_STREAM_MEDIA_TYPE
      The shared application/octet-stream media type.
  • Method Details

    • checkArgumentRestrictedName

      public static <C extends CharSequence> C checkArgumentRestrictedName(C input)
      Confirms that the given input conforms to the rules for restricted-name according to RFC 6838, returning the given input.
      API Note:
      This method is useful for checking a type, subtype, or parameter name.
      Type Parameters:
      C - The type of character sequence input.
      Parameters:
      input - The character sequence to check.
      Returns:
      The given input.
      Throws:
      NullPointerException - if the given input is null.
      IllegalArgumentException - if the given input does not conform to the rules for restricted-name.
      See Also:
    • getPrimaryType

      public String getPrimaryType()
      Returns:
      The primary type of the media type.
    • getSubType

      public String getSubType()
      Returns:
      The subtype of the media type.
    • getParameters

      public Set<MediaType.Parameter> getParameters()
      Returns:
      The set of parameters, which may be empty, but will never be null.
    • findCharset

      public Optional<Charset> findCharset()
      Convenience method for returning the "charset" parameter. If there are multiple "charset" parameters, it is undefined which one is used to return the value.
      Returns:
      The charset specified by one of the "charset" parameters, if any.
      Throws:
      UnsupportedCharsetException - If no support for the named charset is available in this instance of the Java virtual machine
    • create

      @Deprecated public static MediaType create(CharSequence charSequence)
      Deprecated.
      in favor of parse(CharSequence); to be removed in next major version.
      Parses a media type object from a sequence of characters.
      Implementation Specification:
      The primary type, subtype, and parameter names, if any, are each normalized to lowercase. The value of the "charset" parameter, if present, is normalized to lowercase.
      Parameters:
      charSequence - The character sequence representation of the media type.
      Returns:
      A new media type object parsed from the string.
      Throws:
      IllegalArgumentException - if the primary type, subtype, and/or a parameter name does not conform to the RESTRICTED_NAME_PATTERN pattern.
    • of

      @Deprecated public static MediaType of(CharSequence charSequence)
      Deprecated.
      in favor of parse(CharSequence); to be removed in next major version.
      Parses a media type object from a sequence of characters.
      Implementation Specification:
      The primary type, subtype, and parameter names, if any, are each normalized to lowercase. The value of the "charset" parameter, if present, is normalized to lowercase.
      Parameters:
      charSequence - The character sequence representation of the media type.
      Returns:
      A new media type object parsed from the string.
      Throws:
      IllegalArgumentException - if the name does not conform to the RESTRICTED_NAME_PATTERN pattern.
      IllegalArgumentException - if the primary type, subtype, and/or a parameter name does not conform to the RESTRICTED_NAME_PATTERN pattern.
    • create

      @Deprecated public static MediaType create(String primaryType, String subType, MediaType.Parameter... parameters)
      Deprecated.
      in favor of of(String, String, Parameter...); to be removed in next major version.
      Creates a media type object from primary type, a subtype, and optional parameters.
      Implementation Specification:
      The primary type and subtype are each normalized to lowercase.
      Parameters:
      primaryType - The primary type.
      subType - The subtype.
      parameters - Optional name-value pairs representing parameters of the media type.
      Returns:
      A new media type object constructed from the given information.
      Throws:
      IllegalArgumentException - if the primary type and/or subtype does not conform to the RESTRICTED_NAME_PATTERN pattern.
    • of

      public static MediaType of(String primaryType, String subType, MediaType.Parameter... parameters)
      Returns a media type object from primary type, a subtype, and optional parameters.
      Implementation Specification:
      The primary type and subtype are each normalized to lowercase.
      Parameters:
      primaryType - The primary type.
      subType - The subtype.
      parameters - Optional name-value pairs representing parameters of the media type.
      Returns:
      A new media type object constructed from the given information.
      Throws:
      IllegalArgumentException - if the primary type and/or subtype does not conform to the RESTRICTED_NAME_PATTERN pattern.
    • of

      public static MediaType of(String primaryType, String subType, Set<MediaType.Parameter> parameters)
      Returns a media type object from primary type, a subtype, and optional parameters.
      Implementation Specification:
      The primary type and subtype are each normalized to lowercase.
      Parameters:
      primaryType - The primary type.
      subType - The subtype.
      parameters - Zero or more name-value pairs representing parameters of the media type.
      Returns:
      A new media type object constructed from the given information.
      Throws:
      NullPointerException - if the given parameters set is null.
      IllegalArgumentException - if the primary type and/or subtype does not conform to the RESTRICTED_NAME_PATTERN pattern.
    • parse

      public static MediaType parse(CharSequence text)
      Parses a media type object from a sequence of characters.
      Implementation Specification:
      The primary type, subtype, and parameter names, if any, are each normalized to lowercase. The value of the "charset" parameter, if present, is normalized to lowercase.
      Parameters:
      text - The character sequence representation of the media type.
      Returns:
      A new media type object parsed from the string.
      Throws:
      IllegalArgumentException - if the primary type, subtype, and/or a parameter name does not conform to the RESTRICTED_NAME_PATTERN pattern.
    • parseParameters

      public static Set<MediaType.Parameter> parseParameters(CharSequence text)
      Parses parameters of a media type from a sequence of characters.
      Implementation Specification:
      The parameter names are each normalized to lowercase. The value of the "charset" parameter, if present, is normalized to lowercase.
      Parameters:
      text - The character sequence representing the parameters of the media type, not including the ';' delimiter.
      Returns:
      Media type parameters parsed from the string.
      Throws:
      IllegalArgumentException - if the string is not syntactically correct parameters, or if a parameter name does not conform to the RESTRICTED_NAME_PATTERN pattern.
    • getParameter

      public String getParameter(String name)
      Retrieve the parameter value associated with the given parameter name. Names are comparisons are ASCII case-insensitive.
      Parameters:
      name - The name of the parameter.
      Returns:
      The (always unquoted) value associated with the given name, or null if there is no parameter with the given name.
      Throws:
      NullPointerException - if the given parameter name is null.
    • matches

      public boolean matches(@Nonnull CharSequence text)
      Matches a media type against a primary type and subtype string representation. Comparisons are ASCII case-insensitive. This method supports wildcard subtypes.
      Parameters:
      text - The primary type and subtype with which to compare the media type, such as text/plain or image/*.
      Returns:
      true if the media type has a primary type and a subtype matching those given.
      Throws:
      IllegalArgumentException - if the given match type is not in the correct format, such as missing a type separator slash.
      See Also:
    • matches

      public boolean matches(@Nonnull String primaryType, @Nonnull String subType)
      Matches a media type against a primary type and subtype. Comparisons are ASCII case-insensitive. This method supports wildcard subtypes.
      Parameters:
      primaryType - The primary type with which to compare the media type.
      subType - The subtype with which to compare the media type.
      Returns:
      true if the media type has a primary type and a subtype matching those given.
      See Also:
    • match

      @Deprecated public boolean match(@Nonnull String primaryType, @Nonnull String subType)
      Deprecated.
      to be replaced with matches(String, String).
      Matches a media type against a primary type and subtype. Comparisons are ASCII case-insensitive. This method supports wildcard subtypes.
      Parameters:
      primaryType - The primary type with which to compare the media type.
      subType - The subtype with which to compare the media type.
      Returns:
      true if the media type has a primary type and a subtype matching those given.
      See Also:
    • matches

      public boolean matches(@Nonnull String primaryType, @Nonnull String subType, @Nonnull Class<?> objectClass)
      Matches a media type against a primary type and subtype, with a class parameter indicating the given object class. This method supports wildcard subtypes.
      Parameters:
      primaryType - The primary type with which to compare the media type.
      subType - The subtype with which to compare the media type.
      objectClass - The class for which to check in the parameters under the key "class".
      Returns:
      true if the media type has the same primary type and subtype as that given, along with a class parameter.
      See Also:
    • matches

      public boolean matches(@Nonnull Class<?> objectClass)
      Matches a media type against the "application" primary type and "x-java-object" subtype, with a "class" parameter indicating the given object class. This method supports wildcard subtypes.
      Parameters:
      objectClass - The class for which to check in the parameters under the key "class".
      Returns:
      true if the media type has the same primary type and subtype as that given, along with a class parameter.
      See Also:
    • getBaseType

      @Deprecated public String getBaseType()
      Deprecated.
      to be removed in favor of toBaseTypeString().
      Returns:
      A string representation of the the base media type, that is, the same primary and subtype as the media type, but with no parameters.
    • getBaseContentType

      @Deprecated public MediaType getBaseContentType()
      Deprecated.
      to be removed in favor of toBaseType().
      Determines the base media type, with no parameters, of the media type. Useful for making comparisons or for storing in canonical form in a hash table. If this media type is already a base media type, this media type is returned.
      Returns:
      A media type with the same primary and subtype as the media type, but with no parameters.
    • toBaseType

      public MediaType toBaseType()
      Returns an instance of the "base type"; that is, the media type with no parameters.
      API Note:
      The base type is useful for making comparisons or for storing in canonical form in a hash table.
      Implementation Specification:
      If this media type is already a base media type, this media type is returned.
      Returns:
      A media type with the same primary and subtype as the media type, but with no parameters.
      See Also:
    • hasBaseType

      public boolean hasBaseType(MediaType mediaType)
      Checks to see if the given media type has the same primary type and subtype as this media type. The parameters of the this media type and the given media type are ignored. This method does not support wildcards.
      Parameters:
      mediaType - The media type with which to compare this media type.
      Returns:
      true if the primary types and base types of the two media types are equal.
      See Also:
    • hasBaseType

      public boolean hasBaseType(String primaryType, String subType)
      Matches a media type against a primary type and subtype with no wildcard support. Comparisons are ASCII case-insensitive.
      Parameters:
      primaryType - The primary type with which to compare the media type.
      subType - The subtype with which to compare the media type.
      Returns:
      true if the media type has the same primary type and subtype as that given.
      Throws:
      NullPointerException - if the primary type and/or subtype is null.
      See Also:
    • hasSubTypeSuffix

      public boolean hasSubTypeSuffix(String... suffixes)
      Determines if the subtype of the media type has the given suffix.
      Implementation Specification:
      Suffixes are compared on an ASCII case-insensitive basis.
      Implementation Note:
      This implementation restricts each suffix to the RESTRICTED_NAME_PATTERN pattern, the same pattern applicable to a subtype, although this requirement is not explicit in RFC 6838.
      Parameters:
      suffixes - The suffix strings that will be checked, after they are combined into a single suffix, each part prepended with '+'.
      Returns:
      true if the media type's subtype has the given suffixes.
      Throws:
      IllegalArgumentException - if a suffix does not conform to the RESTRICTED_NAME_PATTERN pattern, including if it already begins with the '+' delimiter.
    • withParameter

      public MediaType withParameter(MediaType.Parameter newParameter)
      Returns a media type with the given parameter, replacing any existing parameter with the same name. If this media type already has the given parameter, this media type will be returned. If this media type has a parameter with the same name but with a different value, the parameter will be replaced with the one given. Otherwise, the parameter will be added to the parameters.
      Implementation Specification:
      Parameter name comparisons are ASCII case-insensitive. The comparison of the "charset" parameter value is performed in an ASCII case-insensitive manner. All other parameter values are compared with case sensitivity.
      Parameters:
      newParameter - The new parameter to add or replace.
      Returns:
      A media type with the given parameter.
    • withParameter

      public MediaType withParameter(String name, String value)
      Returns a media type with the given parameter, replacing any existing parameter with the same name. If this media type already has the given parameter, this media type will be returned. If this media type has a parameter with the same name but with a different value, the parameter will be replaced with the one given. Otherwise, the parameter will be added to the parameters.
      Implementation Specification:
      Parameter name comparisons are ASCII case-insensitive. The comparison of the "charset" parameter value is performed in an ASCII case-insensitive manner. All other parameter values are compared with case sensitivity., This implementation delegates to withParameter(Parameter).
      Parameters:
      name - The parameter name to add or replace.
      value - The parameter value.
      Returns:
      A media type with the given parameter.
      Throws:
      NullPointerException - if the given name and/or value is null.
      IllegalArgumentException - if the parameter name does not conform to the RESTRICTED_NAME_PATTERN pattern.
      See Also:
    • withCharset

      public MediaType withCharset(@Nonnull Charset charset)
      Returns a media type with the given charset as a "charset" parameter, replacing any existing parameter with the same name. If this media type already has the given parameter, this media type will be returned. If this media type has a parameter with the same name but with a different value, the parameter will be replaced with the one given. Otherwise, the parameter will be added to the parameters.
      Implementation Specification:
      Parameter name comparisons are ASCII case-insensitive. The comparison of the "charset" parameter value is performed in an ASCII case-insensitive manner., This implementation delegates to withParameter(String, String).
      Parameters:
      charset - The charset value to add or replace.
      Returns:
      A media type with the given parameter.
      Throws:
      NullPointerException - if the given charset is null.
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      Implementation Specification:
      This implementation returns the hash code of the primary type, the subtype, the parameter names, and the "charset" parameter value in a case insensitive manner, as these items have already been normalized by this class.
      Returns:
      A hash code value for this object.
      See Also:
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
      Implementation Specification:
      This implementation considers an object equal if it is another MediaType with the same primary types and subtypes, the same number of parameters, and a matching parameter value for every parameter of this media type. Comparisons are ASCII case-insensitive for the primary type, the subtype, the parameter names, and the "charset" parameter value, as these items have already been normalized by this class.
      Parameters:
      object - The reference object with which to compare.
      See Also:
    • toString

      public String toString(boolean formatted)
      Returns a possibly formatted string version of the given media type.
      Parameters:
      formatted - Whether the resulting string should be formatted with extra whitespace for human readability.
      Returns:
      The canonical representation of the media type according to RFC 6838.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Implementation Specification:
      This implementation returns the canonical representation of the media type according to RFC 6838, with no added whitespace.
    • toBaseTypeString

      public String toBaseTypeString()
      Returns a string representation of the base type; that is, the same primary and subtype as the media type, but with no parameters
      API Note:
      Compare with javax.activiation.MimeType.getBaseType().
      Returns:
      A string representation of the media type with no parameters.
      See Also:
    • toString

      public static String toString(@Nonnull String primaryType, @Nonnull String subType, MediaType.Parameter... parameters)
      Constructs a string representing a media type.
      Parameters:
      primaryType - The primary type.
      subType - The subtype.
      parameters - Optional name-value pairs representing parameters of the media type.
      Returns:
      A string representing the type in the form "primaryType/subType[;parameters]".
    • toString

      public static String toString(@Nonnull String primaryType, @Nonnull String subType, @Nonnull Iterable<MediaType.Parameter> parameters)
      Constructs a string representing a media type in canonical form with no extra whitespace or other formatting. The parameters will be placed in the string in iteration order.
      Parameters:
      primaryType - The primary type.
      subType - The subtype.
      parameters - Any name-value pairs representing parameters of the media type.
      Returns:
      A string representing the type in the form "primaryType/subType[;parameters]".
      Throws:
      NullPointerException - if the given parameters set is null.
    • toString

      public static String toString(@Nonnull String primaryType, @Nonnull String subType, @Nonnull Iterable<MediaType.Parameter> parameters, boolean formatted)
      Constructs a string representing a media type. The parameters will be placed in the string in iteration order.
      Parameters:
      primaryType - The primary type.
      subType - The subtype.
      parameters - Any name-value pairs representing parameters of the media type.
      formatted - Whether the resulting string should be formatted with extra whitespace for human readability.
      Returns:
      A string representing the type in the form "primaryType/subType[;parameters]".
      Throws:
      NullPointerException - if the given parameters set is null.
      See Also:
    • createSubTypeSuffix

      public static String createSubTypeSuffix(String... suffixes)
      Creates a media type suffix by prepending '+' to each suffix and concatenating the suffixes.
      Implementation Specification:
      Each suffix is normalized to lowercase.
      Implementation Note:
      This implementation restricts each suffix to the RESTRICTED_NAME_PATTERN pattern, the same pattern applicable to a subtype, although this requirement is not explicit in RFC 6838.
      Parameters:
      suffixes - The suffix strings to combine into a suffix.
      Returns:
      A suffix composed of the given suffix strings.
      Throws:
      IllegalArgumentException - if a suffix does not conform to the RESTRICTED_NAME_PATTERN pattern, including if it already begins with the '+' delimiter.
      See Also: