java.lang.Object
io.jooby.MediaType
- All Implemented Interfaces:
Comparable<MediaType>
Implementation of media/content type.
- Since:
- 2.0.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final MediaType
ALL.static final String
ALL.static final MediaType
TEXT_CSS.static final String
TEXT_CSS.static final MediaType
FORM_URLENCODED.static final String
FORM_URLENCODED.static final MediaType
TEXT_HTML.static final String
TEXT_HTML.static final MediaType
APPLICATION_JSON.static final String
APPLICATION_JAVASCRIPT.static final MediaType
APPLICATION_JSON.static final String
APPLICATION_JSON.static final BinaryOperator<MediaType>
Computes and returns the most specific media type of both.static final MediaType
MULTIPART_FORM_DATA.static final String
MULTIPART_FORM_DATA.static final String
APPLICATION_OCTET_STREAM.static final MediaType
APPLICATION_OCTET_STREAM.static final MediaType
TEXT_PLAIN.static final String
TEXT_PLAIN.static final MediaType
APPLICATION_XML.static final String
APPLICATION_XML.static final MediaType
YAML.static final String
YAML. -
Method Summary
Modifier and TypeMethodDescriptionstatic MediaType
Mediatype by file extension.static MediaType
Mediatype by file extension.static MediaType
Mediatype by file extension.static MediaType
byFileExtension
(String ext) Mediatype by file extension.int
boolean
Charset ornull
.getParameter
(String name) Get a parameter that matches the given name ornull
.float
Value ofq
parameter.Subtype segment of mediatype (trailing type).getType()
Type segment of mediatype (leading type).getValue()
Media type value without parameters.int
hashCode()
boolean
isJson()
Indicates whenever this is a json mediatype.boolean
Indicates whenever this is a textual mediatype.boolean
True if this mediatype is compatible with the given content type.boolean
True if this mediatype is compatible with the given content type.Parse one or more mediatype values.toContentTypeHeader
(Charset charset) Render a content type header and add the charset parameter (when present).toString()
static MediaType
Parse a string value into a media-type.
-
Field Details
-
MOST_SPECIFIC
Computes and returns the most specific media type of both. -
JSON
APPLICATION_JSON.- See Also:
-
XML
APPLICATION_XML.- See Also:
-
TEXT
TEXT_PLAIN.- See Also:
-
HTML
TEXT_HTML.- See Also:
-
JS
APPLICATION_JAVASCRIPT.- See Also:
-
CSS
TEXT_CSS.- See Also:
-
OCTET_STREAM
APPLICATION_OCTET_STREAM.- See Also:
-
FORM_URLENCODED
FORM_URLENCODED.- See Also:
-
MULTIPART_FORMDATA
MULTIPART_FORM_DATA.- See Also:
-
YAML
YAML.- See Also:
-
ALL
ALL.- See Also:
-
json
APPLICATION_JSON. -
yaml
YAML. -
xml
APPLICATION_XML. -
text
TEXT_PLAIN. -
html
TEXT_HTML. -
js
APPLICATION_JSON. -
css
TEXT_CSS. -
octetStream
APPLICATION_OCTET_STREAM. -
form
FORM_URLENCODED. -
multipart
MULTIPART_FORM_DATA. -
all
ALL.
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
getParameter
Get a parameter that matches the given name ornull
.- Parameters:
name
- Parameter name.- Returns:
- Parameter value or
null
.
-
getValue
Media type value without parameters.- Returns:
- Media type value.
-
toContentTypeHeader
Render a content type header and add the charset parameter (when present).- Parameters:
charset
- Charset.- Returns:
- Content type header.
-
getQuality
@NonNull public float getQuality()Value ofq
parameter.- Returns:
- Value of
q
parameter.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<MediaType>
-
isTextual
public boolean isTextual()Indicates whenever this is a textual mediatype.- Returns:
- True for textual mediatype.
-
isJson
public boolean isJson()Indicates whenever this is a json mediatype.- Returns:
- True for json mediatype.
-
getCharset
Charset ornull
.- Returns:
- Charset or
null
.
-
getType
Type segment of mediatype (leading type).- Returns:
- Type segment of mediatype (leading type).
-
getSubtype
Subtype segment of mediatype (trailing type).- Returns:
- Subtype segment of mediatype (trailing type).
-
matches
True if this mediatype is compatible with the given content type.- Parameters:
mediaType
- Media type to test.- Returns:
- True if this mediatype is compatible with the given content type.
-
matches
True if this mediatype is compatible with the given content type.- Parameters:
type
- Media type to test.- Returns:
- True if this mediatype is compatible with the given content type.
-
valueOf
Parse a string value into a media-type.- Parameters:
value
- String media-type.- Returns:
- Media type.
-
parse
Parse one or more mediatype values. Mediatype must be separated by comma,
.- Parameters:
value
- Mediatype comma separated value.- Returns:
- One or more mediatypes.
-
byFile
Mediatype by file extension.- Parameters:
file
- File.- Returns:
- Mediatype.
-
byFile
Mediatype by file extension.- Parameters:
file
- File.- Returns:
- Mediatype.
-
byFile
Mediatype by file extension.- Parameters:
filename
- File.- Returns:
- Mediatype.
-
byFileExtension
Mediatype by file extension.- Parameters:
ext
- File extension.- Returns:
- Mediatype.
-
toString
-