Enum Class XContentType

java.lang.Object
java.lang.Enum<XContentType>
org.elasticsearch.xcontent.XContentType
All Implemented Interfaces:
Serializable, Comparable<XContentType>, Constable, MediaType

public enum XContentType extends Enum<XContentType> implements MediaType
The content type of XContent.
  • Enum Constant Details

    • JSON

      public static final XContentType JSON
      A JSON based content type.
    • SMILE

      public static final XContentType SMILE
      The jackson based smile binary format. Fast and compact binary format.
    • YAML

      public static final XContentType YAML
      A YAML based content type.
    • CBOR

      public static final XContentType CBOR
      A CBOR based content type.
    • VND_JSON

      public static final XContentType VND_JSON
      A versioned JSON based content type.
    • VND_SMILE

      public static final XContentType VND_SMILE
      Versioned jackson based smile binary format. Fast and compact binary format.
    • VND_YAML

      public static final XContentType VND_YAML
      A Versioned YAML based content type.
    • VND_CBOR

      public static final XContentType VND_CBOR
      A Versioned CBOR based content type.
  • Field Details

  • Method Details

    • values

      public static XContentType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static XContentType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • fromFormat

      public static XContentType fromFormat(String format)
      Accepts a format string, which is most of the time is equivalent to MediaType's subtype i.e. application/json and attempts to match the value to an XContentType. The comparisons are done in lower case format. This method will return null if no match is found
    • fromMediaType

      public static XContentType fromMediaType(String mediaTypeHeaderValue) throws IllegalArgumentException
      Attempts to match the given media type with the known XContentType values. This match is done in a case-insensitive manner. The provided media type can optionally has parameters. This method is suitable for parsing of the Content-Type and Accept HTTP headers. This method will return null if no match is found
      Throws:
      IllegalArgumentException
    • parseVersion

      public static Byte parseVersion(String mediaType)
    • index

      public int index()
    • mediaType

      public String mediaType()
    • xContent

      public abstract XContent xContent()
    • mediaTypeWithoutParameters

      public abstract String mediaTypeWithoutParameters()
    • toParsedMediaType

      public ParsedMediaType toParsedMediaType()
    • canonical

      public XContentType canonical()
      Returns a canonical XContentType for this XContentType. A canonical XContentType is used to serialize or deserialize the data from/to for HTTP. More specialized XContentType types such as vnd* variants still use the general data structure, but may have semantic differences. Example: XContentType.VND_JSON has a canonical XContentType.JSON XContentType.JSON has a canonical XContentType.JSON