MediaType class

A sub-class of MimeType that adds support for quality parameters as defined in the HTTP specification.

@author Joris Hermans

Inheritance

Constructors

MediaType(String type, {String subtype, String charset, Map<String, String> parameters})
MediaType.parseMediaType(String mediaType)
factory

Properties

charset String
read / write, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
parameters Map<String, String>
read / write, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
subtype String
read / write, inherited
type String
read / write, inherited

Methods

checkParameters(String attribute, String value) → void
inherited
copyQualityValue(MediaType mediaType) MediaType
getCharSet() String
  • Return the character set, as indicated by a charset parameter, if any.
    • @return the character set, or null if not available
  • inherited
    getParameter(String name) String
  • Return a generic parameter value, given a parameter name.
    • @param name the parameter name
    • @return the parameter value, or null if not present
  • inherited
    getParameters() Map
    inherited
    getSubtype() String
  • Return the subtype.
  • inherited
    getType() String
  • Return the primary type.
  • inherited
    hasSame(MediaType other) bool
    includes(covariant MediaType other) bool
  • Indicate whether this MediaType includes the given media type.
    • For instance, text includes text/plain and text/html,
      • and application+xml includes application/soap+xml, etc. This
      • method is not symmetric.
      • @param other the reference media type with which to compare
      • @return true if this media type includes the given media type;
      • false otherwise
  • override
    isCompatibleWith(covariant MediaType other) bool
    override
    isConcrete() bool
  • Indicates whether this media type is concrete, i.e. whether neither the type
    • nor the subtype is a wildcard character.
    • @return whether this media type is concrete
  • inherited
    isQuotedString(String s) bool
    inherited
    isWildcardSubtype() bool
  • Indicates whether the subtype is the wildcard
    • character or the wildcard character followed by a suffix.
    • @return whether the subtype is a wildcard
  • inherited
    isWildcardType() bool
  • Indicates whether the getType is the wildcard character
    • or not.
  • inherited
    noSuchMethod(Invocation invocation) → dynamic
    Invoked when a non-existent method or property is accessed. [...]
    inherited
    removeQualityValue() MediaType
    toString() String
    Returns a string representation of this object.
    inherited
    unquote(String s) String
    inherited

    Operators

    operator ==(Object other) bool
    The equality operator. [...]
    inherited

    Static Properties

    ALL MediaType
  • constant media type that includes all media ranges (i.e. "*/*").
  • final
    ALL_VALUE String
  • A String equivalent of {@link MediaType#ALL}.
  • final
    APPLICATION_ATOM_XML MediaType
  • constant media type for {@code application/atom+xml}.
  • final
    APPLICATION_ATOM_XML_VALUE String
  • A String equivalent of {@link MediaType#APPLICATION_ATOM_XML}.
  • final
    APPLICATION_FORM_URLENCODED MediaType
    constant media type for {@code application/x-www-form-urlencoded}.
    final
    APPLICATION_FORM_URLENCODED_VALUE String
  • A String equivalent of {@link MediaType#APPLICATION_FORM_URLENCODED}.
  • final
    APPLICATION_JSON MediaType
  • constant media type for {@code application/json}.
    • @see #APPLICATION_JSON_UTF8
  • final
    APPLICATION_JSON_UTF8 MediaType
  • constant media type for {@code application/json;charset=UTF-8}.
  • final
    APPLICATION_JSON_UTF8_VALUE String
  • A String equivalent of {@link MediaType#APPLICATION_JSON_UTF8}.
  • final
    APPLICATION_JSON_VALUE String
  • A String equivalent of {@link MediaType#APPLICATION_JSON}.
    • @see #APPLICATION_JSON_UTF8_VALUE
  • final
    APPLICATION_OCTET_STREAM MediaType
    constant media type for {@code application/octet-stream}.
    final
    APPLICATION_OCTET_STREAM_VALUE String
  • A String equivalent of {@link MediaType#APPLICATION_OCTET_STREAM}.
  • final
    APPLICATION_XHTML_XML MediaType
    constant media type for {@code application/xhtml+xml}.
    final
    APPLICATION_XHTML_XML_VALUE String
  • A String equivalent of {@link MediaType#APPLICATION_XHTML_XML}.
  • final
    APPLICATION_XML MediaType
  • constant media type for {@code application/xml}.
  • final
    APPLICATION_XML_VALUE String
  • A String equivalent of {@link MediaType#APPLICATION_XML}.
  • final
    IMAGE_GIF MediaType
  • constant media type for {@code image/gif}.
  • final
    IMAGE_GIF_VALUE String
  • A String equivalent of {@link MediaType#IMAGE_GIF}.
  • final
    IMAGE_JPEG MediaType
  • constant media type for {@code image/jpeg}.
  • final
    IMAGE_JPEG_VALUE String
  • A String equivalent of {@link MediaType#IMAGE_JPEG}.
  • final
    IMAGE_PNG MediaType
  • Public constant media type for {@code image/png}.
  • final
    IMAGE_PNG_VALUE String
  • A String equivalent of {@link MediaType#IMAGE_PNG}.
  • final
    IMAGE_WEBP MediaType
  • Public constant media type for {@code image/webp}.
  • final
    IMAGE_WEBP_VALUE String
  • A String equivalent of {@link MediaType#IMAGE_WEBP}.
  • final
    MULTIPART_FORM_DATA MediaType
    Public constant media type for {@code multipart/form-data}.
    final
    MULTIPART_FORM_DATA_VALUE String
  • A String equivalent of {@link MediaType#MULTIPART_FORM_DATA}.
  • final
    PARAM_QUALITY_FACTOR String
    final
    TEXT_CSV MediaType
  • constant media type for {@code text/csv}.
  • final
    TEXT_CSV_VALUE String
  • A Text CSV mediatype.
  • final
    TEXT_HTML MediaType
    Public constant media type for {@code text/html}.
    final
    TEXT_HTML_VALUE String
  • A String equivalent of {@link MediaType#TEXT_HTML}.
  • final
    TEXT_PLAIN MediaType
    Public constant media type for {@code text/plain}.
    final
    TEXT_PLAIN_VALUE String
  • A String equivalent of {@link MediaType#TEXT_PLAIN}.
  • final
    TEXT_XML MediaType
    Public constant media type for {@code text/xml}.
    final
    TEXT_XML_VALUE String
  • A String equivalent of {@link MediaType#TEXT_XML}.
  • final

    Static Methods

    parseMediaTypes(String mediaTypes) List<MediaType>
    toStringify(Iterable<MediaType> mediaTypes) String
  • Return a string representation of the given list of MediaType objects.
    • This method can be used to for an Accept or Content-Type header.
    • @param mediaTypes the media types to create a string representation for
    • @return the string representation