Package com.tngtech.jgiven.attachment
Class MediaType
- java.lang.Object
-
- com.tngtech.jgiven.attachment.MediaType
-
public class MediaType extends java.lang.Object
Represents a (simplified) Media Type.- Since:
- 0.7.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MediaType.Type
Represents the type of a Media Type
-
Field Summary
Fields Modifier and Type Field Description static MediaType
APPLICATION_XML_UTF_8
application/xmlstatic MediaType
GIF
image/gifstatic MediaType
JPEG
image/jpegstatic MediaType
JSON_UTF_8
application/jsonstatic MediaType
PLAIN_TEXT_UTF_8
text/plainstatic MediaType
PNG
image/pngstatic MediaType
SVG_UTF_8
image/svg+xmlstatic MediaType
XML_UTF_8
text/xml
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MediaType
application(java.lang.String subType)
Creates a binary application media type with the given subtype.static MediaType
applicationUtf8(java.lang.String subType)
Creates a textual application media type with the given subtype and UTF-8 encodingjava.lang.String
asString()
static MediaType
audio(java.lang.String subType)
Creates a binary audio media type with the given subtype.static MediaType
binary(MediaType.Type type, java.lang.String subType)
Creates a binary media type with the given type and subtypejava.nio.charset.Charset
getCharset()
java.lang.String
getSubType()
The subtype of the Media Type.MediaType.Type
getType()
The type of the Media Type.static MediaType
image(java.lang.String subType)
Creates a binary image media type with the given subtype.static MediaType
imageUtf8(java.lang.String subType)
Creates a textual image media type with the given subtype and UTF-8 encodingboolean
isBinary()
Whether this media type is binary or not.boolean
isImage()
static MediaType
nonBinary(MediaType.Type type, java.lang.String subType, java.nio.charset.Charset charSet)
Creates a non-binary media type with the given type, subtype, and charSetstatic MediaType
nonBinaryUtf8(MediaType.Type type, java.lang.String subType)
Creates a non-binary media type with the given type, subtype, and UTF-8 encodingstatic MediaType
text(java.lang.String subType, java.nio.charset.Charset charset)
Creates a non-binary text media type with the given subtype and a specified encodingstatic MediaType
textUtf8(java.lang.String subType)
Creates a non-binary text media type with the given subtype.java.lang.String
toString()
static MediaType
video(java.lang.String subType)
Creates a binary video media type with the given subtype.
-
-
-
Field Detail
-
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 Detail
-
getType
public MediaType.Type getType()
The type of the Media Type.
-
getSubType
public java.lang.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 java.nio.charset.Charset getCharset()
- Returns:
- the charset of this media type if one is specified
- Throws:
java.lang.IllegalArgumentException
- if no charset is specified
-
asString
public java.lang.String asString()
-
binary
public static MediaType binary(MediaType.Type type, java.lang.String subType)
Creates a binary media type with the given type and subtype- Throws:
JGivenWrongUsageException
- if any of the given arguments isnull
-
nonBinary
public static MediaType nonBinary(MediaType.Type type, java.lang.String subType, java.nio.charset.Charset charSet)
Creates a non-binary media type with the given type, subtype, and charSet- Throws:
JGivenWrongUsageException
- if any of the given arguments isnull
-
nonBinaryUtf8
public static MediaType nonBinaryUtf8(MediaType.Type type, java.lang.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 isnull
-
image
public static MediaType image(java.lang.String subType)
Creates a binary image media type with the given subtype.
-
imageUtf8
public static MediaType imageUtf8(java.lang.String subType)
Creates a textual image media type with the given subtype and UTF-8 encoding
-
application
public static MediaType application(java.lang.String subType)
Creates a binary application media type with the given subtype.
-
applicationUtf8
public static MediaType applicationUtf8(java.lang.String subType)
Creates a textual application media type with the given subtype and UTF-8 encoding
-
video
public static MediaType video(java.lang.String subType)
Creates a binary video media type with the given subtype.
-
audio
public static MediaType audio(java.lang.String subType)
Creates a binary audio media type with the given subtype.
-
text
public static MediaType text(java.lang.String subType, java.nio.charset.Charset charset)
Creates a non-binary text media type with the given subtype and a specified encoding
-
textUtf8
public static MediaType textUtf8(java.lang.String subType)
Creates a non-binary text media type with the given subtype.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-