Interface MediaType


public interface MediaType
Represent a Media type (rfc6838).
Author:
Julien Viet
  • Field Details

    • ANY

      static final MediaType ANY
    • APPLICATION

      static final MediaType APPLICATION
    • APPLICATION_OCTET_STREAM

      static final MediaType APPLICATION_OCTET_STREAM
    • APPLICATION_JSON

      static final MediaType APPLICATION_JSON
    • TEXT

      static final MediaType TEXT
    • TEXT_PLAIN

      static final MediaType TEXT_PLAIN
  • Method Details

    • parseAcceptHeader

      static List<MediaType> parseAcceptHeader(String header) throws IllegalArgumentException
      Parse an accept header which is a list of media types
      Parameters:
      header - the header
      Returns:
      the list of media types
      Throws:
      IllegalArgumentException - when the list is not valid
    • parse

      static MediaType parse(String s)
      Parse a media type.
      Parameters:
      s - the string representation
      Returns:
      the parsed media type or null when the string to parse is not valid
    • type

      String type()
      Returns:
      the type or null when everything is matched (*)
    • subType

      String subType()
      Returns:
      the sub type or null when everything is matched (*)
    • accepts

      boolean accepts(MediaType other)
      Returns:
      whether the other mime type is accepted
    • parameter

      String parameter(String name)
      Return a media type parameter
      Parameters:
      name - the parameter name
      Returns:
      the value or null