Class MediaTypeRegistry<T extends MediaType>

java.lang.Object
org.elasticsearch.xcontent.MediaTypeRegistry<T>

public class MediaTypeRegistry<T extends MediaType> extends Object
A registry for quick media type lookup. It allows to find media type by a header value - typeWithSubtype aka mediaType without parameters. I.e. application/json will return XContentType.JSON Also allows to find media type by a path parameter format. I.e. txt used in path _sql?format=txt will return TextFormat.PLAIN_TEXT Multiple header representations may map to a single MediaType for example, "application/json" and "application/x-ndjson" both represent a JSON MediaType. A MediaType can have only one query parameter representation. For example "json" (case insensitive) maps back to a JSON media type. Additionally, a http header may optionally have parameters. For example "application/vnd.elasticsearch+json; compatible-with=7". This class also allows to define a regular expression for valid values of charset.
  • Constructor Details

    • MediaTypeRegistry

      public MediaTypeRegistry()
  • Method Details

    • queryParamToMediaType

      public T queryParamToMediaType(String format)
    • typeWithSubtypeToMediaType

      public T typeWithSubtypeToMediaType(String typeWithSubtype)
    • parametersFor

      public Map<String,Pattern> parametersFor(String typeWithSubtype)
    • register

      public MediaTypeRegistry<T> register(T[] mediaTypes)