Class MediaType

java.lang.Object
com.tngtech.jgiven.attachment.MediaType

public class MediaType extends Object
Represents a (simplified) Media Type.
Since:
0.7.0
  • Field Details

    • GIF

      public static final MediaType GIF
      image/gif
    • PNG

      public static final MediaType PNG
      image/png
    • JPEG

      public static final MediaType JPEG
      image/jpeg
    • SVG_UTF_8

      public static final MediaType SVG_UTF_8
      image/svg+xml
    • PLAIN_TEXT_UTF_8

      public static final MediaType PLAIN_TEXT_UTF_8
      text/plain
    • JSON_UTF_8

      public static final MediaType JSON_UTF_8
      application/json
    • APPLICATION_XML_UTF_8

      public static final MediaType APPLICATION_XML_UTF_8
      application/xml
    • XML_UTF_8

      public static final MediaType XML_UTF_8
      text/xml
  • Method Details

    • getType

      public MediaType.Type getType()
      The type of the Media Type.
    • getSubType

      public String getSubType()
      The subtype of the Media Type.
    • isBinary

      public boolean isBinary()
      Whether this media type is binary or not.
    • isImage

      public boolean isImage()
    • getCharset

      public Charset getCharset()
      Returns:
      the charset of this media type if one is specified
      Throws:
      IllegalArgumentException - if no charset is specified
    • asString

      public String asString()
    • binary

      public static MediaType binary(MediaType.Type type, String subType)
      Creates a binary media type with the given type and subtype
      Throws:
      JGivenWrongUsageException - if any of the given arguments is null
    • nonBinary

      public static MediaType nonBinary(MediaType.Type type, String subType, Charset charSet)
      Creates a non-binary media type with the given type, subtype, and charSet
      Throws:
      JGivenWrongUsageException - if any of the given arguments is null
    • nonBinaryUtf8

      public static MediaType nonBinaryUtf8(MediaType.Type type, String subType)
      Creates a non-binary media type with the given type, subtype, and UTF-8 encoding
      Throws:
      JGivenWrongUsageException - if any of the given arguments is null
    • image

      public static MediaType image(String subType)
      Creates a binary image media type with the given subtype.
    • imageUtf8

      public static MediaType imageUtf8(String subType)
      Creates a textual image media type with the given subtype and UTF-8 encoding
    • application

      public static MediaType application(String subType)
      Creates a binary application media type with the given subtype.
    • applicationUtf8

      public static MediaType applicationUtf8(String subType)
      Creates a textual application media type with the given subtype and UTF-8 encoding
    • video

      public static MediaType video(String subType)
      Creates a binary video media type with the given subtype.
    • audio

      public static MediaType audio(String subType)
      Creates a binary audio media type with the given subtype.
    • text

      public static MediaType text(String subType, Charset charset)
      Creates a non-binary text media type with the given subtype and a specified encoding
    • textUtf8

      public static MediaType textUtf8(String subType)
      Creates a non-binary text media type with the given subtype.
    • toString

      public String toString()
      Overrides:
      toString in class Object