Class MediaTypeRegistry

java.lang.Object
org.opensearch.core.xcontent.MediaTypeRegistry

public final class MediaTypeRegistry extends Object
Parses supported internet media types
Opensearch.internal:
  • Field Details

  • Constructor Details

    • MediaTypeRegistry

      public MediaTypeRegistry()
  • Method Details

    • fromMediaType

      public static MediaType fromMediaType(String mediaType)
    • fromFormat

      public static MediaType fromFormat(String format)
    • contentBuilder

      public static XContentBuilder contentBuilder(MediaType type) throws IOException
      Returns a binary content builder for the provided content type.
      Throws:
      IOException
    • contentBuilder

      public static XContentBuilder contentBuilder(MediaType type, OutputStream outputStream) throws IOException
      Throws:
      IOException
    • xContent

      @Deprecated public static MediaType xContent(byte[] data, int offset, int length)
      Deprecated.
      the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.
      Guesses the content (type) based on the provided char sequence and returns the corresponding XContent
    • xContent

      @Deprecated public static MediaType xContent(byte[] data)
      Deprecated.
      the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.
      Guesses the content type based on the provided bytes and returns the corresponding XContent
    • xContent

      @Deprecated public static MediaType xContent(CharSequence content)
      Deprecated.
      the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.
      Guesses the content (type) based on the provided char sequence and returns the corresponding XContent
    • xContentType

      @Deprecated public static MediaType xContentType(CharSequence content)
      Deprecated.
      the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.
      Guesses the content type based on the provided char sequence.
    • xContentType

      @Deprecated public static MediaType xContentType(InputStream si) throws IOException
      Deprecated.
      the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.
      Guesses the content type based on the provided input stream without consuming it.
      Throws:
      IOException
    • xContentType

      @Deprecated public static MediaType xContentType(BytesReference bytes)
      Deprecated.
      the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.
      Guesses the content type based on the provided bytes.
    • mediaTypeFromBytes

      @Deprecated public static MediaType mediaTypeFromBytes(byte[] data, int offset, int length)
      Deprecated.
      the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.
      Guesses the content type based on the provided bytes.
    • parseMediaType

      public static MediaTypeRegistry.ParsedMediaType parseMediaType(String headerValue)
      parsing media type that follows https://tools.ietf.org/html/rfc7231#section-3.1.1.1
      Parameters:
      headerValue - a header value from Accept or Content-Type
      Returns:
      a parsed media-type
    • getDefaultMediaType

      public static MediaType getDefaultMediaType()