Package com.tngtech.jgiven.attachment
Class MediaType
java.lang.Object
com.tngtech.jgiven.attachment.MediaType
Represents a (simplified) Media Type.
- Since:
- 0.7.0
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final MediaType
application/xmlstatic final MediaType
image/gifstatic final MediaType
image/jpegstatic final MediaType
application/jsonstatic final MediaType
text/plainstatic final MediaType
image/pngstatic final MediaType
image/svg+xmlstatic final MediaType
text/xml -
Method Summary
Modifier and TypeMethodDescriptionstatic MediaType
application
(String subType) Creates a binary application media type with the given subtype.static MediaType
applicationUtf8
(String subType) Creates a textual application media type with the given subtype and UTF-8 encodingasString()
static MediaType
Creates a binary audio media type with the given subtype.static MediaType
binary
(MediaType.Type type, String subType) Creates a binary media type with the given type and subtypeThe subtype of the Media Type.getType()
The type of the Media Type.static MediaType
Creates a binary image media type with the given subtype.static MediaType
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, String subType, Charset charSet) Creates a non-binary media type with the given type, subtype, and charSetstatic MediaType
nonBinaryUtf8
(MediaType.Type type, String subType) Creates a non-binary media type with the given type, subtype, and UTF-8 encodingstatic MediaType
Creates a non-binary text media type with the given subtype and a specified encodingstatic MediaType
Creates a non-binary text media type with the given subtype.toString()
static MediaType
Creates a binary video media type with the given subtype.
-
Field Details
-
GIF
image/gif -
PNG
image/png -
JPEG
image/jpeg -
SVG_UTF_8
image/svg+xml -
PLAIN_TEXT_UTF_8
text/plain -
JSON_UTF_8
application/json -
APPLICATION_XML_UTF_8
application/xml -
XML_UTF_8
text/xml
-
-
Method Details
-
getType
The type of the Media Type. -
getSubType
The subtype of the Media Type. -
isBinary
public boolean isBinary()Whether this media type is binary or not. -
isImage
public boolean isImage() -
getCharset
- Returns:
- the charset of this media type if one is specified
- Throws:
IllegalArgumentException
- if no charset is specified
-
asString
-
binary
Creates a binary media type with the given type and subtype- Throws:
JGivenWrongUsageException
- if any of the given arguments isnull
-
nonBinary
Creates a non-binary media type with the given type, subtype, and charSet- Throws:
JGivenWrongUsageException
- if any of the given arguments isnull
-
nonBinaryUtf8
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
Creates a binary image media type with the given subtype. -
imageUtf8
Creates a textual image media type with the given subtype and UTF-8 encoding -
application
Creates a binary application media type with the given subtype. -
applicationUtf8
Creates a textual application media type with the given subtype and UTF-8 encoding -
video
Creates a binary video media type with the given subtype. -
audio
Creates a binary audio media type with the given subtype. -
text
Creates a non-binary text media type with the given subtype and a specified encoding -
textUtf8
Creates a non-binary text media type with the given subtype. -
toString
-